There are lot of options for ffmpeg and other software, I tried "concat" method with ffmpeg and tried mkvmerge, they didn't work well for JPEG video (MJPG). I would use any tool that will keep quality, but preferably ffmpeg.
Here are specifications of the videos (they're both the same):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.MOV':
Metadata:
major_brand : qt
minor_version : 537331972
compatible_brands: qt pana
Duration: 00:00:30.00, start: 0.000000, bitrate: 29166 kb/s
Stream #0:0(eng): Video: mjpeg (jpeg / 0x6765706A), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 28486 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-04-02T14:53:42.000000Z
encoder : Photo - JPEG
Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 16000 Hz, mono, s16, 256 kb/s (default)
Simplest methods
The simplest method to join MJPEG videos would be to just use the
cat
tool or the concat protocol inffmpeg
. But I almost never suggest these as they only work for the simplest formats and there are too many ways for these methods to create broken outputs.Best method
The concat demuxer is "smarter" than
cat
or the concat protocol so it is more robust and less likely to create broken outputs.Create a text file named
input.txt
listing the videos you want to concatenate.Run
ffmpeg
and give itinput.txt
as the input:This assumes your inputs have the same attributes: video format, frame rate, pixel format (YUV 4:2:0 vs YUV 4:2:2 vs YUV 4:4:4), width, height, audio format, channel layout, and sample rate.
The example uses stream copy mode (
-c copy
) so it will avoid re-encoding and therefore preserve the quality.See FFmpeg Wiki: Concatenate for more info.
Like this:
And yes this works.
Why not? These commands are pretty generic and work for me. I hardly use mjpg and I did not find issues with Motion JPEG for ffmeg.
Alternatives