parent
167f2a184a
commit
922ca4cbdd
|
|
@ -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):
|
||||

|
||||
* 全部版本下载, 包括windows图形界面/linux命令行/mac命令行: https://github.com/orestonce/m3u8d/releases
|
||||
* linux/mac版的命令行使用教程
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
2
go.mod
2
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
|
||||
)
|
||||
|
|
|
|||
4
go.sum
4
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=
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 8.2 KiB |
|
|
@ -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"
|
||||
|
|
|
|||
30
merge.go
30
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue