我有一个视频文件,它有一个视频流、两个音频流和两个字幕流。我想为第二个音频流设置标题和语言,并且只希望将此流传送到输出。
为此我使用以下命令:
ffmpeg -i input.mp4 -map -0:1 -map 0:2 -metadata:s:a:0 title='Test_Title' -metadata:s:a:0 language='eng' -map 0:v:0? -c copy output.mkv
但是 FFmpeg 无法识别该流,尽管它存在。以下是错误消息:
Stream map '0:1' matches no streams.
To ignore this, add a trailing '?' to the map.
当我添加-map 0:a?
命令时,它会复制音频流。
输入文件信息:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:04:49.94, start: 0.000000, bitrate: 1012 kb/s
Chapter #0:0: start 0.000000, end 180.000000
Metadata:
title : Part A
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1365 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
handler_name : SoundHandler
Stream #0:3(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
Stream #0:4(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
Metadata:
handler_name : SubtitleHandler
Stream #0:5(eng): Data: bin_data (text / 0x74786574)
Metadata:
handler_name : SubtitleHandler
我怎样才能仅选择第二个音频流并更新元数据?
答案1
您不需要删除音频流,只需映射您需要的音频流,这对我有用:
ffmpeg -i input.mp4 -map 0:2 -metadata:s:a:0 title='Test_Title' -metadata:s:a:0 language='eng' -map 0:v:0? -c copy output.mkv