Convert Y4M to TS — Free Online Tool

Convert Y4M (YUV4MPEG2) lossless uncompressed video to MPEG-2 Transport Stream (TS) format, encoding the raw video frames with H.264 (libx264) and packaging the output into a broadcast-compatible container. This is the standard pipeline for compressing uncompressed Y4M intermediate files into a streamable, broadcast-ready TS file suitable for HLS pipelines, digital TV systems, and media servers.

FFmpeg Command

Copy this command to run the same conversion locally with FFmpeg on your desktop. Download FFmpeg

Free — no uploads, no signups. Your files never leave your browser.

Estimated output:

Conversion Complete!

Download

How It Works

Y4M stores raw, uncompressed YUV video frames with no inter-frame compression — every frame is stored in full, making the files enormous but perfectly lossless. During this conversion, FFmpeg reads each raw YUV frame from the Y4M file and encodes them using the libx264 H.264 encoder, applying temporal and spatial compression (including inter-frame prediction and DCT) for the first time. The resulting H.264 video stream, along with any AAC-encoded audio if present, is then muxed into the MPEG-2 Transport Stream container — a packetized format originally designed for broadcast transmission that segments the stream into 188-byte packets. Because Y4M carries no audio, if your source has no audio track, the -c:a aac and -b:a flags are effectively unused. The CRF 23 setting controls the trade-off between file size and visual quality during this first-ever lossy compression step.

What Each Flag Does

Flag What it does
ffmpeg Invokes the FFmpeg command-line tool, which handles the reading, decoding, encoding, and muxing pipeline for this Y4M to TS conversion.
-i input.y4m Specifies the input Y4M file. FFmpeg reads the YUV4MPEG2 header to determine frame dimensions, frame rate, and chroma subsampling format, then streams the raw uncompressed YUV frames into the encoder.
-c:v libx264 Selects the libx264 H.264 encoder to compress the raw YUV frames from the Y4M source. This is the first and only compression step these frames will undergo, converting them from uncompressed YUV pixel data into a spatially and temporally compressed H.264 bitstream suitable for the TS container.
-c:a aac Sets the audio codec to AAC for any audio stream present in the input. Since Y4M carries no audio, this flag has no practical effect in this specific conversion but ensures correct behavior if the command is adapted to include a second audio input source.
-crf 23 Sets the Constant Rate Factor for libx264 to 23, which is the default quality level providing a good balance between file size and visual fidelity. Because Y4M is lossless uncompressed source material, this CRF value determines exactly how much quality is introduced by the H.264 encoding step — lower values (e.g., 18) preserve more detail from the original YUV frames at the cost of larger output files.
-b:a 128k Sets the AAC audio bitrate to 128 kilobits per second, the standard quality level for stereo AAC audio in broadcast and streaming contexts. This flag is included for completeness but has no effect when converting a Y4M file that contains no audio track.
output.ts Specifies the output filename and triggers FFmpeg to mux the H.264 video stream into an MPEG-2 Transport Stream container, automatically formatting the H.264 bitstream in Annex B format and packaging it into 188-byte TS packets as required by the broadcast standard.

Common Use Cases

  • Compressing the output of a video synthesis or rendering tool (like libav or a custom shader pipeline) that exports Y4M for downstream encoding into a broadcast-ready TS file
  • Preparing lossless Y4M frames from a video editing intermediate workflow for delivery to an HLS streaming server, which requires TS-segmented H.264 content
  • Converting Y4M files produced by tools like ffmpeg pipe chains, MPlayer, or VapourSynth into a format compatible with digital broadcast playout systems and MPEG-2 transport muxers
  • Archiving a lossless Y4M source into a much smaller H.264-encoded TS file for long-term storage while retaining broadcast container compatibility
  • Taking raw YUV frames exported from scientific or medical imaging software in Y4M format and encoding them into TS for playback on broadcast-grade hardware monitors
  • Encoding Y4M output from a screen capture or test pattern generator into TS format for use in broadcast QA, signal testing, or transmission simulation workflows

