Question

Does anybody know how to stitch two (or more) videos together using ffmpeg (or another cli)? This is assuming that all the videos are in the same format and the video format being used allows for lossless stitching (no transcode, just end-to-end stitching).

Was it helpful?

Solution

Using ffmpeg I think the command you want is

-newvideo

the help describes this as "add a new video stream to the current output stream"

although I personally have not tried it.

OTHER TIPS

for newer ffmpeg's there is a "concat" input option too: http://ffmpeg.org/faq.html#How-can-I-join-video-files_003f

See also Concatenate two mp4 files using ffmpeg

You can stitch two or more videos with ffmpeg that are in a format that can be concatenated by doing this:

$ cat file1.avi file2.avi > cat_output.avi
$ ffmpeg -i cat_output.avi -r 25 -sameq stitched.avi 

The second step it necessary where ffmpeg merges the joined files into a proper readable video file.

There is no such thing as -newvideo in ffmpeg to my knowledge.

You can concatenate and encode multiple .avis using mencoder like so:

$ cat part1.avi part2.avi > tmp.avi && mencoder -forceidx -oac copy -ovc copy tmp.avi -o final.avi && rm -f tmp.avi

If you're using OS X, mencoder is part of the mplayer Homebrew package. You can install it easily enough with:

$ brew install mplayer

We added support for stitching videos with ffmpeg (static build required) in Java to ffmpeg-cli-wrapper. For stitching videos, check out this example. Library also supports fade in, fade out, text overlays etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top