How to Transcode Video to Lagarith Lossless with FFmpeg

This guide provides a straightforward tutorial on how to transcode video files into the lossless Lagarith video codec using the powerful command-line tool FFmpeg. You will learn the specific FFmpeg commands, required parameters, and configuration options needed to achieve high-quality, lossless video compression suitable for video editing and archiving.

The Basic Lagarith Transcoding Command

Lagarith is a lossless video codec commonly wrapped in an AVI container. To transcode a video to Lagarith using FFmpeg, you need to specify the Lagarith encoder (lagarith) for the video stream.

Run the following basic command in your terminal:

ffmpeg -i input.mp4 -c:v lagarith -c:a pcm_s16le output.avi

Command Breakdown:


Managing Color Spaces and Pixel Formats

Lagarith supports several pixel formats, including YV12 (YUV 4:2:0), YUY2 (YUV 4:2:2), and RGB. To maintain the original color space or force a specific one, use the -pix_fmt flag.

1. Transcoding to Lossless RGB (Best for Graphics and Animations)

If your source video is RGB or you want to maximize color precision:

ffmpeg -i input.mp4 -c:v lagarith -pix_fmt rgb24 -c:a pcm_s16le output.avi

2. Transcoding to YUV 4:2:0 (Standard Video)

If you want to compress standard camera footage while keeping the file size smaller:

ffmpeg -i input.mp4 -c:v lagarith -pix_fmt yuv420p -c:a pcm_s16le output.avi

Copying Existing Audio Without Re-encoding

If your source video already has high-quality audio (such as AAC or AC3) and you want to preserve it without re-encoding, use the -c:a copy parameter:

ffmpeg -i input.mp4 -c:v lagarith -c:a copy output.avi

Verifying the Output File

Once the transcoding process is complete, you can verify that the file was encoded correctly using FFmpeg’s ffprobe tool:

ffprobe output.avi

Look for the video stream line in the output, which should display Video: lagarith.