4

To add two audio tracks into sample.mp4 (without any audio track):

ffmpeg \
-i sample.mp4 \
-i chi.mp3 \
-i eng.mp3 \
-c:v copy \
-map 0:v \
-map 1:a \
-map 2:a \
-metadata:s:a:0 title="chinese"  \
-metadata:s:a:1 title="english"  \
-metadata:s:a:0 language="chi"   \
-metadata:s:a:1 language="eng"  \
-y \
video_with_multi_audio.mp4

Show all the streams in video_with_multi_audio.mp4:

ffprobe -i  video_with_multi_audio.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_with_multi_audio.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.27.100
  Duration: 00:00:28.03, start: 0.000000, bitrate: 1118 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 1280x720, 879 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
    Metadata:
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 libx264
  Stream #0:1[0x2](chi): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 121 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 124 kb/s
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

I want to add two subtitles chi.ass, eng.ass into video_with_multi_audio.mp4.

My try:

ffmpeg -i video_with_multi_audio.mp4  \
       -i chi.ass \
       -i eng.ass \
       -map 0:v:0 \
       -map 1:s:0 \
       -map 2:s:1 \
       -c copy -c:s ass \
       -metadata:s:s:0 language=chi -metadata:s:s:1 language=eng \
       video_sub.mp4

Error info:

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

To add ? :

ffmpeg -i video_with_multi_audio.mp4  \
       -i chi.ass \
       -i eng.ass \
       -map 0:v:0 \
       -map 0:s:0? \
       -map 0:s:1? \
       -c copy -c:s ass \
       -metadata:s:s:0 language=chi -metadata:s:s:1 language=eng \
       video_sub.mp4

No error info ,and no audio tracks and subtitles in the video_sub.mp4.The ffmpeg command can't work.
How can add multiple ass file as soft multiple subtitles with ffmpeg?

No error info for the command:

ffmpeg -i video_with_multi_audio.mp4  \
       -i chi.ass \
       -i eng.ass \
       -map 0:v:0 \
       -map 0:s:0? \
       -map 0:s:1? \
       -metadata:s:s:0 language=chi \
       -metadata:s:s:1 language=eng \
       -c:s copy video.mkv

The video.mkv contains no audio track and no subtitle!

3
  • Is the output required to be MP4? From what I remember, MP4 containers can't have ASS/SSA-format subtitles at all (only a simple MP4-specific format). Would suggest muxing to .mkv instead. Commented Jun 17, 2025 at 5:57
  • No use to output it as video_sub.mkv. Commented Jun 17, 2025 at 6:03
  • Don't you mean ".liquid_ass"? Commented Jun 17, 2025 at 15:29

2 Answers 2

3

As far as I know, you cannot put SSA/ASS format subtitles in MP4 – the format only supports its own specific "MPEG-4 Timed Text" subtitle format (without any fancy formatting). FFmpeg can convert to that format:

-c:s mov_text

If you want to preserve ASS, you should instead generate a Matroska (.mkv) file:

-c:s copy video_out.mkv

More commonly mkvmerge or mkvtoolnix-gui are used for this.

1
  • Still can't work!The output file contains no audio track and subtitle ! Commented Jun 17, 2025 at 6:11
1

Solved.

ffmpeg \
    -i video_with_multi_audio.mp4\
    -i chi.ass \
    -i eng.ass \
    -map 0:v -c copy \
    -map 0:a -c copy \
    -map 1:s \
    -map 2:s \
    -c:s copy  video.mkv

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.