更新gomedia

main v1.5.5
orestonce 2022-07-23 11:21:52 +08:00
parent 167f2a184a
commit 922ca4cbdd
8 changed files with 41 additions and 15 deletions

View File

@ -3,7 +3,7 @@
* 没有ffmpeg依赖, 不需要单独配置任何环境 * 没有ffmpeg依赖, 不需要单独配置任何环境
* 提供windows图形界面(Qt), mac、linux命令行, linux支持arm、386、mipsle * 提供windows图形界面(Qt), mac、linux命令行, linux支持arm、386、mipsle
* 程序会自动将下载的ts文件合并转换格式为mp4 * 程序会自动将下载的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) ![](m3u8d-qt/screenshot.png)
* 全部版本下载, 包括windows图形界面/linux命令行/mac命令行: https://github.com/orestonce/m3u8d/releases * 全部版本下载, 包括windows图形界面/linux命令行/mac命令行: https://github.com/orestonce/m3u8d/releases
* linux/mac版的命令行使用教程 * linux/mac版的命令行使用教程

View File

@ -201,7 +201,7 @@ func (this *downloadEnv) RunDownload(req RunDownload_Req) (resp RunDownload_Resp
err = MergeTsFileListToSingleMp4(MergeTsFileListToSingleMp4_Req{ err = MergeTsFileListToSingleMp4(MergeTsFileListToSingleMp4_Req{
TsFileList: tsFileList, TsFileList: tsFileList,
OutputMp4: tmpOutputName, OutputMp4: tmpOutputName,
ctx: this.ctx, Ctx: this.ctx,
}) })
if err != nil { if err != nil {
resp.ErrMsg = "合并错误: " + err.Error() resp.ErrMsg = "合并错误: " + err.Error()

View File

@ -13,7 +13,7 @@ import (
"strings" "strings"
) )
const version = "1.5.4" const version = "1.5.5"
func main() { func main() {
BuildCliBinary() // 编译二进制 BuildCliBinary() // 编译二进制
@ -29,6 +29,7 @@ func BuildCliBinary() {
type buildCfg struct { type buildCfg struct {
GOOS string GOOS string
GOARCH string GOARCH string
Ext string
} }
var list = []buildCfg{ var list = []buildCfg{
{ {
@ -47,9 +48,14 @@ func BuildCliBinary() {
GOOS: "darwin", GOOS: "darwin",
GOARCH: "amd64", GOARCH: "amd64",
}, },
{
GOOS: "windows",
GOARCH: "386",
Ext: ".exe",
},
} }
for _, cfg := range list { 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 := exec.Command("go", "build", "-trimpath", "-ldflags", "-s -w", "-o", filepath.Join(wd, "bin", name))
cmd.Dir = filepath.Join(wd, "cmd") cmd.Dir = filepath.Join(wd, "cmd")
cmd.Env = append(os.Environ(), "GOOS="+cfg.GOOS) cmd.Env = append(os.Environ(), "GOOS="+cfg.GOOS)

2
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/orestonce/go2cpp v0.0.0-20220704224208-2d58769247a4 github.com/orestonce/go2cpp v0.0.0-20220704224208-2d58769247a4
github.com/orestonce/gopool v0.0.0-20220508090328-d7d56d45b171 github.com/orestonce/gopool v0.0.0-20220508090328-d7d56d45b171
github.com/spf13/cobra v1.4.0 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/net v0.0.0-20220617184016-355a448f1bc9
golang.org/x/text v0.3.7 golang.org/x/text v0.3.7
) )

4
go.sum
View File

@ -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/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 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 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-20220721095559-a283c87d8a0b h1:ugQfEkchgCe+MBtP/Ih+ypTr1WhlcTHahnIDrS1GXoo=
github.com/yapingcat/gomedia v0.0.0-20220717141418-916ca463aae9/go.mod h1:WSZ59bidJOO40JSJmLqlkBJrjZCtjbKKkygEMfzY/kc= 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 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc=
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 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= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -7,8 +7,8 @@ IDI_ICON1 ICON "favicon.ico"
#endif #endif
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,5,4,0 FILEVERSION 1,5,5,0
PRODUCTVERSION 1,5,4,0 PRODUCTVERSION 1,5,5,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG FILEFLAGS VS_FF_DEBUG
@ -23,7 +23,7 @@ VS_VERSION_INFO VERSIONINFO
BEGIN BEGIN
BLOCK "080404b0" BLOCK "080404b0"
BEGIN BEGIN
VALUE "ProductVersion", "1.5.4.0\0" VALUE "ProductVersion", "1.5.5.0\0"
VALUE "ProductName", "m3u8视频下载工具\0" VALUE "ProductName", "m3u8视频下载工具\0"
VALUE "LegalCopyright", "https://github.com/orestonce/m3u8d\0" VALUE "LegalCopyright", "https://github.com/orestonce/m3u8d\0"
VALUE "FileDescription", "m3u8视频下载工具\0" VALUE "FileDescription", "m3u8视频下载工具\0"

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"errors" "errors"
"github.com/yapingcat/gomedia/codec"
"github.com/yapingcat/gomedia/mp4" "github.com/yapingcat/gomedia/mp4"
"github.com/yapingcat/gomedia/mpeg2" "github.com/yapingcat/gomedia/mpeg2"
"io/ioutil" "io/ioutil"
@ -14,7 +15,7 @@ import (
type MergeTsFileListToSingleMp4_Req struct { type MergeTsFileListToSingleMp4_Req struct {
TsFileList []string TsFileList []string
OutputMp4 string OutputMp4 string
ctx context.Context Ctx context.Context
} }
func MergeTsFileListToSingleMp4(req MergeTsFileListToSingleMp4_Req) (err error) { func MergeTsFileListToSingleMp4(req MergeTsFileListToSingleMp4_Req) (err error) {
@ -33,23 +34,42 @@ func MergeTsFileListToSingleMp4(req MergeTsFileListToSingleMp4_Req) (err error)
demuxer := mpeg2.NewTSDemuxer() demuxer := mpeg2.NewTSDemuxer()
var OnFrameErr error var OnFrameErr error
var audioTimestamp uint64 = 0
aacSampleRate := -1
demuxer.OnFrame = func(cid mpeg2.TS_STREAM_TYPE, frame []byte, pts uint64, dts uint64) { demuxer.OnFrame = func(cid mpeg2.TS_STREAM_TYPE, frame []byte, pts uint64, dts uint64) {
if OnFrameErr != nil { if OnFrameErr != nil {
return return
} }
if cid == mpeg2.TS_STREAM_AAC { 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 { } 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 { } else {
OnFrameErr = errors.New("unknown cid " + strconv.Itoa(int(cid))) OnFrameErr = errors.New("unknown cid " + strconv.Itoa(int(cid)))
return
} }
} }
for idx, tsFile := range req.TsFileList { for idx, tsFile := range req.TsFileList {
select { select {
case <-req.ctx.Done(): case <-req.Ctx.Done():
return req.ctx.Err() return req.Ctx.Err()
default: default:
} }
DrawProgressBar(len(req.TsFileList), idx) DrawProgressBar(len(req.TsFileList), idx)