在FFmpeg中按语言映射流 [英] Mapping streams by language in FFmpeg

查看:175
本文介绍了在FFmpeg中按语言映射流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多具有多种音频和字幕语言的文件,但是音轨编号不一致(英语音频流并不总是第一个),因此请使用以下命令:

I have lots of files with multiple audio and subtitle languages, however the track numbers aren't consistent (the English audio stream isn't always the first) so using a command such as:

ffmpeg -i "input.mkv" -map 0 -map -0:a:1 -c:v copy -c:a copy "output.mkv"

没有产生预期的结果.搜索后,我发现可以使用以下命令根据语言映射流:

doesn't yield expected results. After searching around I discovered it was possible to map streams based on language with this command:

ffmpeg -i "input.mkv" -map 0 -map -0:m:language:eng -c:v copy -c:a copy "output.mkv"

但是-map -0:m:language:eng将删除所有带有英语标记的曲目.要保持字幕轨道,可以使用-map 0:s,这是一个很好的解决方案,但是,我想知道是否可能仅根据语言映射音频流.

However -map -0:m:language:eng will remove all tracks with the English language flag. To keep the subtitle tracks you can use -map 0:s this is a good solution however, I want to know if it's possible to only map audio streams based on language.

推荐答案

已更新据我所知,这是在不使用流ID的情况下保留所有其他流的同时删除英语音频的最佳方法.我发现与语言标志相比更加不一致.通常人们使用正确的语言标记,但是音频语言不太可能保留相同的ID.

Updated As far as I can tell this is the best way to remove English audio while retaining all other streams without using stream IDs which I find to be more inconsistent then language flags. Generally people use correct language flags however audio languages are less likely to keep the same ID.

ffmpeg -i "in.mkv" -map a -map -m:language:eng -map v -map s -map d? -map t -c:v copy -c:a copy "out.mkv"

该命令将映射每个音频流,然后使用English语言标记删除音频.然后它将映射所有视频,字幕和附件流.如果需要,可以添加-disposition:a:0 default为第一个音频流提供[default]标志.注意:仅在删除已经具有默认标志的音频时使用.如果要将默认的音轨设置为默认值,请将-disposition:a:0更改为-disposition:a:1.

The command will map every audio stream then remove audio with the English language flag. It will then map all video, subtitle and attachment streams. You can add -disposition:a:0 default to give the first audio stream the [default] flag if needed. Note: Only use when you are removing audio that has the default flag already. Change -disposition:a:0 to -disposition:a:1 and so on if you want to set a different audio track to default.

这篇关于在FFmpeg中按语言映射流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