After a lot of trial and error, I managed to add multiple subtitle streams to one MP4. However, when checking the metadata of the MP4, I see some results that I want to change, hoping someone can help me or can explain why it happened.
This is the input (original MP4 to which I added subtitle streams)
$ ffmpeg -i movie.mp4
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2048x872 [SAR 1:1 DAR 256:109], 2352 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 440 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
Then, I execute the following command. I gathered this information from different sources and I'm not an FFMPEG guru :)
ffmpeg -i movie.mp4 -f srt -i nl.srt -i mk.srt -i sk.srt \
-map 0:0 -map 0:1 -map 1:0 -map 2:0 -map 3:0 \
-c:v copy -c:a copy \
-c:s mov_text -c:s mov_text -c:s mov_text \
-metadata:s:s:0 language=nld -metadata:s:s:1 language=mkd -metadata:s:s:2 language=skv \
NEW.mp4
In a few seconds, the NEW.mp4 is created and when playing the video I get the video and audio that I expect and 3 subtitle streams that can be switched during playback. The subtitles itself are also what I expect to be.
Output of NEW.mp4
$ ffmpeg -i NEW.mp4
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2048x872 [SAR 1:1 DAR 256:109], 2352 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 440 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(nld): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
Stream #0:3(mkd): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
Metadata:
handler_name : SubtitleHandler
Stream #0:4(svk): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
Metadata:
handler_name : SubtitleHandler
I'm not sure if the type of subtitle is the one I should use -> 'mov_text'. If I use the same command but instead of using 'mov_text', I want to use 'srt' or 'subrip', I get some errors.
[mp4 @ 0x7ba2c0] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x7ba2c0] Codec for stream 1 does not use global headers but container format requires global headers
[mp4 @ 0x7ba2c0] Could not find tag for codec subrip in stream #2, codec not currently supported in container
The only question that remains for me is how can I make it work with 'srt' or 'subrip' ? In the meantime I will look for solutions and when found, I will put it here.