1
$ ffmpeg -i fa1.m2t -ss 0:02:22 -to 01:34:17 -map 0:1 -map 0:2 -map 0:6? -c:v libx265 -crf 28 -preset ultrafast -c:a aac -b:a 128k -c:s copy fa1.mkv

The streams are:

Input #0, mpegts, from 'fa1.m2t':
  Duration: 01:43:54.32, start: 40328.578578, bitrate: 5611 kb/s
  Program 25 
    Stream #0:0[0x33](fin): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:1[0x13a]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x366](swe): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 448 kb/s
    Stream #0:3[0x369](dut): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 192 kb/s (visual impaired)
    Stream #0:4[0xc38](swe): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0xc4f](swe): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)
File 'fa1.mkv' already exists. Overwrite ? [y/N] y

But the the subtitle stream that I want is #0:6 which starts later...

Output #0, matroska, to 'fa1.mkv':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: hevc (libx265), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.107.100 libx265
    Stream #0:1(swe): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.107.100 aac
[mpegts @ 0x561dd54e9ae0] New subtitle stream 0:6 at pos:100252692 and DTS:40471.3s    
frame=  638 fps= 28 q=-0.0 Lsize=    3587kB time=00:00:25.40 bitrate=1156.9kbits/s speed=1.11x  

So, how can I include this stream #0:6 into the movie? It does not exist in the beginning of the recording.

  • Hi, @arijii, welcome to AskUbuntu, and thank you for asking a question. If the answer below answers your question, please click the check mark "✓" to mark your question as answered. This helps others searching for answers in the future, and gives me some points. :-) Visit askubuntu.com/tour to learn more about the AskUbuntu site. – Jim DeLaHunt Dec 30 '18 at 0:32
1

Use the ffmpeg option -probesize to force ffmpeg to search enough bytes into the input file, and option -analyzeduration to force it to search for enough seconds.

The ffmpeg documentation, 19 Format Options explains the options. Each takes an integer argument, with suffixes like M to indicate millions, and G to indicate billions. The argument to -probesize specifies how many bytes to search (default: 5 million). The argument to -analyzeduration specifies how many microseconds to search (default: 5 million microseconds, or 5 seconds). In both cases, they measure from the start of the input file. The search ends when the earlier of these two arguments expires. Put these options before the -i argument naming the input file.

Your example shows this message about the start of the new stream:

New subtitle stream 0:6 at pos:100252692 and DTS:40471.3s

pos is a byte count. The new stream is at 100,252,692, or just over 100 million. DTS means Decoding Time Stamp (I believe, per an ffmpeg tutorial), and is in seconds. The new stream is at 40,471.3 seconds, compared to a DTS of about 40,328.6 seconds at the start of the video, so the new stream is about 147.7 seconds in.

So, you want to search at least 101 million bytes and 150 million microseconds into the input video. Insert these options before the -i fa1.m2t, giving:

$ ffmpeg -probesize 101M -analyzeduration 150M -i fa1.m2t -ss 0:02:22 -to 01:34:17 -map 0:1 -map 0:2 -map 0:6? -c:v libx265 -crf 28 -preset ultrafast -c:a aac -b:a 128k -c:s copy fa1.mkv

[Note: new command not tested, since I don't have your input file.]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.