Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th July 2025, 18:28   #1  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
Adding metadata from file into MP4 with ffmpeg

To add metadata from a pre-edited file (or from an export from another file), ffmpeg supports an FFMETADATA file format. This is mainly documented to add chapters to MP4 files.

It should also support adding general, global meta tags, like a file comment and a movie title, despite an existing separate command line parameter.

If I am not completely wrong,

Code:
-meta comment="This is my movie comment" -meta title="This is the movie title"
should be equivalent to:

Code:
-i movie.ffmetadata -map_metadata 1
movie.ffmetadata
Code:
;FFMETADATA1
comment=This is my movie comment
title=This is the movie title
I already used the metadata file successfully to add chapters to an MP4 file, like this:

Code:
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/1000
START=0
END=10010
title=My first chapter
[CHAPTER]
TIMEBASE=1/1000
START=10010
END=19186
title=My second chapter
But if I merge both into the same metadata file, the chapters are added but the global tags get lost.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 6th July 2025 at 07:30.
LigH is offline   Reply With Quote
Old 6th July 2025, 05:26   #2  |  Link
Kurt.noise
Registered User
 
Join Date: Nov 2022
Location: Aix en Provence, France
Posts: 163
Did you try something like that ?


PHP Code:
;FFMETADATA1
title
=My Awesome Movie
comment
=This is a global comment about the movie.
genre=Documentary

[CHAPTER]
TIMEBASE=1/1000
START
=0
END
=60000
title
=Introduction


[CHAPTER]
TIMEBASE=1/1000
START
=60000
END
=120000
title
=Chapter 1


[CHAPTER]
TIMEBASE=1/1000
START
=120000
END
=180000
title
=Chapter 2 
Kurt.noise is offline   Reply With Quote
Old 6th July 2025, 05:34   #3  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 954
I think you've already put pressure on the creators. There is some correction, but it doesn't add much.
https://github.com/FFmpeg/FFmpeg/com...038675fd0f5711
You should not use ffmetadata because there are errors.
I also don't know what the message in MediaInfo means
Error Detection Type : Per level 1
Metadata information in ffmpeg is treated modestly. Each container has different metadata and I don't even know if there are limits to the size of info in comments. What about track title information? There isn't. Each track or metadata can have a separate title without the possibility of opening links. In matroska containers, comment titles can be multilingual.
Jamaika is offline   Reply With Quote
Old 6th July 2025, 06:43   #4  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
@Kurt.noise: Exactly like this. Just fewer empty lines in between. Chapters were generated by chapterEditor 1.45, general tags added manually.

@Jamaika: I did not mention it to the ffmpeg issue tracker yet. And I need the preparation of a file to be able to use the same call in a batch for different movies.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 6th July 2025, 07:14   #5  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 954
If you're going to add error information, ask why double chapter menus are created for mp4.
ffmpeg_avx2.exe -i 111.hevc -i 111.aac -i 111.txt -map_metadata 1 -c copy 111.mp4
Code:
Menu #1
ID                                       : 3
Codec ID                                 : text
Duration                                 : 25 min 5 s
Language                                 : English
Menu For                                 : 1,2
XX:XX:XX.XXX                             :xxxx
...
Bit rate mode                            : VBR

Menu #2
XX:XX:XX.XXX                             :xxxx
...

Last edited by Jamaika; 6th July 2025 at 07:18.
Jamaika is offline   Reply With Quote
Old 7th July 2025, 17:21   #6  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
ffmpeg ticket #11660 created.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 12th July 2025, 19:54   #7  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
I will use MP4Box instead; it supports chapters and tags in UTF-8 text files while multiplexing.

MP4Box -add video.m4v -add audio.m4a -chap chapters.ogm.txt -itags tags.ini.txt movie.mp4

Chapters in OGM Chapters format (CHAPTER01=HH:MM:SS.XXX\nCHAPTER01NAME=Name), iTunes compatible tags in name=value pairs (similar to Windows INI)

@Jamaika: And it inserts the chapters only once.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 12th July 2025 at 20:02.
LigH is offline   Reply With Quote
Old 14th July 2025, 16:42   #8  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Location: Between my two ears
Posts: 957
-map_metadata 2
Z2697 is offline   Reply With Quote
Old 14th July 2025, 16:48   #9  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
And why? Where can I find verbose documentation about this ultra-secret magic parameter?
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 14th July 2025, 19:59   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,409
any good,

https://superuser.com/questions/9962...ile-to-another

More results from SuperUser.com
Code:
ffmpeg "-map_metadata" site:superuser.com
https://www.google.com/search?q=ffmp...Asuperuser.com

EDIT:
https://ffmpeg.org/ffmpeg.html#Advanced-options
About 75% down the page. [EDIT: about 1 or two screens past where above link enters]
Quote:
-map_metadata[:metadata_spec_out] infile[:metadata_spec_in] (output,per-metadata)

Set metadata information of the next output file from infile. Note that those are file indices (zero-based), not filenames. Optional metadata_spec_in/out parameters specify, which metadata to copy. A metadata specifier can have the following forms:

g

global metadata, i.e. metadata that applies to the whole file
s[:stream_spec]

per-stream metadata. stream_spec is a stream specifier as described in the Stream specifiers chapter. In an input metadata specifier, the first matching stream is copied from. In an output metadata specifier, all matching streams are copied to.
c:chapter_index

per-chapter metadata. chapter_index is the zero-based chapter index.
program_index

per-program metadata. program_index is the zero-based program index.

If metadata specifier is omitted, it defaults to global.

By default, global metadata is copied from the first input file, per-stream and per-chapter metadata is copied along with streams/chapters. These default mappings are disabled by creating any mapping of the relevant type. A negative file index can be used to create a dummy mapping that just disables automatic copying.

For example to copy metadata from the first stream of the input file to global metadata of the output file:

ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3

To do the reverse, i.e. copy global metadata to all audio streams:

ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv

Note that simple 0 would work as well in this example, since global metadata is assumed by default.
EDIT: copy metadata using exiftool
https://stackoverflow.com/questions/...adata-copy-all

EDIT:
Code:
ffmpeg "-map_metadata" site:stackoverflow.com
https://www.google.com/search?q=ffmp...t=gws-wiz-serp
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 14th July 2025 at 20:26.
StainlessS is online now   Reply With Quote
Old 15th July 2025, 09:46   #11  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,439
I did find the chapter in the official ffmpeg documentation. And I see no explanation of the meaning of a "1" or "2" there.

In other articles, which are no official documentation I hoped for, I even read about the existence of a "-1". So, apparently, third-party talks about that topic are the only reliable reference...
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.