Skip to main content

Video Format Conversion

Introduction to FFMPEGffmpeg

FFMPEGffmpeg is a free and opensource tool that can be used to convert images and videos to different formats. The tool can be used to convert any video file to MJPEG format so that it can be imported and played by the MJPEG decoder behavior.

Installing FFMPEGffmpeg
Using the FFMPEGffmpeg tool to convert MP4 videos to MJPEG

The following command can be used to convert an mp4 file into MJPEG format:

ffmpeg -i input.mp4 -c:v mjpeg -q:v 2 -pix_fmt yuvj420p -huffman optimal -vf "scale=400:225" -f mjpeg -t 10 -r 15 output.mjpeg

The breakdown of the arguments in the command is as follow:

  • ffmpeg - The name of the tool
  • -i - Specifies the input file
  • -c:v mjpeg - Encodes all video channels with the mjpeg codec
  • -q:v 2 - This is the quality scale for the video stream. Values are from 1=best to 31=worst
  • -pix_fmt yuvj420p - Select the pixel format as YUV420
  • -huffman optimal - Use optimal huffman coding
  • -vf "scale=4--:400:225" - Set the output video resolution
  • -f mjpeg - forceForce output file format as mjpeg
  • -t 10 - restrictRestrict length of output video to 10 seconds
  • -r 15 - Set the output video frame rate to 15 fps
output.jpegmjpeg - name of the output file