Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques ffmpeg to set metadata

  • ffmpeg to set metadata

    Posted by Peter Robertson on February 12, 2013 at 10:00 pm

    I use ffmpeg to set metadata on some of my video clips during conversion. Is there a way to set the metadata of a video without sending it to an output. Occasionally I don’t want to convert a clip but just change the metadata. I know there are probably other apps out there that will allow you to write video metadata but I’d like to use ffmpeg if possible.

    Perhaps there is a way to make a DUPLICATE of a clip and write the metadata to the duplicate clip?

    Thanks.

    Pedro

    Pedro

    Peter Robertson replied 13 years, 3 months ago 4 Members · 9 Replies
  • 9 Replies
  • Reuben Martin

    February 13, 2013 at 12:09 am

    This entirely depends on what format you are trying to change the metadata on.

  • Jim Sustacek

    February 13, 2013 at 1:36 pm

    I don’t think you can do it — I’ve never seen ffmpeg update/write a file in-place.

    I often use MP4Box (and mp4track) for metadata updates instead.

    Otherwise, for ffmpeg, I always use two commands: the first to write to a temp file, then the second to copy it back to the original:
    ffmpeg -i original.mp4 -metadata title="my title" -c copy -y /tmp/tmp.mp4 && ffmpeg -i /tmp/tmp.mp4 -c copy -y original.mp4
    If you do it a lot, you could wrap it all in a nice script too.

  • Lou Logan

    February 13, 2013 at 9:08 pm

    [Jim Sustacek] ffmpeg -i original.mp4 -metadata title="my title" -c copy -y /tmp/tmp.mp4 && ffmpeg -i /tmp/tmp.mp4 -c copy -y original.mp4

    Consider adding “-map 0”. By default ffmpeg will choose to copy only the “best” streams but not automatically choose all streams when using “-c copy”. From the documentation:

    Stream selection
    By default ffmpeg includes only one stream of each type (video, audio, subtitle) present in the input files and adds them to each output file. It picks the “best” of each based upon the following criteria; for video it is the stream with the highest resolution, for audio the stream with the most channels, for subtitle it’s the first subtitle stream. In the case where several streams of the same type rate equally, the lowest numbered stream is chosen.

    This doesn’t matter for an input that only has one stream per stream type (video, audio, subtitle, etc), but adding “-map 0” will ensure that all streams from the (first) input will be copied if your input contains multiple tracks per stream type (such as one video stream and two audio streams).

  • Jim Sustacek

    February 14, 2013 at 8:21 pm

    Thanks for the “-map 0” tip, I will keep that in mind!

  • Peter Robertson

    February 20, 2013 at 6:43 pm

    That works great except I can’t seem to be able to set the description

    -metadata description=”Some info”

    Either that or I can’t seem to be able to view it using Exiftool.

    Any suggestions?

    Thanks.

    Pedro

  • Lou Logan

    February 21, 2013 at 7:52 pm

    [Peter Robertson] “Any suggestions?”

    Please show your full ffmpeg command and the complete console output.

  • Peter Robertson

    February 26, 2013 at 3:47 pm

    These are the commands that I am using:

    ffmpeg -i MTStest.mp4 -metadata title=”66115-title of clip” -metadata author=”authors name” -metadata description=”some description” -c copy -y /tmp/tmp.mov && ffmpeg -i /tmp/tmp.mov -c copy -y MTStest.mp4

    And this is the output from the command line:

    ffmpeg version N-49695-g4e2c636 Copyright (c) 2000-2013 the FFmpeg developers
    built on Feb 7 2013 13:15:40 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
    configuration: –enable-libx264 –enable-gpl –enable-shared
    libavutil 52. 17.101 / 52. 17.101
    libavcodec 54. 91.102 / 54. 91.102
    libavformat 54. 61.104 / 54. 61.104
    libavdevice 54. 3.103 / 54. 3.103
    libavfilter 3. 35.101 / 3. 35.101
    libswscale 2. 2.100 / 2. 2.100
    libswresample 0. 17.102 / 0. 17.102
    libpostproc 52. 2.100 / 52. 2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘MTStest.mp4’:
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    title : 66115-title of clip
    artist : authors name
    encoder : Lavf54.61.104
    copyright : Peter Robertson
    Duration: 00:28:38.76, start: 0.000000, bitrate: 1150 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280×720 [SAR 1:1 DAR 16:9], 1013 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata:
    handler_name : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
    handler_name : SoundHandler
    Output #0, mov, to ‘/tmp/tmp.mov’:
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    copyright : Peter Robertson
    artist : authors name
    description : some description
    title : 66115-title of clip
    author : authors name
    encoder : Lavf54.61.104
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 1280×720 [SAR 1:1 DAR 16:9], q=2-31, 1013 kb/s, 29.97 fps, 30k tbn, 30k tbc
    Metadata:
    handler_name : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 128 kb/s
    Metadata:
    handler_name : SoundHandler
    Stream mapping:
    Stream #0:0 -> #0:0 (copy)
    Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 9236 fps=0.0 q=-1.0 size= 42138kB time=00:05:08.09 bitrate=1120.4kbits/frame=18903 fps=18440 q=-1.0 size= 90115kB time=00:10:30.65 bitrate=1170.6kbitframe=26939 fps=17348 q=-1.0 size= 131077kB time=00:14:58.81 bitrate=1194.7kbitframe=37062 fps=18054 q=-1.0 size= 176522kB time=00:20:36.58 bitrate=1169.4kbitframe=47064 fps=18436 q=-1.0 size= 220154kB time=00:26:10.32 bitrate=1148.5kbitframe=51510 fps=18353 q=-1.0 Lsize= 241301kB time=00:28:38.74 bitrate=1150.1kbits/s
    video:212533kB audio:26920kB subtitle:0 global headers:0kB muxing overhead 0.771552%
    ffmpeg version N-49695-g4e2c636 Copyright (c) 2000-2013 the FFmpeg developers
    built on Feb 7 2013 13:15:40 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
    configuration: –enable-libx264 –enable-gpl –enable-shared
    libavutil 52. 17.101 / 52. 17.101
    libavcodec 54. 91.102 / 54. 91.102
    libavformat 54. 61.104 / 54. 61.104
    libavdevice 54. 3.103 / 54. 3.103
    libavfilter 3. 35.101 / 3. 35.101
    libswscale 2. 2.100 / 2. 2.100
    libswresample 0. 17.102 / 0. 17.102
    libpostproc 52. 2.100 / 52. 2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘/tmp/tmp.mov’:
    Metadata:
    major_brand : qt
    minor_version : 512
    compatible_brands: qt
    title : 66115-title of clip
    artist : authors name
    encoder : Lavf54.61.104
    copyright : Peter Robertson
    Duration: 00:28:38.76, start: 0.000000, bitrate: 1150 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280×720 [SAR 1:1 DAR 16:9], 1013 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata:
    handler_name : DataHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
    handler_name : DataHandler
    Output #0, mp4, to ‘MTStest.mp4’:
    Metadata:
    major_brand : qt
    minor_version : 512
    compatible_brands: qt
    title : 66115-title of clip
    artist : authors name
    copyright : Peter Robertson
    encoder : Lavf54.61.104
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280×720 [SAR 1:1 DAR 16:9], q=2-31, 1013 kb/s, 29.97 fps, 30k tbn, 30k tbc
    Metadata:
    handler_name : DataHandler
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 128 kb/s
    Metadata:
    handler_name : DataHandler
    Stream mapping:
    Stream #0:0 -> #0:0 (copy)
    Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame=10163 fps=0.0 q=-1.0 size= 46411kB time=00:05:39.05 bitrate=1121.4kbits/frame=18903 fps=18860 q=-1.0 size= 90115kB time=00:10:30.65 bitrate=1170.6kbitframe=28765 fps=18706 q=-1.0 size= 139265kB time=00:15:59.76 bitrate=1188.7kbitframe=39383 fps=19327 q=-1.0 size= 186811kB time=00:21:54.02 bitrate=1164.6kbitframe=48629 fps=19162 q=-1.0 size= 226937kB time=00:27:02.54 bitrate=1145.8kbitframe=51510 fps=19060 q=-1.0 Lsize= 241301kB time=00:28:38.74 bitrate=1150.1kbits/s
    video:212533kB audio:26920kB subtitle:0 global headers:0kB muxing overhead 0.771520%

    The “description : some description” is not being written to the file. The others are.

    Thanks.

    Peter

    Pedro

  • Lou Logan

    February 26, 2013 at 7:33 pm

    ffmpeg does not seem to support description for mov container, but it seems to work fine with mp4 container. I’m not sure if this is supported officially by mov or if it is simply a missing feature in ffmpeg. Why are you using mov as the output container and then re-muxing to mp4? Why not simply output to mp4?

    Also, placing your commands and console output in the CODE tags will make it easier to read and differentiate it from your comments.

  • Peter Robertson

    February 26, 2013 at 9:01 pm

    THANKS! I feel a little silly–I did not realize I forgot to change the extension of the tmp file from .mov to .mp4.

    Pedro

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy