# Lossless compression for video with audio

What are the best settings to render if I want lossless compression of the video and audio?

(I'm rendering a small clip that will be added to the Video Editor of multiple Blender files)

I couldn't get DNxHD to work (which isn't lossless, but very close to it), so I suggest the following options, which work for me:

• Output Format H.264 (RGB)

• Encoding Preset H264

• Lossless Output (none of the values in the panel matter)

• Audio Codec FLAC (bitrate doesn't matter again)

This will give you great quality at a relatively small filesize.

• It appears that even with these settings, the bitrate does matter (for the video, but not audio). As an extreme example, I rendered once with bitrate 6000 and once with bitrate 50. This first file was 559KB and seemed lossless to the eye. The second was 266KB and clearly had undergone lossy compression (as seen be playing in VLC or importing into VSE). You can see a comparison of a single frame here. Should I report his as a bug? – Garrett Feb 16 '14 at 2:30
• Definately, that shouldn't happen. The options should also be grayed out, so you know they won't do anything. – CodeManX Feb 16 '14 at 2:40
• The bug has been fixed and although the boxes don't get grayed out, I've confirmed that your answer works. – Garrett Feb 18 '14 at 1:57
• That screenshot is from an old version of Blender (2.78 or older) – dr. Sybren Sep 20 '17 at 21:55

There is a preset for "AVI Raw" which is lossless, when a video format is selected you have some options within the Encoding panel. When H.264 is selected for Format you get a Lossless output option, when avi, quicktime, ogg or matroska are selected for Format you have several Codec options - of which PNG should be lossless. For audio, FLAC and PCM would appear to be the lossless options.

Normally to keep video in a lossless quality an image sequence is used, PNG, TIFF and OpenEXR are common formats used. If the audio length matches the entire video then it is easy to align both to the same start frame when adding to a new blend file. Once added they can be merged a a meta strip to keep them together.

• Garrett asked for Audio+Video, AVI Raw does not output any audio. – CodeManX Feb 15 '14 at 14:30

The best quality option for lossless video output with audio would be HuffYUV or H.264 w/ Lossless Output mentioned previously.

Filesize with H.264 lossless output is dramatically smaller than HuffYUV. I'm not sure exactly how lossless it really is. Use PCM or FLAC to preserve audio quality.

I've gotten DNxHD to work in the past by using values from this table of supported resolutions. Blender fails to encode unless a compatible set of values is used. Albeit lossy, DNxHD is a pretty nice compression format for size/quality ratio.

Depending on your needs and preferences, it might be a good idea to render animations to lossless image sequences (e.g. PNG, OpenEXR, or TIFF, etc.). That way, you can tweak small portions of your animation or stop and resume rendering at a later time, without needing to re-render the whole sequence.

• Lossless means lossless, doesn't it? h264 lossless coding – CodeManX Apr 23 '14 at 19:42
• There may be some loss in precision during conversion from RGB to YUV, H.264's native colorspace. It may not be visually significant however, and the space savings may be well worth it. I like to use H.264 lossless for final output, and HuffYUV for portions that go into VSE or other NLE. – mantlepro Apr 25 '14 at 5:19

I render with perceptually lossless and then I use FFmpeg to compress it later. FFmpeg reduces the bitrate and the size(myvideo: 7.9GB to 1.7GB) without effecting the original quality. Of course, you will need to install it here.

ffmpeg -i input.mp4 -vcodec libx265 -crf 20 output.mp4