3

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)
3

Simplest methods

The simplest method to join MJPEG videos would be to just use the cat tool or the concat protocol in ffmpeg. 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.

  1. Create a text file named input.txt listing the videos you want to concatenate.

    file 'input1.mov'
    file 'input2.mov'
    
  2. Run ffmpeg and give it input.txt as the input:

    ffmpeg -f concat -i input.txt -c copy output.mov
    
    • 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.

0

Like this:

ffmpeg -i {file1} -qscale:v 1 {file1}
ffmpeg -i {file2} -qscale:v 1 {file2}
ffmpeg -i concat:"{file1}|{file2}" -c copy {both}
ffmpeg -i {both} -qscale:v 2 {final}

And yes this works.

they didn't work well for JPEG video (MJPG)

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

mencoder -ovc copy -oac copy {file1} {file2} -o {result}
  • I'm getting only black background on videos. – R S Apr 9 '20 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.