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. |
21st March 2016, 03:40 | #1 | Link |
Scared of Iguanas
Join Date: Aug 2006
Posts: 32
|
FFMPEG - copying metadata
I'm probably missing something simple, but here goes!
I have hundreds of .MKV files with the following streams: - video - audio 1 (DTS) - audio 2 (AAC) - subtitle 1 - subtitle 2 I'm trying to replace the DTS track in each of these with a newly created AC3 (which I've mastered in another program) using FFMPEG to mux. So the new file looks like: - video - audio 1 (new AC3) - audio 2 (AAC) - subtitle 1 - subtitle 2 How do I correctly map the metadata from the original file to the new one? If I use -map_metadata 0, the video, subtitle and audio 2 tracks have the correct metadata in the new file but the metadata from the original audio 1 (DTS) isn't copied over to the new audio 1 (AC3). But if I manually map the metadata from the original audio 1 to the new audio 1, the metadata from the other tracks isn't carried across. I can't find a way to combine the two - if that makes sense! I would just do a manual -map_metadata for each stream, but I'm looking to do this in a batch file and some of the .mkvs have less than 2 subtitle streams (and FFMPEG balks if I try to map metadata to a stream that doesn't exist). Any ideas? Last edited by buffyangel108; 21st March 2016 at 03:54. |
22nd March 2016, 17:32 | #2 | Link |
Scared of Iguanas
Join Date: Aug 2006
Posts: 32
|
Just to update this: I've found a solution, albeit a long-winded one.
I've amended the batch file to first run ffprobe on the original MKV file, parse the language of audio1 (DTS) to a variable, then apply it using -metadata to the new file (which doesn't disable -map_metadata for the other tracks). So the other tracks (video, audio2 and subs) in the new file have the metadata copied from the original file (using -map_metadata 0) and the new audio1 (AC3) track gets it metadata set from the ffprobe data. Probably horribly inefficient, but it works! |
27th March 2016, 10:21 | #4 | Link |
Registered User
Join Date: Oct 2011
Posts: 204
|
No idea if that will actually work, but how about
Code:
ffmpeg -i video.mkv -i audio.ac3 -map_metadata 0 -map_metadata:a:0 0:a:0 out.mkv It first carries over all the metadata from input file 0 (video.mkv) to the output file. Then, it maps the metadata from input file 0, audio stream 0 to the output file's audio stream 0. Reference |
12th April 2016, 15:29 | #5 | Link | |
Scared of Iguanas
Join Date: Aug 2006
Posts: 32
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|