2

所以我在传输流 (*.ts) 中混合了 H264 视频 + AAC 音频。为了实现均匀分布的 PCR 值,我在命令中添加了 muxrate 标签。

ffmpeg -analyzeduration 20000000 -probesize 20M -loglevel verbose -i 1135084.m4v -i 1135084.m4a -c copy -muxrate 7982K -map 0:v:0 -map 1:a:0 -metadata:s:a:0 language=eng -metadata:s:a:0 tms_track_id=169451954 TEMP0.ts

由于我们的客户需要 DVB 字幕,我们通过字幕编辑将 SRT 转换为 DVD,然后使用 ffmpeg 使用以下命令将它们编码为 DVB:

ffmpeg -analyzeduration 20000000 -probesize 20M -loglevel verbose -i TEMP0.ts -i out.da.idx -map 0 -c copy -muxrate 7992K -map 1:s -c:s:0 dvbsub -metadata:s:s:0 language=dan TEMP1.ts

这是 ffmpeg 命令的输出:

ffmpeg version git-2019-11-18-d831edc Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191010
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 36.100 / 56. 36.100
  libavcodec     58. 62.100 / 58. 62.100
  libavformat    58. 35.100 / 58. 35.100
  libavdevice    58.  9.101 / 58.  9.101
  libavfilter     7. 66.100 /  7. 66.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[h264 @ 000002bf7460d400] non-existing SPS 0 referenced in buffering period
