'Adding srt to mkv doesnt work if a file has an image attached

I'm trying to add an srt subtitle to an mkv file, but it doesn't work as expected, unless I omit the stream with poster image.

The command I originally used:

ffmpeg -i 1.mkv -i 2.srt -map 0 -map 1 -c copy 3.mkv

For 1.mkv the streams are:

0:0 video
0:1 audio 1
0:2 audio 2
0:3 srt subtitle
0:4: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 353x500, 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      filename        : poster.jpg
      mimetype        : image/jpeg

But what I got was a second subtitle only displaying the very first line, and not showing anything after that.

Omitting poster made things work, and and adding it back later didn't break anything either.

ffmpeg -i 1.mkv -i 2.srt -map 0 -map -0:4 -map 1 -c copy 3.mkv
ffmpeg -i 1.mkv -i 3.mkv -map 1 -map 0:4 -c copy 4.mkv  

So I thought it might be an order thing, but running

ffmpeg -i 1.mkv -i 2.srt -map 0 -map -0:4 -map 1 -map 0:4 -c copy 3.mkv

doesn't work. What's the problem here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source