TUTORIAL 6 – VIDEO CODING WITH FFMPEG
Objectives:
1. To consolidate your video coding and compression knowledge and practice skill;
2. To learn how to encode video with the well-known open-source tool FFMPEG;
3. To assess video quality
Preparation:
At home you are asked to:
1. Download a raw yuv video from https://hlevkin.com/hlevkin/14testvideos.htm
2. Install FFMPEG and codecs:
$sudo apt update
$sudo apt install ffmpeg libx264-dev libx265-dev
I. Encoding video
Issue the following command to encode the raw video into H264:
$ffmpeg -f rawvideo -pix_fmt yuv420p -s 352x288 -r 30 -i foreman.yuv -c:v libx264 -crf 28 -preset
slow output_avc.mp4
For H265:
II. Assessing video quality
The quality can be measured by estimating PSNR and SSIM. For the former, issue the command:
$ ffmpeg -video_size 352x288 -i foreman.yuv -i foreman.mp4 -lavfi psnr=stats_file=psnr_logfile.txt -f
null -
Similarly, to measure SSIM, type:
$ ffmpeg -video_size 352x288 -i foreman.yuv -i foreman.mp4 -lavfi ssim=stats_file=ssim_logfile.txt -f
null -
The text files respectively hold measurement statistics.
III. Compiling FFMPEG
FFMPEG is an open-source project, you may download and compile it from
https://ffmpeg.org/download.html#get-sources