Convert Y4M to MP4 — Free Online Tool

Convert Y4M (YUV4MPEG2) lossless uncompressed video files to MP4 using H.264 encoding with AAC audio. This tool compresses raw YUV frame data into a streamable, web-compatible MP4 — dramatically reducing file sizes while producing broadcast-quality output through libx264's proven CRF-based encoding.

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 stored in full, making files enormous but pixel-perfect. During this conversion, FFmpeg reads each raw YUV frame and feeds it through the libx264 encoder, which applies H.264 compression using a Constant Rate Factor (CRF) of 23. This means the encoder dynamically allocates bits per frame to maintain consistent perceptual quality rather than a fixed bitrate. Since Y4M typically carries no audio track, no audio transcoding occurs unless the source file contains audio, in which case it would be encoded to AAC at 128k. The output MP4 also receives the -movflags +faststart flag, which relocates the MP4 index (moov atom) to the beginning of the file, enabling progressive streaming and browser playback before the full file is downloaded.

What Each Flag Does

Flag What it does
ffmpeg Invokes the FFmpeg binary — the open-source multimedia processing engine that performs the Y4M decoding and H.264 encoding pipeline underlying this conversion.
-i input.y4m Specifies the input Y4M file. FFmpeg reads the YUV4MPEG2 header to determine frame dimensions, frame rate, and colorspace before decoding each raw YUV frame in sequence.
-c:v libx264 Selects libx264 as the H.264 video encoder, which compresses the raw YUV frames from the Y4M source into an efficient, universally playable video stream for the MP4 container.
-c:a aac Sets the audio encoder to AAC (Advanced Audio Coding), the standard audio codec for MP4 files. Since Y4M carries no audio, this flag has no practical effect here but ensures correct behavior if an audio stream were present.
-crf 23 Sets the Constant Rate Factor to 23 for the H.264 encoder, controlling the quality-to-size tradeoff when compressing the raw Y4M frames. Lower values produce higher quality and larger files; 23 is the libx264 default and represents a good balance for general distribution.
-b:a 128k Sets the AAC audio bitrate to 128 kilobits per second, a standard quality level for stereo audio in MP4 files. This is a no-op for typical Y4M sources that contain no audio track.
-movflags +faststart Moves the MP4 moov atom (file index) to the beginning of the output file, enabling web browsers and streaming players to start playing the video before the full download completes.
output.mp4 Specifies the output filename and tells FFmpeg to use the MP4 container format, which wraps the H.264 video stream produced from the Y4M source into a widely compatible, streamable file.

Common Use Cases

  • Encoding the output of a video synthesis or compositing pipeline (e.g., from tools like Blender, FFmpeg filtergraphs, or avisynth) that pipes lossless Y4M into a distributable H.264 MP4 for upload or sharing
  • Archiving rendered animation frames exported as Y4M from open-source tools like Kdenlive or Shotcut into a compact MP4 for client delivery
  • Compressing a Y4M intermediate file produced during a lossless editing workflow into a web-optimized MP4 for embedding in a website or CMS
  • Converting Y4M test sequences used in video codec research or quality benchmarking into standard MP4 files for presentation or documentation
  • Reducing the massive file size of a Y4M capture from a video hardware device or screen recorder before uploading to a video platform like YouTube or Vimeo
  • Finalizing a post-production workflow where Y4M was used as a lossless interchange format between applications, producing a universally playable MP4 deliverable

Frequently Asked Questions

Y4M stores raw, uncompressed YUV pixel data for every single frame — a 1080p30 Y4M file consumes roughly 180MB per second. H.264 in the output MP4 uses inter-frame compression, storing only the differences between frames rather than full frames repeatedly. At the default CRF 23, you can expect compression ratios of 100:1 or greater compared to the raw Y4M source, with minimal perceptible quality loss for most content.
Yes — H.264 encoding with libx264 is a lossy process, so some quality is lost relative to the lossless Y4M source. However, at CRF 23 the quality loss is designed to be perceptually transparent for most content. If you need higher fidelity, lower the CRF value (e.g., CRF 18 or CRF 15) in the FFmpeg command — lower values preserve more detail at the cost of larger file sizes. For archival purposes, CRF 0 enables lossless H.264 output.
No. Y4M is a video-only format and does not support audio tracks, so the output MP4 will also contain no audio stream. The -c:a aac and -b:a 128k flags in the command are present for completeness but will have no effect if there is no audio in the source. Most video players and platforms handle silent MP4 files without issue.
The -crf flag controls H.264 encoding quality using Constant Rate Factor mode. The scale runs from 0 (lossless) to 51 (worst quality), with 23 as the default and a visually good range typically between 18 and 28. To change it, modify the value in the command — for example, replace '-crf 23' with '-crf 18' for higher quality output suitable for archival or professional delivery. Each step of 6 roughly halves or doubles the resulting file size.
MP4 files contain a metadata index called the moov atom, which by default is written at the end of the file after encoding completes. The -movflags +faststart flag post-processes the file to move this atom to the beginning, which allows web browsers and streaming players to begin playback before the entire file has been downloaded. This is especially valuable if the resulting MP4 will be served over HTTP or embedded in a webpage.
Yes. On Linux or macOS you can run a shell loop such as: for f in *.y4m; do ffmpeg -i "$f" -c:v libx264 -c:a aac -crf 23 -b:a 128k -movflags +faststart "${f%.y4m}.mp4"; 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 -movflags +faststart "%~nf.mp4". Each Y4M file will be independently encoded to a matching MP4 with the same quality settings.

Technical Notes

Y4M (YUV4MPEG2) encodes frames in planar YUV colorspace — most commonly YUV 4:2:0, though 4:2:2 and 4:4:4 variants exist. When libx264 encodes the output MP4, it defaults to yuv420p pixel format for maximum compatibility with devices and browsers. If your Y4M source uses 4:2:2 or 4:4:4 chroma subsampling, this conversion will downsample chroma data to 4:2:0, which is a mild quality tradeoff but necessary for broad playback compatibility. Y4M files carry minimal metadata — typically just frame rate, frame dimensions, and colorspace in a plain-text header — so there is no rich metadata (like timestamps, GPS, or camera data) to preserve. The libx264 encoder's default settings include CABAC entropy coding, automatic scene detection for keyframe placement, and a default encoding speed of 'medium', all of which are reasonable for general use. For very high frame rate Y4M sources (120fps+), ensure the output container and player support the frame rate, as some platforms cap ingestion at 60fps. If lossless output is strictly required, adding '-crf 0' and '-preset veryslow' to the command will produce a lossless H.264 MP4, though file sizes will be substantially larger than a standard CRF 23 encode.

Related Tools