Video into Matroska/FFV1

Problem

Transcode a video file using the FFV1 codec into the Matroska container for preservation purposes.

Solution

ffmpeg \
    -i input_file \
    -c:v ffv1 \
    -level 3 \
    -coder 1 \
    -context 1 \
    -g 1 \
    -slices 24 \
    -slicecrc 1 \
    -c:a copy \
    output_file.mkv

General command

ffmpeg \
    -i input_file \
    -c:v ffv1 \
    -level 3 \
    -threads nb_threads \
    -coder 1 \
    -context 1 \
    -g 1 \
    -slices 24 \
    -slicecrc 1 \
    -c:a copy \
    output_file.mkv

General commands using 2-pass mode

ffmpeg \
    -i input_file \
    -c:v ffv1 \
    -level 3 \
    -pass 1 \
    -passlogfile my_passlogfile \
    -f nut /dev/null \
    -an

ffmpeg \
    -i input_file \
    -c:v ffv1 \
    -level 3 \
    -pass 2 \
    -passlogfile my_passlogfile \
    -c:a copy \
    output_file.mkv

Command syntax

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-c:v ffv1
The video codec FFV1 is selected.
-level 3
The version 3 of FFV1 is selected.
-threads nb_threads
This positive integer gives the number of threads to use while processing. Adjust this to match how many of your available CPU cores you want to use.
-coder 1
-context 1
-g 1
The GOP-size 1 is selected for archival use.
-slices nb_slices
Valid values are 4, 6, 9, 12, 16, 24 or 30. Each frame is split into this number of slices. This affects multithreating performance, as well as filesize: increasing the number of slices may speed up performance, but also increases the filesize.
-slicecrc switch
0 = off, 1 = on. Enabling this option adds CRC information to each slice. This makes it possible for a decoder to detect errore in the bitstream, rather than blindly decoding a broken slice.
-c:a copy
re-encodes the audio stream using the same audio codec
output_file.mkv
path, name and extension of the output file

Discussion

We advise to use only the version 3 of FFV1: the version 1 is deprecated, the version 2 has never really existed, and the version 4 is under development.

The command line works for every input video format, regardless of the container in which the input data are actually wrapped.

The video codec is specified by -codec:video, which may be abbreviated as -c:v (or -codec:v or -c:video). We advise to avoid the alias -vcodec.

The audio codec is specified by -codec:a, which may be abbreviated as -c:a. We advise to avoid the alias -acodec. For silent videos you can replace -c:a copy by -an; for video with sound you may choose to re-encode with another audio codec (e.g. -c:a pcm_s16le is a current choice, but -c:a flac may be the best one).

The extension for the Matroska container is .mkv.


2018–05–21