ffmpeg字幕按语言叠加

时间:2017-02-15 12:08:30

标签: ffmpeg overlay

我的信息流看起来像这样:

Input #0, mpegts, from 'udp://@...':
  Duration: N/A, start: 19316.897278, bitrate: N/A
  Program 504
    Stream #0:0[0x13b1], 125, 1/90000: Video: mpeg2video (Main), 1 reference frame ([2][0][0][0] / 0x0002), yuv420p(tv, top first, left), 720x576 [SAR 64:45 DAR 16:9], 0/1, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x13b2], 208, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 256 kb/s
    Stream #0:2[0x1541](srp), 4, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:3[0x1542](slv), 3, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:4[0x1543](hrv), 4, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0x1544](cze), 3, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:6[0x1545](hun), 4, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:7[0x1546](ron), 3, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:8[0x1547](alb), 4, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:9[0x1548](bul), 5, 1/90000: Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:10[0x13b9](eng), 127, 1/90000: Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)

我尝试在输出视频中添加英文字幕,但字幕/语言的数量随时间变化。我需要按语言选择所需的字幕。我能怎么做?这是我不成功的例子。谢谢。

ffmpeg -i "udp://@..." -map s:eng -sn -map v:0 -profile:v baseline
-c:v libx264 -b:v 1500k -maxrate 2200k -filter_complex [0:v][0:s]overlay -c:a libfdk_aac -b:a 128k /test.ts

1 个答案:

答案 0 :(得分:1)

尝试

ffmpeg -i "udp://@..." -map 0:v -map 0:a -map 0:m:language:eng -c copy -f mpegts pipe:1 | ffmpeg -f mpegts -i pipe:0 -filter_complex [0:v][0:s]overlay -profile:v baseline -c:v libx264 -b:v 1500k -maxrate 2200k -c:a libfdk_aac -b:a 128k /test.ts