Image sequence into Matroska/FFV1

Problem

Transcode an image sequence into an FFV1 file wrapped in a Matroska container.

Solution

ffmpeg                        \
-f image2                     \
-framerate 24                 \
-i input_file_%06d.extension  \
-c:v ffv1                     \
-level 3                      \
-threads 8                    \
-coder 1                      \
-context 1                    \
-g 1                          \
-slices 24                    \
-slicecrc 1                   \
-c:a copy                     \
output_file.mkv

General command

ffmpeg                         \
-f image2                      \
-framerate frames_per_second   \
-i input_file_regex.extension  \
-c:v ffv1                      \
-level 3                       \
-threads nb_threads            \
-coder 1                       \
-context 1                     \
-g 1                           \
-slices nb_slices              \
-slicecrc 1                    \
-c:a copy                      \
output_file

Command syntax

ffmpeg
starts the command
-f image2
forces the image file de-muxer for single image files
-framerate frames_per_second
sets the frame rate
-i input_file_regex.extension
path, name with regex and extension of the input files
-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 the available CPU and/or GPU cores you want to use.
-coder 1
The Range coder is selected.
-context 1
The large context is selected.
-g 1
The GOP-size 1 is selected for archival use.
-slices nb_slices
Valid values include 4, 6, 9, 12, 16, 24 and 30.1 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 errors 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
path, name and extension of the output file

Discussion

The parameters witch apply to the input files must precede them. Therefore the option -f image2 must precede the image sequence given as input.

The frame rate of sound film is 24 fps (frames per second) and the default frame rate of image2 is 25 fps, therefore we have to change it.

The regex %06d matches six digits long numbers, possibly with leading zeroes. This allows to read in ascending order, one image after the other, the full sequence inside one folder. The command must of course match the naming convention actually used. And for image sequences starting at 086400 (captured at 24 fps with a timecode starting at 01:00:00:00) or at 090000 (captured at 25 fps with a timecode starting at 01:00:00:00), add the flag -start_number 86400 or -start_number 90000 before -i input_file_%06d.ext.

The extension for TIFF files is .tif or maybe .tiff; the extension for DPX files is .dpx (or eventually .cin for old Cineon files). Other file formats are possible.

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

We advise to use only the version 3 of FFV1 in production, because versions 0 and 1 are deprecated, the version 2 has never really existed, and the version 4 is currently under development.

 

A Bash script allowing to perform this transcoding is included in our collection Bash Script for Audiovisual Preservation.


Note

1

As of FFmpeg 8.0, the following values ​​are valid:

   4    6    8    9   12   15   16   18   20   24   25   28   30   32   35   36
  40   42   45   48   49   50   54   56   60   63   64   66   70   72   77   80
  81   84   88   90   91   96   98   99  100  104  108  110  112  117  120  121
 126  128  130  132  135  140  143  144  150  153  154  156  160  162  165  168
 169  170  176  180  182  187  190  192  195  196  198  200  204  208  209  210
 216  220  221  224  225  228  231  234  238  240  242  247  252  255  256  260
 264  266  270  272  273  276  280  285  286  288  289  294  299  300  304  306
 308  312  315  320  322  323  324  325  330  336  338  340  342  345  350  352 
 357  360  361  364  368  374  375  378  380  384  390  391  392  396  399  400
 405  408  414  416  418  420  425  432  435  437  440  441  442  448  450  456
 459  460  462  464  468  475  476  480  483  484  486  493  494  496  500  504
 506  510  512  513  520  522  525  527  528  529  532  540  544  546  550  551
 552  558  560  561  567  570  572  575  576  578  580  588  589  594  598  600
 608  609  612  616  620  621  624  625  627  630  638  640  644  646  648  650
 651  660  665  667  672  675  676  680  682  684  690  693  696  700  702  703
 704  713  714  720  722  725  726  728  729  735  736  740  744  748  750  754
 756  759  760  768  770  775  777  780  782  783  784  792  798  800  805  806
 810  812  814  816  819  825  828  832  836  837  840  841  850  851  858  861
 864  868  870  874  875  880  882  884  888  891  896  897  899  900  902  910
 912  918  920  924  925  928  930  936  943  945  946  950  952  957  960  961
 962  966  968  972  975  980  984  986  988  989  990  992  999 1000 1008 1012
1014 1015 1020 1023 1024

For older versions of FFmpeg, the following values ​​are valid:

   4    6    9   12   15   16   20   24   25   28   30   35   36   40   42   45
  48   49   54   56   60   63   64   66   70   72   77   80   81   84   88   90
  91   96   99  100  104  108  110  112  117  120  121  126  130  132  135  140
 143  144  150  153  154  156  160  165  168  169  170  176  180  182  187  190
 192  195  196  198  204  208  209  210  216  220  221  224  225  228  231  234
 238  240  247  252  255  256  260  264  266  270  272  273  276  280  285  286
 288  289  294  299  300  304  306  308  312  315  320  322  323  324  325  330
 336  340  342  345  350  352  357  360  361  364  368  374  375  378  380  384
 390  391  396  399  400  405  408  414  416  418  420  425  432  435  437  440
 441  442  448  450  456  459  460  462  464  468  475  476  480  483  484  486
 493  494  496  500  504  506  510  513  520  522  525  527  528  529  532  540
 544  546  550  551  552  558  560  561  567  570  572  575  576  580  588  589
 594  598  600  608  609  612  616  620  621  624  625  627  630  638  640  644
 646  648  650  651  660  665  667  672  675  676  680  682  684  690  693  696
 700  702  703  704  713  714  720  725  726  728  729  735  736  740  744  748
 750  754  756  759  760  768  770  775  777  780  782  783  784  792  798  800
 805  806  810  812  814  816  819  825  828  832  836  837  840  841  850  851
 858  861  864  868  870  874  875  880  884  888  891  896  897  899  900  902
 910  912  918  920  924  925  928  930  936  943  945  946  950  952  957  960
 961  962  966  972  975  980  984  986  988  989  990  992  999 1000 1008 1012
1014 1015 1020 1023

2026-11-14