Pensieve

Transcoding a video for LBRY before uploading

Section: Re-encoding & Transcoding

The built-in video transcoding function in the LBRY desktop application starts the FFMPEG utility process with the following parameters:

ffmpeg -i "$(path_to_original_file).ext" -y -c:s copy -c:d copy \ -c:v libx264 -crf 24 -preset faster -pix_fmt yuv420p \ -vf "scale=if(gte(iw\,ih)\,min(1920\,iw)\,-2):if(lt(iw\,ih)\,min(1920\,ih)\,-2)" \ -maxrate 5500K -bufsize 5000K -movflags +faststart \ -c:a aac -b:a 160k "$(path_to_original_file)_fixed.mp4"

The meanings of the passed parameters:

An alternative option for transcoding a horizontal video with increased bitrate and quality and better compression:

ffmpeg -i "$(path_to_original_file).ext" -y -c:s copy -c:d copy \ -c:v libx264 -crf 17 -preset slower -pix_fmt yuv420p \ -maxrate 8M -bufsize 8M -movflags +faststart \ -c:a aac -b:a 160k "$(path_to_original_file) (Transcoded).mp4"

One may select optimal CRF values by performing tests on a sample of the target file with a faster preset. The average bitrate of the transcoded test file should be close (on the left side) to the target bitrate. The CRF value of 17 is sufficient to produce a video with indistinguishable quality (using a slow preset). Note that with a fixed CRF value, the target bitrate may not always be reached, and the encoder will use more bits if necessary.

A sample can be cut from the source file like this:

ffmpeg -i input.ext -ss 00:01:00 -to 00:02:00 -c copy sample.ext

References: