[Libav-user] Add metadata to the container when encoding a video file

Gabriele Greco gabriele.greco at hudl.com
Fri May 21 11:46:06 EEST 2021


I have some problems adding metadata to a mp4 or mov container, not sure if it's a problem in avformat or if I'm doing something wrong.

I'd like to have my metadata at the same level where I see "major_brand", "encoder" and similar stuff with ffprobe.

To check the behaviour, I got the latest ffmpeg head sources and modified the test program:

doc/examples/muxing.c

I simply added the line:

    av_dict_set(&oc->metadata, "testKey", "testValue", 0);

just before av_dump_format (at line 601).

I compiled and run the program (tested both with .mp4 and .mov)

av_dump_format finds the metadata and prints....

[libx264 @ 0x7f8e2d00b600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8e2d00b600] profile High, level 1.3
[libx264 @ 0x7f8e2d00b600] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=12 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
  Metadata:
    testKey         : testValue
    Stream #0:0: Video: h264, yuv420p, 352x288, q=2-31, 400 kb/s, 25 tbn
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 64 kb/s

... but when I probe with ffprobe the final file I get:

../../ffprobe test.mp4
ffprobe version N-102394-g4fda451c9f Copyright (c) 2007-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --disable-lzma --prefix=/usr/local/sdk/darwin-x64 --enable-libx264 --enable-libfdk-aac --enable-nonfree --enable-gpl --enable-libopus --enable-libvpx --enable-libvorbis --enable-pic --disable-sdl2
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  0.100 / 59.  0.100
  libavformat    59.  0.101 / 59.  0.101
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:10.03, start: 0.000000, bitrate: 328 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 352x288, 255 kb/s, 25.10 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 65 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]


.... no trace at all of my metadata!

I'm doing something wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210521/81855813/attachment.htm>


More information about the Libav-user mailing list