[FFmpeg-devel] [PATCH] FFV1 specification: Add more details about the configuration record

Michael Niedermayer michaelni at gmx.at
Thu May 14 18:57:15 CEST 2015


On Thu, May 14, 2015 at 12:36:53PM +0200, Jerome Martinez wrote:
> Le 14/05/2015 00:48, Michael Niedermayer a écrit :
> >
> >nut and ffm surely work too
> 
> I have doubts there are lot of FFV1 content in such container format ;-)
> 
> Anyway:
> - Patch updated with NUT file format information
> - I tested FFmpeg for the support of FFV1 in FFM (source MOV files
> are there https://github.com/MediaArea/MediaConch/tree/master/SampleTestFiles/FFV1
> )
> 
> ffmpeg -i ffv1_0.mov -vcodec copy ffv1_0.ffm
> ffmpeg -i ffv1_0.ffm -f null /dev/null
> is OK.
> 
> ffmpeg -i ffv1_3.mov -vcodec copy ffv1_3.ffm
> ffmpeg -i ffv1_3.ffm -f null /dev/null
> is NOK
> 
> [ffv1 @ 004F2600] read_quant_table error
> [ffv1 @ 00515AC0] Cannot decode non-keyframe without valid keyframe
> [ffv1 @ 005296A0] Cannot decode non-keyframe without valid keyframe
> [ffv1 @ 00537BC0] Cannot decode non-keyframe without valid keyframe
> [ffv1 @ 004D22A0] Cannot decode non-keyframe without valid keyframe
> [ffv1 @ 004D2700] Cannot decode non-keyframe without valid keyframe
> [ffv1 @ 004D3300] Cannot decode non-keyframe without valid keyframe
> Error while decoding stream #0:0: Invalid data found when processing input
> 
> I looked for the GlobalHeader presence in ffv1_3.ffm (FFM2 format)
> but it is not present (I don't find the 4 bytes of CRC in the file)
> Looks like FFmpeg creates invalid FFV1 version 3 in NUT files
> (frames are OK but the GlobalHeader part is missing) and is not able
> to read such file.
> 
> I don't find any documentation about FFM format specification (I
> just find some reference in
> https://www.ffmpeg.org/ffserver.html#FFM_002c-FFM2-formats ) but it
> looks like FFM supports extra_data (AVFMT_GLOBALHEADER,
> CODEC_FLAG_GLOBAL_HEADER, in avformat/ffm_*.c) and the issue is
> maybe in ffv1enc/ffv1dec:
> I see in ffmenc.c:
>         if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
>             avio_wb32(pb, codec->extradata_size);
>             avio_write(pb, codec->extradata, codec->extradata_size);
>         }
> but ffv1enc.c does not contain any reference to
> CODEC_FLAG_GLOBAL_HEADER as libx264.c / libx265.c / libfaac.c / ...
> do.
> If don't now enough FFmpeg source code for going further in my
> inspection: it is a headache because FFM2 format looks like to rely
> on CODEC_FLAG_GLOBAL_HEADER (which is not part of FFM2, it is in
> FFMpeg source code) for writing extradata_size in the container, but
> extradata may be present or not present depending of the FFV1
> version, and I don't see  how to write that in the code: if I force
> ffv1 for writing extradata_size in FFM file in all cases, I break
> previous FFV1 version 0-1 files, and if I let as is I can not write
> extradata_size in FFM file.
> Someone for helping?
> 
> >
> >
> >>>  It should make it clear that these are not the only containers
> >>>supported but that nearly any container can be used
> >>Agreed.
> >>
> >>Is it OK with:
> >>
> >>"This configuration record can be placed in any file format
> >>supporting configuration records, fitting as much as possible with
> >>how the file format uses to store configuration records. The
> >>configuration record storage place and NumBytes are currently
> >>defined and supported by this specification for the following
> >>container formats:"
> >ok
> 
> Patch updated.

