Read metadata with FFmpeg


I have an Anafi Ai and I must use ffmpeg in my project to read the Anafi Video in MP4 and RTSP.

I use ffmpeg 4.2.2 and with the ffprobe exe I have this output:

ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b33583c1c0] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'workspace/ProjetLinux/FDR-DRONE/Data/AACU_0000682.MP4':
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomiso2
    creation_time   : 2022-04-15T14:34:21.000000Z
    model           : ANAFI Ai
    artist          : ANAFI Ai 001354
    title           : Fri, 15 Apr 2022 16:40:34 +0200
    date            : 2022-04-15T16:40:34+02:00
    make            : Parrot
    encoder         : PI040452AA2A001354 ANAFI Ai 001354 Fri, 15 Apr 2022 16:40:34 +0200 2022-04-15T16:40:34+02:00 Parrot ANAFI Ai 7.1.0 091a
    com.parrot.serial: PI040452AA2A001354 anafi2-classic-7.1.0 A1FFF510E300EF1A2CADAD9CB20880BA 7AF02F7819A9167A59F245FA21D167F3 front standard user
    com.parrot.dynamic.range: sdr
    com.parrot.tone.mapping: standard
  Duration: 00:06:22.85, start: 0.000000, bitrate: 102208 kb/s
    Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 102043 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
      creation_time   : 2022-04-15T14:34:21.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng): Data: none (mett / 0x7474656D), 56 kb/s (default)
      creation_time   : 2022-04-15T14:34:21.000000Z
      handler_name    : ParrotVideoMetadata
    Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
      creation_time   : 2022-04-15T14:34:21.000000Z
      handler_name    : DefaultAudio
    Stream #0:3: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn, 90k tbc (attached pic)
Unsupported codec with id 0 for input stream 1

I see this message Unsupported codec with id 0 for input stream 1. I think that is normal because it is a Parrot’s message.

I based my code from this topic → Accessing vmeta_frame data arriving in ffmpeg and I write this part:

int ret = av_read_frame( _formatContext, packet );
if(packet->stream_index == 1) // Metadata in Stream 1
    struct vmeta_buffer buf;

    vmeta_buffer_set_cdata(&buf, packet->data, packet->size, 0);

    struct vmeta_frame *meta;
    vmeta_frame_read(&buf, NULL, &meta);
    struct vmeta_location loc;
    vmeta_frame_get_location(meta, &loc);
    printf("location latitude %f longitude %f altitude %f\n", loc.latitude, loc.longitude, loc.altitude);

When I run my code I have this issue:

E vmeta: vmeta_frame_v3: bad id: 0x0a7f (0x5033)
E vmeta: vmeta_frame_get_location:123:  err=22(Invalid argument)
location latitude 0.000000 longitude 0.000000 altitude 0.000000

So I don’t know what is the problem, maybe _formatContext isn’t good configured ?


As stated in the libvideo-metadata header, the mime_type argument must be provided when reading metadata from a MP4 file. (And for live too on Anafi Ai).

The ideal way to do this is to get the MIME-type from the video file itself, but if you’re only interested in Anafi Ai, you can use the VMETA_FRAME_PROTO_MIME_TYPE constant, which is the type that this model uses both for recording and streaming.


It works, thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.