Frequently Asked Questions

Yes — this is the first lossy compression step your video will undergo, since Y4M is completely uncompressed. The default CRF 23 setting with libx264 produces visually high-quality output that is nearly indistinguishable from the source at normal viewing distances, but it is not bit-for-bit identical to the original frames. If you need visually lossless output, lower the CRF value toward 0 (e.g., -crf 0 enables lossless H.264 mode), though this will produce significantly larger files.
Y4M stores every video frame as raw, uncompressed YUV pixel data, so a single second of 1080p30 Y4M video can consume over 180 MB. H.264 inside a TS container uses inter-frame compression — encoding only the differences between frames — which can reduce file size by 50x to 200x depending on content complexity and the CRF setting. The dramatic size reduction is expected and is the primary reason for this conversion.
Y4M is a video-only format and carries no audio streams whatsoever. If your original source had audio, it was discarded before or during Y4M export. The -c:a aac and -b:a 128k flags in the FFmpeg command are included by default but will have no effect if the Y4M input has no audio track. The resulting TS file will contain only a video stream unless you explicitly add an audio source using FFmpeg's -i flag for a second input.
MPEG-2 Transport Stream is specifically designed for broadcast and streaming environments where the stream may be received mid-transmission or must be robust to packet loss — each 188-byte TS packet is self-contained enough to allow recovery. TS is the required container format for HLS (HTTP Live Streaming) segments, IPTV playout, and digital broadcast systems. If you are targeting general web delivery or file-based playback, MP4 would be a simpler choice, but TS is the correct format for live streaming pipelines and broadcast infrastructure.
Adjust the -crf value in the command: lower numbers mean higher quality and larger files, higher numbers mean lower quality and smaller files. The range is 0 (lossless H.264) to 51 (extremely lossy). For example, replacing -crf 23 with -crf 18 produces near-visually-lossless output that most viewers cannot distinguish from the uncompressed Y4M source, while -crf 28 noticeably reduces file size at the cost of some detail. For broadcast delivery, values between 18 and 23 are typical.
Yes. On Linux or macOS, you can run a shell loop: `for f in *.y4m; do ffmpeg -i "$f" -c:v libx264 -c:a aac -crf 23 -b:a 128k "${f%.y4m}.ts"; done`. On Windows Command Prompt, use: `for %f in (*.y4m) do ffmpeg -i "%f" -c:v libx264 -c:a aac -crf 23 -b:a 128k "%~nf.ts"`. This is particularly useful when processing Y4M outputs from a render farm or batch processing pipeline. Note that Y4M files are very large, so ensure you have sufficient disk space for both input and output files simultaneously.

Technical Notes

Y4M files embed color space metadata in their header (e.g., C420 for 4:2:0 chroma subsampling, C444 for 4:4:4), and FFmpeg reads this to correctly configure the libx264 encoder's chroma subsampling. If your Y4M source uses 4:4:4 or 4:2:2 chroma, be aware that libx264 will by default convert to 4:2:0 for TS output unless you explicitly pass -pix_fmt yuv444p and configure the encoder accordingly — most broadcast TS workflows expect 4:2:0 anyway. The MPEG-2 TS container supports multiple audio tracks and subtitles, but since Y4M carries no audio or subtitle data, these features are unused in this specific conversion without additional inputs. The TS container uses a fixed 188-byte packet structure and requires the H.264 stream to be formatted in Annex B byte-stream format rather than AVCC, which FFmpeg handles automatically when muxing to TS. One known limitation: TS does not support chapter markers, so no chapter metadata can be embedded regardless of source. If your Y4M file was produced by a tool that embeds frame rate or aspect ratio in the Y4M header, FFmpeg will honor those values; if not, you may need to specify -r and -aspect manually to ensure correct playback on strict broadcast decoders.

Related Tools