0

I have a video file that has one video stream, two audio streams, and two subtitle streams. I want to set title and language for the second audio stream and I want only this stream to get carried to the output.

For this I'm using the following command:

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

But FFmpeg couldn't identify the stream, though it exists. Here is the error message:

Stream map '0:1' matches no streams.
To ignore this, add a trailing '?' to the map.

When I add -map 0:a? in the command it duplicates the audio stream.

Input File Info:

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

How could I select only the second audio stream and update metadata?

1 Answer 1

2

You do not need to remove the audio stream, just map the one you need, this works for me:

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

You must log in to answer this question.

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