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.mp4Parameter Breakdown
-i input.ts: Specifies the input ATSC MPEG-TS file.-vf yadif: Applies the “Yet Another Deinterlacing Filter.” Since most ATSC broadcast signals are interlaced (1080i or 480i), this filter converts the video to progressive format (1080p or 480p) to ensure smooth playback on modern TVs, phones, and computers.-c:v libx264: Selects the H.264 video encoder (CPU-based), which offers the best quality-to-file-size ratio.-crf 21: Sets the Constant Rate Factor. The scale ranges from 0 (lossless) to 51 (worst quality). A value between 18 and 23 is ideal for high-definition ATSC sources, balancing excellent visual quality with a reasonable file size.-preset medium: Controls the trade-off between encoding speed and compression efficiency. “Medium” is the default and provides a good balance, but you can use “slow” for better compression or “fast” if you are in a hurry.-c:a aac -b:a 192k: Transcodes the original AC-3 audio to AAC format at a bitrate of 192kbps, which is widely compatible across all playback devices.
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.mkvNote: 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.mp4This command uses hardware-accelerated decoding
(mpeg2_qsv), hardware-based deinterlacing/scaling
(deinterlace_qsv), and hardware encoding
(h264_qsv) for maximum performance.