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)
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityI 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.
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.
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.
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.
https://www.ffmpeg.org/download.html
And here's the command to compress it.
ffmpeg -i input.mp4 -vcodec libx265 -crf 20 output.mp4