3

I have a bunch of movies in avi format on my disk. However, they don't contain any metadata like title etc.

I found a command which would do it for me :

ffmpeg -i input.avi -metadata title="Moonshine" -metadata author="Moonshine" -metadata copyright="2009" -metadata comment="foo" -acodec copy -vcodec copy output.avi

This works fine BUT it will only copy ONE audio track. My files contain more than one audio track. I want ffmpeg to copy everything and just give the file a title.

Also, is there any way to give the audio tracks a language name? For example a file contains 2 audio tracks. The first one is English and the second one is Russian. How do I name them correctly so when I use a video player it would show me in the language menu that the first one is English and the second one is Russian?

5

stream selection

Default stream selection behavior is to select one stream type per input. For example, as in your input, if it contains two audio streams, then only the stream with the most number of channels will be selected.

You can tell ffmpeg to include all streams with the -map option.

Because the -map option begins counting at 0, the 0 in this example refers to the first input (input.avi: your only input in this case). If you had additional inputs then -map 1 would refer to the second input.

set language metadata

To set the language of the first and second audio streams use the -metadata option with stream specifiers:

ffmpeg -i input.avi -map 0 -codec copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=rus output.avi

See the documentation for more info.

  • I think avi doesn't support much if any per-stream metadata (other than the necessary technical stuff). -metadata:s:a:0 language=eng didn't do anything. (byte-identical output with/without, muxing from an input avi to an output avi, where mplayer listed the language as "unknown" in the input.) I already suspected this, so this command was very helpful to verify that avi doesn't do track names / language metadata. – Peter Cordes Jan 27 '15 at 8:40
  • update, actually the Avi-Mux GUI manual alexander-noe.com/video/amg/en_main_window.html talks about naming streams in AVI. Maybe just not supported by ffmpeg? – Peter Cordes Jan 27 '15 at 17:45
0

Use like this for AVI files

 -map 0 -acodec copy -metadata:s:a:0  title="English" -metadata:s:a:1 title="Hindi"

The title keyword does the trick

  • Can you expand - how does this answer the question? – suspectus Aug 17 '15 at 15:29
  • 1
    Also it is convention to add the whole command line including the command. When you do it is good practise to explain each parameter as @suspectus alludes to – albal Aug 17 '15 at 18:53
0

Took quite a long time for me to figure this out. I'm posting it here, because even after 3 years this thread is one of the first hits in google search: AVI (more specific: RIFF) does support language names but in opposite to mkv, the metadata is not stored in the stream but in the header using tags IAS1-9 for up to 9 different audio streams.

ffmpeg -i input.avi -map 0 -codec copy -metadata IAS1=eng -metadata IAS2=ger output.avi

VLC ist pretty tolerant. If you enter ISO code "ger", VLC translates it to "Deutsch", if you enter "MyLang" instead, VLC displays "MyLang". Other software like Kodi needs the the correct ISO code. It would read "MyL" only and then display the language as unknown.

However, please be aware that ffmpeg does not just add the language but also changes other metadata. For example, audio interleave and preload data are different in output.avi, no idea if this is good or might result in audio out of sync. Check with MediaInfo or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.