Folder Structure and Video Conversion

A project log for The Slowest Video Player with 7-Colors!

Watch your favorite films at 1 frame per minute

manuel-tosoneManuel Tosone 03/18/2021 at 15:300 Comments

Folder structure

Hi, everybody. With this log, I want to address how I go about generating the image files to load into the SD card and its folder structure. One of my goals was to be able to load more than one movie at a time. The solution I come up with is to have a folder for each movie in which the frames are stored.

|        |-0000.jpg
|        |-0001.jpg
|        |-0002.jpg
|        |-...
|        |-0000.jpg
|        |-0001.jpg
|        |-0002.jpg
|        |-...

Video conversion

To extract the images from the video file I use a command-line program called ffmpeg. The nice thing about this program is that it has some predefined filter that you can apply in sequence to achieve practically anything you can imagine.

ffmpeg -hwaccel auto -i input_file.mp4 -vf "fps=1,\
    -pix_fmt yuvj420p -q:v 6 %04d.jpg

What the command does is best explained by the following diagram. First, the input file is decoded, then the frame rate is dropped to 1 frame per second. The frames are then scaled and cropped to the display resolution. After that, some color correction is applied before finally saving the images as jpegs. Preprocessing the images by raising the contrast and color saturation makes the images on the display appear more natural and compensates for the display low color count.

JPEG quality test

The ffmpeg program lets you specify how much compression to apply. The -q:v option accepts a parameter in the range 2 to 32, where 2 is the highest quality and 32 is the lowest quality. In the following test, I loaded on the display four images with different quality. The side-by-side comparison shows the compressed image on the left with the capture of the display on the right. It is noted that the quality of the overall picture is quite good even with the highest compression though the fine details are lost. This is particularly noticeable in the fence links that tend to disappear at higher compressions.