How to Transcode Video to MPEG-2 Using FFmpeg

This article provides a straightforward guide on how to transcode video files into the MPEG-2 format using the mpeg2video encoder inside FFmpeg. You will learn the essential command-line syntax, key parameters for controlling quality and bitrate, and practical examples for creating compatible MPEG-2 outputs.

Basic MPEG-2 Transcoding Command

To convert a input video file to MPEG-2, you need to specify the mpeg2video encoder for the video stream. Below is the standard command-line structure:

ffmpeg -i input.mp4 -c:v mpeg2video -b:v 5M -c:a mp2 -b:a 192k output.mpg

Parameter Breakdown:

  • -i input.mp4: Specifies the path to your source video file.
  • -c:v mpeg2video: Selects the MPEG-2 video encoder.
  • -b:v 5M: Sets the video bitrate to 5 Megabits per second (Mbps). Since MPEG-2 is an older, less efficient codec, it requires higher bitrates (typically between 4M and 8M) to maintain good visual quality.
  • -c:a mp2: Encodes the audio using the MP2 (MPEG-1 Audio Layer II) codec, which is highly compatible with the MPEG-2 container. Alternatively, you can use ac3 (Dolby Digital).
  • -b:a 192k: Sets the audio bitrate to 192 kbps.
  • output.mpg: The name and format of your output file.

Controlling Quality with Constant Quality (VBR)

Instead of setting a fixed bitrate, you can use the -qscale:v (or -q:v) option to enable Variable Bitrate (VBR) encoding based on a quality scale. This ensures consistent visual quality throughout the video.

ffmpeg -i input.mp4 -c:v mpeg2video -qscale:v 3 -c:a ac3 -b:a 192k output.mpg
  • -qscale:v 3: Standardizes the video quality. The scale ranges from 1 (highest quality, largest file size) to 31 (lowest quality, smallest file size). A value between 2 and 5 is recommended for high-quality MPEG-2 video.

Encoding for DVD Compatibility

MPEG-2 is the standard format for DVD-Video. FFmpeg includes built-in target profiles that automatically set the correct resolution, bitrate, framerate, and GOP (Group of Pictures) structure required for DVD standards.

For NTSC (primarily North America):

ffmpeg -i input.mp4 -target ntsc-dvd output.mpg

For PAL (primarily Europe and Asia):

ffmpeg -i input.mp4 -target pal-dvd output.mpg

Using the -target flag overrides manual codec and bitrate settings to guarantee that the output file strictly complies with DVD authoring specifications.