Transcode ATSC MPEG-2 to H.264 with FFmpeg

This article provides a straightforward guide on how to use FFmpeg to decode ATSC MPEG-2 video streams and transcode them into highly compatible H.264 video. We will cover the essential command-line parameters, including how to handle interlaced broadcast video, transcode the accompanying AC-3 audio, and optimize the output quality for modern media players.

The Standard FFmpeg Command

ATSC broadcasts are typically delivered in an MPEG-TS (.ts) container featuring MPEG-2 video and AC-3 (Dolby Digital) audio. Because ATSC video is often interlaced, the transcoding command must include a deinterlacing filter to prevent visual artifacts on progressive screens.

Here is the standard command to transcode ATSC MPEG-2 to H.264:

ffmpeg -i input.ts -vf yadif -c:v libx264 -crf 21 -preset medium -c:a aac -b:a 192k output.mp4

Parameter Breakdown

Alternative: Copying the Audio Stream

If you want to preserve the original multi-channel AC-3 (Dolby Digital) audio stream without re-encoding it, you can copy the audio track directly. This saves processing time and preserves the exact original audio quality.

ffmpeg -i input.ts -vf yadif -c:v libx264 -crf 21 -preset medium -c:a copy output.mkv

Note: When copying AC-3 audio, it is recommended to use the .mkv (Matroska) or .ts output container, as .mp4 has limited support for certain legacy AC-3 configurations on older devices.

Hardware Accelerated Transcoding (Intel Quick Sync)

If your computer has an Intel processor with Quick Sync Video (QSV), you can offload the decoding and encoding to the hardware GPU to speed up the process significantly:

ffmpeg -hwaccel qsv -c:v mpeg2_qsv -i input.ts -vf "deinterlace_qsv,scale_qsv" -c:v h264_qsv -global_quality 21 -c:a aac -b:a 192k output.mp4

This command uses hardware-accelerated decoding (mpeg2_qsv), hardware-based deinterlacing/scaling (deinterlace_qsv), and hardware encoding (h264_qsv) for maximum performance.