Convert Y4M to M2TS — Free Online Tool

Convert Y4M (YUV4MPEG2) lossless raw video files to M2TS (Blu-ray MPEG-2 Transport Stream) format, encoding the uncompressed video stream with H.264 (libx264) and wrapping it in a broadcast-ready BDAV container. This is the standard pipeline from lossless intermediate footage to a compressed, distributable Blu-ray-compatible file.

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 files store raw, uncompressed YUV video frames with no inter-frame compression — every frame is a complete image. During this conversion, FFmpeg reads those raw frames and encodes them with the libx264 H.264 encoder at CRF 23 (a perceptually good default quality level), applying spatial and temporal compression for the first time in the pipeline. Since Y4M carries no audio, the AAC audio stream in the output will only be present if your Y4M source happens to contain an audio track (rare), otherwise the M2TS output will be video-only. The encoded stream is then muxed into the M2TS BDAV container, which wraps everything in an MPEG-2 Transport Stream packet structure compatible with Blu-ray players and AVCHD camcorders. The result is a dramatically smaller file — H.264 at CRF 23 is typically 100–300x smaller than the raw Y4M source — at visually near-lossless quality.

What Each Flag Does

Flag What it does
ffmpeg Invokes the FFmpeg tool. In the browser version, this runs via FFmpeg.wasm (WebAssembly) entirely client-side with no server upload.
-i input.y4m Specifies the input Y4M file. FFmpeg reads the uncompressed YUV frame data and the plain-text Y4M header (which encodes width, height, framerate, interlacing, and pixel format) to configure the decoding pipeline.
-c:v libx264 Selects libx264 as the H.264 video encoder, which will compress the raw YUV frames from the Y4M source for the first time in the pipeline. H.264 is the standard video codec for AVCHD and Blu-ray M2TS content.
-c:a aac Sets the audio codec to AAC (Advanced Audio Coding) using FFmpeg's native AAC encoder. Since Y4M rarely contains audio, this flag will only take effect if an audio stream is present in the source; otherwise it is silently ignored.
-crf 23 Sets the Constant Rate Factor for the H.264 encoder to 23, the libx264 default. Because the Y4M source is lossless, this is the first and only quality-reducing step — lower values (e.g., 18) will produce larger files closer to the original's visual fidelity, while higher values (e.g., 28) will further reduce file size at the cost of detail.
-b:a 128k Sets the AAC audio bitrate to 128 kbps, a standard quality level for stereo audio in M2TS delivery. This flag only applies if an audio stream exists in the Y4M source.
output.m2ts Specifies the output filename and triggers FFmpeg to use the mpegts muxer in BDAV mode (192-byte packets), producing an M2TS file compatible with Blu-ray players and AVCHD devices.

Common Use Cases

  • Delivering the final render from a lossless video pipeline (e.g., from a tool like AviSynth or VapourSynth that outputs Y4M) as a Blu-ray-compatible M2TS file for disc authoring.
  • Archiving rendered CGI or VFX footage that was piped out of a compositor in Y4M format into a compressed, widely playable M2TS file for client delivery.
  • Converting raw Y4M test sequences used in codec benchmarking or video quality research into H.264-encoded M2TS files for playback on consumer Blu-ray hardware.
  • Preparing uncompressed camera test footage captured or converted to Y4M for upload to platforms or NLEs that prefer the M2TS container (common with AVCHD-based workflows).
  • Shrinking massive Y4M intermediate files produced during lossless video editing to a manageable H.264/M2TS format for long-term storage without perceptible quality loss.
  • Converting Y4M output from open-source video tools (such as x264's lossless pipe output) into BDAV M2TS for compatibility with Sony, Panasonic, or Pioneer Blu-ray players.

Frequently Asked Questions

Yes — this conversion introduces lossy compression for the first time. Y4M stores raw, uncompressed YUV pixel data, so every bit of original image data is intact. Encoding to H.264 at CRF 23 (the default) applies perceptual compression that is visually near-transparent for most content, but it is not mathematically lossless. If you need lossless output, you could use CRF 0 with libx264, which produces lossless H.264, or switch the video codec to FLAC-equivalent lossless options — though CRF 0 files will be much larger than CRF 23.
Y4M is completely uncompressed, so a single minute of 1080p footage at 24fps can easily exceed 10–20 GB. H.264 at CRF 23 typically compresses that to around 50–200 MB per minute depending on scene complexity, representing a 100x to 300x size reduction. The M2TS container itself adds minimal overhead compared to a raw H.264 stream. This dramatic reduction is the primary practical reason to perform this conversion.
The Y4M (YUV4MPEG2) format is a video-only format by specification and almost never contains audio in practice. If your source Y4M file has no audio, the resulting M2TS file will also have no audio track — the -c:a aac and -b:a 128k flags in the FFmpeg command will simply have no audio stream to encode. If you need to add audio to the M2TS output, you should supply a separate audio file using an additional -i flag and mix it into the output.
M2TS with H.264 video is the native format of AVCHD and Blu-ray discs, so hardware Blu-ray players, PS3, and PS4 all support it natively when the video stays within Blu-ray profile limits (typically High Profile, Level 4.1 for 1080p). However, the FFmpeg command as written does not explicitly set the H.264 profile or level, so very high resolutions or framerates might produce a stream that exceeds hardware decoder limits. If targeting a specific Blu-ray player, add -profile:v high -level 4.1 to the command.
The -crf 23 flag controls quality and is the primary lever for file size. Lower CRF values mean higher quality and larger files (CRF 18 is often described as 'visually lossless'), while higher values mean smaller files with more compression artifacts (CRF 28–35 for smaller web delivery). CRF 0 produces mathematically lossless H.264. For this Y4M-to-M2TS use case, values between 18 and 23 are recommended if you want to preserve the visual fidelity of your lossless source material.
Yes. On Linux or macOS, you can use a shell loop: for f in *.y4m; do ffmpeg -i "$f" -c:v libx264 -c:a aac -crf 23 -b:a 128k "${f%.y4m}.m2ts"; 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.m2ts". Note that because Y4M files are uncompressed and very large, batch processing can be slow and disk-intensive — ensure you have sufficient temporary storage.

Technical Notes

Y4M (YUV4MPEG2) is a deliberately simple format: it stores planar YUV frames with a plain-text header per frame and no inter-frame compression, making it ideal as a pipe format between video tools but impractical for storage or distribution. When muxing into M2TS, FFmpeg uses the mpegts muxer with the BDAV packet structure (192-byte packets with 4-byte Blu-ray timestamps prepended to standard 188-byte MPEG-TS packets). The libx264 encoder works directly from Y4M's native YUV colorspace data, avoiding any colorspace conversion overhead if the source is yuv420p — the most common Y4M pixel format. If your Y4M source uses a higher-chroma-resolution format like yuv444p, libx264 will internally convert to yuv420p by default, which is a chroma subsampling step and a form of quality loss. M2TS supports multiple audio tracks and subtitles, but since Y4M carries no such metadata, none will be present in the output. The M2TS container does not support embedded chapter markers. File sizes from this conversion are highly content-dependent: still or slow-moving frames compress extremely well with H.264, while rapid motion or film grain in the raw Y4M source will result in larger output files at any given CRF value.

Related Tools