Video preparation#
In our paper, we find that compressing and downsampling videos can significantly increase processing speed and save compute resources and time.
For a quick one-line example:
ffmpeg -i mouse.avi -vcodec libx264 -vf scale=720x480 mouse.mp4
Video Compression and Rescaling with FFmpeg#
FFmpeg is a potent tool for video processing, offering capabilities for compression and rescaling. This guide presents the process of compressing and rescaling videos using FFmpeg.
Installing FFmpeg#
conda create --name annolid-env
conda activate annolid-env
conda install -c conda-forge ffmpeg
Verify FFmpeg installation#
ffmpeg -version
Compressing a Video#
Reduce file size while maintaining quality
ffmpeg -i input.mp4 -c:v libx264 -crf 18 output.mp4
Reduce file size and quality
ffmpeg -i input.mp4 -c:v libx264 -b:v 500k output.mp4
Rescaling a Video#
Resize to a specific resolution
ffmpeg -i input.mp4 -filter:v scale=w=1280:h=720 output.mp4
Resize to a specific aspect ratio
ffmpeg -i input.mp4 -filter:v scale=w=1280:h=-1 output.mp4
Compress Videos with Annolid GUI#
The GUI version is a better fit when you need to process a folder of videos, apply the same defaults to most files, and keep a few file-specific exceptions.
Click
File -> Downsample Videos.Select the folder containing your original videos.
Open the
Input / Outputtab and set an output folder to save all the processed videos.If you leave it blank, Annolid uses a sibling folder with
_downsampledappended to the input folder name.
Open the
Processingtab and set folder defaults:For example, selecting
0.5will reduce the size of the video by half.Leave FPS blank unless you need a fixed frame rate.
Enable crop only if the same crop applies to every video.
If one or more videos need different settings, click
Review Videos One by One (Folder Input)and useSave & Nextfor exceptions orSkipto keep the defaults.Open the
Runtab.Check the
Rescale Videocheckbox.Click the
Run Processingbutton.
This workflow compresses and downsamples the selected folder while keeping per-video changes explicit and reproducible.
Additional Tips#
Utilize the
-presetoption to adjust encoding speed, for example-preset fast.Specify the audio codec with
-c:a, for example-c:a aac.Set the audio bitrate using
-b:a, for example-b:a 128k.If you need a deeper walkthrough for folder workflows, see the dedicated downsampling guide in the documentation.