floostack/transcoder

How to merge two mp4 files?

fujiawei-dev opened this issue · 2 comments

How to merge two mp4 files?
I need to implement the following functions.

ffmpeg -i 1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts
ffmpeg -i 2.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 2.ts

ffmpeg -i "concat:1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 1merge2.mp4
0x-1 commented

I don't think this is an issue.
Here some help of how you could do it:

"-vcodec" is the "-c:v"/VideoCodec option
"-acodex" is "-c:a"/AudioCodec option

use ExtraArgs for any missing option
opts := ffmpeg.Options{
ExtraArgs: ...
}

You need to add:
"-i secondFile"
"-vbsf h264_mp4toannexb"
"-absf aac_adtstoasc"

concat is basically "-f concat" when you use 2 x"-i inputFile"
-f is also supported with the OutputFormat option.

I don't think this is an issue.
Here some help of how you could do it:

"-vcodec" is the "-c:v"/VideoCodec option
"-acodex" is "-c:a"/AudioCodec option

use ExtraArgs for any missing option
opts := ffmpeg.Options{
ExtraArgs: ...
}

You need to add:
"-i secondFile"
"-vbsf h264_mp4toannexb"
"-absf aac_adtstoasc"

concat is basically "-f concat" when you use 2 x"-i inputFile"
-f is also supported with the OutputFormat option.

@0x-1 you mean this? ffmpeg -f concat -i filelist.txt -c copy output.mkv?
in this library don't support write for this?
look ffmpeg/ffmpeg.go:53. when my input is not a Metadata , func GetMetadata will return an error.

so use this library cant merge two files.