diff --git a/README.md b/README.md index c3d7428..4bcc94f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ * 没有ffmpeg依赖, 不需要单独配置任何环境 * 提供windows图形界面(Qt), mac、linux命令行, linux支持arm、386、mipsle * 程序会自动将下载的ts文件合并转换格式为mp4 -* windows自带GUI界面的版本下载: [m3u8d_qt_v1.5.4_windows_amd64.exe](https://github.com/orestonce/m3u8d/releases/download/v1.5.4/m3u8d_qt_v1.5.4_windows_amd64.exe): +* windows自带GUI界面的版本下载: [m3u8d_qt_v1.5.5_windows_amd64.exe](https://github.com/orestonce/m3u8d/releases/download/v1.5.5/m3u8d_qt_v1.5.5_windows_amd64.exe): ![](m3u8d-qt/screenshot.png) * 全部版本下载, 包括windows图形界面/linux命令行/mac命令行: https://github.com/orestonce/m3u8d/releases * linux/mac版的命令行使用教程 diff --git a/download.go b/download.go index 6045dec..2748094 100644 --- a/download.go +++ b/download.go @@ -201,7 +201,7 @@ func (this *downloadEnv) RunDownload(req RunDownload_Req) (resp RunDownload_Resp err = MergeTsFileListToSingleMp4(MergeTsFileListToSingleMp4_Req{ TsFileList: tsFileList, OutputMp4: tmpOutputName, - ctx: this.ctx, + Ctx: this.ctx, }) if err != nil { resp.ErrMsg = "合并错误: " + err.Error() diff --git a/export/main.go b/export/main.go index b330bf6..5c0c07b 100644 --- a/export/main.go +++ b/export/main.go @@ -13,7 +13,7 @@ import ( "strings" ) -const version = "1.5.4" +const version = "1.5.5" func main() { BuildCliBinary() // 编译二进制 @@ -29,6 +29,7 @@ func BuildCliBinary() { type buildCfg struct { GOOS string GOARCH string + Ext string } var list = []buildCfg{ { @@ -47,9 +48,14 @@ func BuildCliBinary() { GOOS: "darwin", GOARCH: "amd64", }, + { + GOOS: "windows", + GOARCH: "386", + Ext: ".exe", + }, } for _, cfg := range list { - name := "m3u8d_cli_v" + version + "_" + cfg.GOOS + "_" + cfg.GOARCH + name := "m3u8d_cli_v" + version + "_" + cfg.GOOS + "_" + cfg.GOARCH + cfg.Ext cmd := exec.Command("go", "build", "-trimpath", "-ldflags", "-s -w", "-o", filepath.Join(wd, "bin", name)) cmd.Dir = filepath.Join(wd, "cmd") cmd.Env = append(os.Environ(), "GOOS="+cfg.GOOS) diff --git a/go.mod b/go.mod index 1749dc8..3db95a3 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/orestonce/go2cpp v0.0.0-20220704224208-2d58769247a4 github.com/orestonce/gopool v0.0.0-20220508090328-d7d56d45b171 github.com/spf13/cobra v1.4.0 - github.com/yapingcat/gomedia v0.0.0-20220717141418-916ca463aae9 + github.com/yapingcat/gomedia v0.0.0-20220721095559-a283c87d8a0b golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 golang.org/x/text v0.3.7 ) diff --git a/go.sum b/go.sum index 4bb9fa8..ee7751c 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/yapingcat/gomedia v0.0.0-20220717141418-916ca463aae9 h1:iIeMJO+oyppY4ggENbLREBYro32NnTp5mgMEZRqpXNs= -github.com/yapingcat/gomedia v0.0.0-20220717141418-916ca463aae9/go.mod h1:WSZ59bidJOO40JSJmLqlkBJrjZCtjbKKkygEMfzY/kc= +github.com/yapingcat/gomedia v0.0.0-20220721095559-a283c87d8a0b h1:ugQfEkchgCe+MBtP/Ih+ypTr1WhlcTHahnIDrS1GXoo= +github.com/yapingcat/gomedia v0.0.0-20220721095559-a283c87d8a0b/go.mod h1:WSZ59bidJOO40JSJmLqlkBJrjZCtjbKKkygEMfzY/kc= golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/m3u8d-qt/screenshot.png b/m3u8d-qt/screenshot.png index 6056052..65c32a5 100644 Binary files a/m3u8d-qt/screenshot.png and b/m3u8d-qt/screenshot.png differ diff --git a/m3u8d-qt/version.rc b/m3u8d-qt/version.rc index 28373d6..b8c687d 100644 --- a/m3u8d-qt/version.rc +++ b/m3u8d-qt/version.rc @@ -7,8 +7,8 @@ IDI_ICON1 ICON "favicon.ico" #endif VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,4,0 - PRODUCTVERSION 1,5,4,0 + FILEVERSION 1,5,5,0 + PRODUCTVERSION 1,5,5,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG @@ -23,7 +23,7 @@ VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "080404b0" BEGIN - VALUE "ProductVersion", "1.5.4.0\0" + VALUE "ProductVersion", "1.5.5.0\0" VALUE "ProductName", "m3u8Ƶع\0" VALUE "LegalCopyright", "https://github.com/orestonce/m3u8d\0" VALUE "FileDescription", "m3u8Ƶع\0" diff --git a/merge.go b/merge.go index c17b1c4..f5afaaa 100644 --- a/merge.go +++ b/merge.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "github.com/yapingcat/gomedia/codec" "github.com/yapingcat/gomedia/mp4" "github.com/yapingcat/gomedia/mpeg2" "io/ioutil" @@ -14,7 +15,7 @@ import ( type MergeTsFileListToSingleMp4_Req struct { TsFileList []string OutputMp4 string - ctx context.Context + Ctx context.Context } func MergeTsFileListToSingleMp4(req MergeTsFileListToSingleMp4_Req) (err error) { @@ -33,23 +34,42 @@ func MergeTsFileListToSingleMp4(req MergeTsFileListToSingleMp4_Req) (err error) demuxer := mpeg2.NewTSDemuxer() var OnFrameErr error + var audioTimestamp uint64 = 0 + aacSampleRate := -1 demuxer.OnFrame = func(cid mpeg2.TS_STREAM_TYPE, frame []byte, pts uint64, dts uint64) { if OnFrameErr != nil { return } if cid == mpeg2.TS_STREAM_AAC { - OnFrameErr = muxer.Write(atid, frame, pts, dts) + codec.SplitAACFrame(frame, func(aac []byte) { + if aacSampleRate == -1 { + adts := codec.NewAdtsFrameHeader() + adts.Decode(aac) + aacSampleRate = codec.AACSampleIdxToSample(int(adts.Fix_Header.Sampling_frequency_index)) + } + err = muxer.Write(atid, aac, audioTimestamp, audioTimestamp) + audioTimestamp += uint64(1024 * 1000 / aacSampleRate) //每帧aac采样固定为1024。aac_sampleRate 为采样率 + if err != nil { + OnFrameErr = err + return + } + }) } else if cid == mpeg2.TS_STREAM_H264 { - OnFrameErr = muxer.Write(vtid, frame, pts, dts) + err = muxer.Write(vtid, frame, uint64(pts), uint64(dts)) + if err != nil { + OnFrameErr = err + return + } } else { OnFrameErr = errors.New("unknown cid " + strconv.Itoa(int(cid))) + return } } for idx, tsFile := range req.TsFileList { select { - case <-req.ctx.Done(): - return req.ctx.Err() + case <-req.Ctx.Done(): + return req.Ctx.Err() default: } DrawProgressBar(len(req.TsFileList), idx)