>  ffv1.lyx |  565 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 503 insertions(+), 62 deletions(-)
> 5f035e151808d3ca2f4f125009c1ce6a1f93ecc2  0001-Add-more-details-about-the-configuration-record.patch
> From 4c71831de018cfa5279610cace0183e8db80dcee Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= <jerome at mediaarea.net>
> Date: Thu, 14 May 2015 10:59:48 +0200
> Subject: [PATCH] Add more details about the configuration record
> 
> Version 2+ of the format has a configuration record which is in
> the underlying container track definition.
> GlobalHeader definition is split in 2 parts:
> - a configuration record part, including more details about how to find
> it in AVI and MP4, including the algorithm for how to skip remaining
> bits directly in the bitstream definition, including the crc_parity,
> - the header part itself, which is the prveious GlobalHeader definition
> minus crc_parity.
> crc_parity definition is also split and moved in the right subsections:
> - configuration_record_crc_parity for the configuration record part
> subsection,
> - slice_crc_parity for the slice subsection.
> ---
>  ffv1.lyx | 565 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 503 insertions(+), 62 deletions(-)
> 
> diff --git a/ffv1.lyx b/ffv1.lyx
> index c8bb2b7..41f2015 100644
> --- a/ffv1.lyx
> +++ b/ffv1.lyx
> @@ -893,6 +893,20 @@ Range
>  a...b means any value starting from a to b, inclusive.
>  \end_layout
>  
> +\begin_layout Subsection
> +Bitstream functions
> +\end_layout
> +
> +\begin_layout Description
> +remaing_bits_in_bitstream(
> +\begin_inset space ~
> +\end_inset
> +
> +) means the count of remaining bits after the current position in the bitstream.
> + It is computed from the NumBytes value multiplied by 8 minus the count
> + of bits already read by the bitstream parser.
> +\end_layout
> +
>  \begin_layout Section
>  General Description
>  \end_layout
> @@ -2525,31 +2539,49 @@ The same context which is initialized to 128 is used for all fields in the
>   header.
>  \end_layout
>  
> +\begin_layout Standard
> +Default values at the decoder initialization phase:
> +\end_layout
> +
> +\begin_layout Description
> +ConfigurationRecordIsPresent is set to 0.
> +\end_layout
> +
>  \begin_layout Subsection
> -Frame
> +Configuration Record
> +\end_layout
> +
> +\begin_layout Standard
> +In the case of a bitstream with version >= 2, a configuration record is
> + stored in the the underlying container, at the track header level.
> +\begin_inset Newline newline
> +\end_inset
> +
> +The size of the configuration record, NumBytes, is supplied by the underlying
> + container.
>  \end_layout
>  
>  \begin_layout Standard
>  \begin_inset Tabular
> -<lyxtabular version="3" rows="9" columns="2">
> +<lyxtabular version="3" rows="7" columns="2">
>  <features rotate="0" tabularvalignment="middle">
>  <column alignment="left" valignment="top">
>  <column alignment="center" valignment="top">
>  <row>
> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
> +<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
>  \begin_inset Text
>  
>  \begin_layout Plain Layout
> -Frame( ) {
> +ConfigurationRecord( NumBytes ) {
>  \end_layout
>  
>  \end_inset
>  </cell>
> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
>  \begin_inset Text
>  
>  \begin_layout Plain Layout
> -type
> +
>  \end_layout
>  
>  \end_inset
> @@ -2575,7 +2607,7 @@ type
>  \begin_inset space ~
>  \end_inset
>  
> -keyframe
> +ConfigurationRecordIsPresent = 1
>  \end_layout
>  
>  \end_inset
> @@ -2584,7 +2616,42 @@ keyframe
>  \begin_inset Text
>  
>  \begin_layout Plain Layout
> -br
> +
> +\end_layout
> +
> +\end_inset
> +</cell>
> +</row>
> +<row>
> +<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
> +\begin_inset Text
> +
> +\begin_layout Plain Layout
> +\begin_inset space ~
> +\end_inset
> +
> +
> +\begin_inset space ~
> +\end_inset
> +
> +
> +\begin_inset space ~
> +\end_inset
> +
> +
> +\begin_inset space ~
> +\end_inset
> +
> +GlobalHeader( )
> +\end_layout
> +
> +\end_inset
> +</cell>
> +<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
> +\begin_inset Text
> +
> +\begin_layout Plain Layout
> +
>  \end_layout
>  
>  \end_inset
> @@ -2610,7 +2677,7 @@ br
>  \begin_inset space ~
>  \end_inset
>  
> -if( keyframe ) {

> +while( remaing_bits_in_bitstream( ) > 32)
[...]
> +reserved

the reserved bit is not defined,
This way one could misunderstand it as if it was allowed to add
such bits in the encoder

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150514/e25f545c/attachment.asc>


More information about the ffmpeg-devel mailing list