[FFmpeg-user] Loss of mp4 metadata when copying

Moritz Barsnick barsnick at gmx.net
Thu Jan 16 09:43:52 EET 2020


On Wed, Jan 15, 2020 at 21:43:47 -0500, Andrew Brezovsky wrote:
> However, ffmpeg seems to be discarding the handler_name field and replacing
> it with a generic "SoundHandler" value.

I can't reproduce, at least not with my command line.

> Here is the command I'm trying to use:
> ffmpeg -i mystery_source.mp4 -map 0 -map_metadata 0 -c copy -metadata:s:a:0
> handler_name="Stereo" mystery.mp4
>
> Here is the output: https://pastebin.com/r8kgt7Ny

Please post that right to the list in future mails.

> ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers

This version is quite old, please try a newer one. You can grab a
static binary for your platform from
https://johnvansickle.com/ffmpeg/
(left column, "git master", please) and retry with that.

Here's my input, my conversion, and its output, just to show it
apparently works, changing stream 0:2's handler_name from "Surround
5.1" to "Stereo":

barsnick at sunshine:/usr/new/tools/video/ffmpeg/ffmpeg-snapshot-2020-01-12 > ffmpeg -i ~/tmp/handler_name.mp4
ffmpeg version N-96334-g1a7f4a1 Copyright (c) 2000-2020 the FFmpeg developers
  built with icc (ICC) 14.0.3 20140422
  configuration: --prefix=/usr/new/tools/video/install/ffmpeg/2020-01-12 --cc=icc --cxx=icpc --enable-gpl --enable-version3 --enable-nonfree --disable-shared --enable-gnu
tls --enable-libcdio --enable-libfreetype --enable-libx264 --enable-libvpx --enable-libmp3lame --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --ena
ble-libtwolame --enable-librtmp --enable-libass --enable-libv4l2 --enable-libvidstab --enable-libfdk-aac --enable-libsmbclient --enable-libzvbi --enable-libtesseract --en
able-libzmq --enable-libopus --enable-libcodec2 --enable-libxml2 --enable-libopencv
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.102 / 58. 35.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 71.100 /  7. 71.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/barsnick/tmp/handler_name.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.35.102
  Duration: 00:00:02.02, start: 0.000000, bitrate: 423 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 270 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Surround 2.0
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s
    Metadata:
      handler_name    : Surround 5.1
At least one output file must be specified
barsnick at sunshine:/usr/new/tools/video/ffmpeg/ffmpeg-snapshot-2020-01-12 > ffmpeg -i ~/tmp/handler_name.mp4 -map 0  -map_metadata 0 -c copy -metadata:s:a:1 handler_name="Stereo" ~/tmp/handler_name.2.mp4
ffmpeg version N-96334-g1a7f4a1 Copyright (c) 2000-2020 the FFmpeg developers
  built with icc (ICC) 14.0.3 20140422
  configuration: --prefix=/usr/new/tools/video/install/ffmpeg/2020-01-12 --cc=icc --cxx=icpc --enable-gpl --enable-version3 --enable-nonfree --disable-shared --enable-gnutls --enable-libcdio --enable-libfreetype --enable-libx264 --enable-libvpx --enable-libmp3lame --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtwolame --enable-librtmp --enable-libass --enable-libv4l2 --enable-libvidstab --enable-libfdk-aac --enable-libsmbclient --enable-libzvbi --enable-libtesseract --enable-libzmq --enable-libopus --enable-libcodec2 --enable-libxml2 --enable-libopencv
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.102 / 58. 35.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 71.100 /  7. 71.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/barsnick/tmp/handler_name.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.35.102
  Duration: 00:00:02.02, start: 0.000000, bitrate: 423 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 270 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Surround 2.0
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s
    Metadata:
      handler_name    : Surround 5.1
File '/home/barsnick/tmp/handler_name.2.mp4' already exists. Overwrite? [y/N] y
Output #0, mp4, to '/home/barsnick/tmp/handler_name.2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.35.102
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 270 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      handler_name    : Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Surround 2.0
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s
    Metadata:
      handler_name    : Stereo
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame=   50 fps=0.0 q=-1.0 Lsize=     104kB time=00:00:01.98 bitrate= 431.2kbits/s speed= 411x
video:66kB audio:34kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.128972%
barsnick at sunshine:/usr/new/tools/video/ffmpeg/ffmpeg-snapshot-2020-01-12 > ffmpeg -i ~/tmp/handler_name.2.mp4
ffmpeg version N-96334-g1a7f4a1 Copyright (c) 2000-2020 the FFmpeg developers
  built with icc (ICC) 14.0.3 20140422
  configuration: --prefix=/usr/new/tools/video/install/ffmpeg/2020-01-12 --cc=icc --cxx=icpc --enable-gpl --enable-version3 --enable-nonfree --disable-shared --enable-gnu
tls --enable-libcdio --enable-libfreetype --enable-libx264 --enable-libvpx --enable-libmp3lame --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --ena
ble-libtwolame --enable-librtmp --enable-libass --enable-libv4l2 --enable-libvidstab --enable-libfdk-aac --enable-libsmbclient --enable-libzvbi --enable-libtesseract --en
able-libzmq --enable-libopus --enable-libcodec2 --enable-libxml2 --enable-libopencv
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.102 / 58. 35.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 71.100 /  7. 71.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/barsnick/tmp/handler_name.2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.35.102
  Duration: 00:00:02.02, start: 0.000000, bitrate: 423 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 270 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Surround 2.0
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s
    Metadata:
      handler_name    : Stereo
At least one output file must be specified

Cheers,
Moritz


More information about the ffmpeg-user mailing list