N
N
NerVik2015-01-13 09:33:43
Video
NerVik, 2015-01-13 09:33:43

How to merge two .mp4s in ffmpeg without transcoding?

Aloha!
There is a task to merge two .mp4 videos without transcoding through ffmpeg or another console program.
google how to do it - did not work.
"ffmpeg -i concat:"input1.mp4|input2.mp4" -c copy out.mp4" does not merge them, the output is the file that was the first argument.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
gt8one, 2017-06-11
@NerVik

FFmpeg: joining and joining MP4 video files

Video files in an MP4 container cannot be concatenated using the concat operator. But you can pre-convert these files into a container, for example, MPEG-TS without transcoding video and audio:
ffmpeg -i vid1.mp4 -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f mpegts vid1.ts
ffmpeg -i vid2.mp4 -acodec copy -vcodec copy -vbsf h264_mp4toannexb -f mpegts vid2.ts

And then these files can already be connected using the concat operator into the final mp4 file:
ffmpeg -i "concat:vid1.ts|vid2.ts" -vcodec copy -acodec copy out.mp4

S
Sergey Lerg, 2015-01-13
@Lerg

Without transcoding it is only possible if the files are of the same format - the codec and encoding parameters must match.
You need to select first video streams from both files
Then join m4v files, I'm not sure that simple gluing is enough, but it is quite possible.
And at the end you need to pack the resulting stream back into mp4. To do this, you need all the data from the file headers. More here:
processors.wiki.ti.com/index.php/Extracting_MPEG-4...

E
Eugene, 2015-01-13
@Nc_Soft

mp4box

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question