3

I use ffmpeg to convert existing movies to H.265 format to reduce their occupied size in HDD. They're encoded mostly in H.264. For this, I use the following command:

ffmpeg -i 1.mkv -c:v libx265 -c:a libmp3lame -b:a 128k -c:s mov_text -map 0 1.mp4

The same for other files. But it's not enough to keep streams descriptive names. The metadata for subtitles, video, and audio streams in input files include their languages (eng, English for example), but they're missing in the output file. For example, ffmpeg outputs the info of the input audio stream as:

Stream #0:1(eng): Audio: ...

And I see "Track 1 - [English]" when playing it with VLC in the list of audio tracks, but it outputs the info of the output audio stream as:

Stream #0:1(und): Audio: ...

And VLC just mentions it as "Track 1". I know that I may add the missing metadata to the output file in some way like this:

ffmpeg -i 1.mp4 -c copy -metadata:s:a:0 language=eng -metadata:s:a:0 handler="English" ...

To re-include them, but why they should be lost to add them later again? I need to improve the first command not to omit them and include them in the output file, 1.mp4.

What I'm missing in the first command?

4
  • Try adding -map_metadata 0 to your original command. Sep 11, 2020 at 16:01
  • 1
    Are you sure it'll resolve the problem? A problem is that I'm not sure when it happens. As a sample, I just tried a small video file and even without using -map_metadata 0 it produced an output which includes the original metadata. It's weird! So what happens that I see some converted videos with 'und' streams?!
    – hamidi
    Sep 11, 2020 at 16:13
  • “Are you sure it'll resolve the problem?” Sometimes the best solution is the one that works without knowing the underlying issue. Meaning, why this happens in your case is unclear. But the general advice is to use -map_metadata 0 so I would go with that. Sep 11, 2020 at 16:34
  • 1
    Ok, Thanks. I hope it'll always work properly. Before getting sure about it, I marked your answer as the solution and I hope it'll be so.
    – hamidi
    Sep 11, 2020 at 17:10

1 Answer 1

1

Try adding -map_metadata 0 to your original command like this:

ffmpeg -i 1.mkv -c:v libx265 -c:a libmp3lame -b:a 128k -c:s mov_text -map 0 `-map_metadata 0 1.mp4

Also, it seems like in some cases you should use -movflags use_metadata_tags. More details can be found in this answer here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .