[FFmpeg-devel] [PATCH] AVI metadata retrieval improvements

Michael Niedermayer michaelni at gmx.at
Fri Mar 21 15:30:26 CET 2014

On Thu, Mar 20, 2014 at 11:12:27PM +0100, Thilo Borgmann wrote:
> Am 04.03.14 17:16, schrieb gregory.wolfe at kodakalaris.com:
> > This is the second of two changes I've made as part of our upgrade to
> > the latest FFmpeg development branch.
> > 
> > This patch enhances two aspects of metadata retrieval from AVI files.
> > I've attached before/after command line output from ffmpeg for each
> > modification.  Test video files that can be used to generate the
> > before/after output have been uploaded to the FFmpeg FTP server.
> > 
> > 
> > Patched file:  libavformat/avidec.c
> > Description (from commit message):
> > 
> > Added function avi_extract_stream_metadata().  Some cameras (e.g., Fuji)
> > store stream metadata following the "strd" stream data tag.  Currently,
> > avi_read_header() calls ff_get_extradata() to read and save this data in
> > the codec's "extradata" slot.  This new function extracts metadata from
> > "extradata" by first looking for the AVIF tag, then extracting metadata
> > from the EXIF tags which follow it.
> I've rewritten almost everything to use existing EXIF functions.
> Patch attached, but there are 2 issues I need advise for:
> a) Current EXIF is in lavc only and relies on lavc/tiff.h and lavc/bytestream,
> so these have to be moved (to lavu)?

using just a header with macros/inline functions is fine
using ff_* functions from other libs is not as ff_ is not exported
using avpriv_* functions in lavf from lavc is ok but the ABI/API
of such functions is then part of the libavcodec ABI/API, non public
but still, so care has to be taken with future changes to these
functions so their ABI/API isnt broken

> b) I can't see anything about the endianess in AVI files. How to determine or is
> it always little-endian?

the avi fileformat itself is always LE, ive no idea though about the
content of various chunks, i guess  either
autodetect if its trivial or
assume its always LE if all files we have are LE

> > In a separate change, some cameras (e.g., Casio) store the date format as
> > yyyy/mm/dd/ hh:mm.  Added code to get rid of the "/" following "dd".
> I don't think this is a good idea for FFmpeg to change the metadata. Should be
> done by the interpreting application, IMHO.

>      int64_t frame_offset;   /* current frame (video) or byte (audio) counter
> @@ -379,6 +382,44 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
>      }
>  }
> +static int avi_extract_stream_metadata(AVStream *st)
> +{
> +    GetByteContext gb;
> +    uint8_t *data = st->codec->extradata;
> +    int data_size = st->codec->extradata_size;
> +    int tag, offset, le = 1;
> +
> +    if ((data == 0) || (data_size < 8)) {

data == NULL or !data
teh () arent needed

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140321/5192a97f/attachment.asc>

More information about the ffmpeg-devel mailing list