[h264 @ 000002bf7460d400] SPS unavailable in decode_picture_timing
[h264 @ 000002bf7460d400] non-existing SPS 0 referenced in buffering period
[h264 @ 000002bf7460d400] SPS unavailable in decode_picture_timing
[h264 @ 000002bf7460d400] Reinit context to 1920x1088, pix_fmt: yuv420p
[mpegts @ 000002bf7460ae00] max_analyze_duration 20000000 reached at 20000000 microseconds st:0
[mpegts @ 000002bf7460ae00] start time for stream 2 is not set in estimate_timings_from_pts
Input #0, mpegts, from 'TEMP1.ts':
  Duration: 01:51:54.48, start: 1.440000, bitrate: 7992 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(progressive, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 254 kb/s
    Stream #0:2[0x102](dan): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
[vobsub @ 000002bf75d65940] IDX/SUB: out.fi.idx -> out.fi.sub
Input #1, vobsub, from 'out.fi.idx':
  Duration: N/A, bitrate: N/A
    Stream #1:0[0x0](fi): Subtitle: dvd_subtitle, 1920x1080 (default)
File 'TEMP2.ts' already exists. Overwrite? [y/N] y
[mpegts @ 000002bf74634f00] service 1 using PCR in pid=256, pcr_period=20ms
[mpegts @ 000002bf74634f00] muxrate 8002000, sdt every 500 ms, pat/pmt every 100 ms
Output #0, mpegts, to 'TEMP2.ts':
  Metadata:
    encoder         : Lavf58.35.100
    Stream #0:0: Video: h264 (High), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(progressive, left), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1(eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 254 kb/s
    Stream #0:2(dan): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:3(fin): Subtitle: dvb_subtitle (dvbsub), 1920x1080 (default)
    Metadata:
      encoder         : Lavc58.62.100 dvbsub
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #1:0 -> #0:3 (dvd_subtitle (dvdsub) -> dvb_subtitle (dvbsub))
Press [q] to stop, [?] for help
No more output streams to write to, finishing.me=01:51:46.51 bitrate=7990.2kbits/s speed=18.2x
frame=167862 fps=456 q=-1.0 Lsize= 6558750kB time=01:51:54.47 bitrate=8002.0kbits/s speed=18.2x
video:5738580kB audio:212004kB subtitle:10989kB other streams:0kB global headers:0kB muxing overhead: 10.017118%
Input file #0 (TEMP1.ts):
  Input stream #0:0 (video): 167862 packets read (5876305439 bytes);
  Input stream #0:1 (audio): 314742 packets read (217092443 bytes);
  Input stream #0:2 (subtitle): 1740 packets read (5578504 bytes);
  Total: 484344 packets (6098976386 bytes) demuxed
Input file #1 (out.fi.idx):
  Input stream #1:0 (subtitle): 855 packets read (6881158 bytes); 854 frames decoded;
  Total: 855 packets (6881158 bytes) demuxed
Output file #0 (TEMP2.ts):
  Output stream #0:0 (video): 167862 packets muxed (5876305439 bytes);
  Output stream #0:1 (audio): 314742 packets muxed (217092443 bytes);
  Output stream #0:2 (subtitle): 1740 packets muxed (5578504 bytes);
  Output stream #0:3 (subtitle): 1708 frames encoded; 1708 packets muxed (5673736 bytes);
  Total: 486052 packets (6104650122 bytes) muxed
[AVIOContext @ 000002bf7463c280] Statistics: 0 seeks, 25621 writeouts
[AVIOContext @ 000002bf74613f80] Statistics: 6728300448 bytes read, 2 seeks
[AVIOContext @ 000002bf75efde40] Statistics: 7852032 bytes read, 0 seeks
[AVIOContext @ 000002bf74f30e40] Statistics: 40275 bytes read, 0 seeks

所以我在一个 TS 中有视频/音频和两个 dvb 轨道。

现在我添加了第三个字幕,我收到了这个警告:

frame=32351 fps=869 q=-1.0 size= 1255936kB time=00:21:33.99 bitrate=7951.1kbits/s speed=34.8x
[mpegts @ 0x2994600] Non-monotonous DTS in output stream 0:3; previous: 116868609, current: 116868607; changing to 116868610. This may result in incorrect timestamps in the output file.
frame=33416 fps=886 q=-1.0 size= 1297408kB time=00:22:16.56 bitrate=7952.0kbits/s speed=35.4x

通过这个警告,DVB (0:3) 完成轨道似乎有些不对劲。用 VLC 播放文件我可以看到完成字幕(21:33 到 22:16 之间)没有出现。

从 0:3 轨道转储数据包我看到 4 个数据包具有相同的 DTS/PTS 值。

#stream#, dts,        pts, duration,     size, hash
0,  111258000,  111258000,        0,     6979, 6215f060, S=1,        1, 67d220bc
0,  111689100,  111689100,        0,       25, e60e94fa, S=1,        1, 67d220bc
0,  113230800,  113230800,        0,     4423, f811be62, S=1,        1, 67d220bc
0,  113561550,  113561550,        0,       25, 6db8d81f, S=1,        1, 67d220bc
0,  113788800,  113788800,        0,     8247, 8b494779, S=1,        1, 67d220bc
0,  114191190,  114191190,        0,       25, a205e183, S=1,        1, 67d220bc

0,  116868607,  116868607,        0,     1119, e5d11188, S=1,        1, 67d220bc
0,  116868607,  116868607,        0,       28, 11e09861, S=1,        1, 67d220bc
0,  116868607,  116868607,        0,     1122, 8320a3f5, S=1,        1, 67d220bc
0,  116868607,  116868607,        0,       28, e896fa37, S=1,        1, 67d220bc

0,  117205200,  117205200,        0,     3583, 47b23f27, S=1,        1, 67d220bc
0,  117611640,  117611640,        0,       25, e5ae32ed, S=1,        1, 67d220bc
0,  117709200,  117709200,        0,     1119, 208b4f80, S=1,        1, 67d220bc
0,  117830970,  117830970,        0,       25, 2a130b71, S=1,        1, 67d220bc
0,  117846000,  117846000,        0,     3105, f179a4f0, S=1,        1, 67d220bc
0,  118148040,  118148040,        0,       25, 29b3ad66, S=1,        1, 67d220bc
0,  120146410,  120146410,        0,     1119, 714ef5d1, S=1,        1, 67d220bc
0,  120146410,  120146410,        0,       28, bbad7fed, S=1,        1, 67d220bc
0,  120708000,  120708000,        0,     2060, 703084f7, S=1,        1, 67d220bc
0,  120855420,  120855420,        0,       25, 6db8d81f, S=1,        1, 67d220bc
0,  121122000,  121122000,        0,     2184, 04a7be71, S=1,        1, 67d220bc
0,  121395330,  121395330,        0,       25, a205e183, S=1,        1, 67d220bc

这些是 SRT 文件中发生警告的行:

146
00:21:34,840 --> 00:21:36,600
Make!
147
00:21:42,280 --> 00:21:46,800
Make! Hei, Make. Make!
148
00:21:47,880 --> 00:21:49,240
Make!
149
00:21:49,400 --> 00:21:52,760
Odota minua, Make!
150
00:22:00,400 --> 00:22:01,760
Make!

有时以不同的顺序混合字幕(例如在丹麦语和瑞典语之前完成)可以解决这个问题,但我想知道为什么会发生这样的事情。

4

0 回答 0