Зазоры в аудио при передаче потока rtsp в rtmp с помощью ffmpeg - PullRequest
1 голос
/ 13 апреля 2020

I pu sh поток выглядит так:

% ffmpeg -rtsp_transport tcp -i "rtsp://**********************" -codec copy -f flv rtmp://x.rtmp.youtube.com/live2/****************

ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.101 / 58. 55.101
  libavformat    58. 31.104 / 58. 31.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.101 /  7. 58.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, rtsp, from 'rtsp:*************************':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720, 12 fps, 25 tbr, 90k tbn, 24 tbc
    Stream #0:1: Audio: aac (LC), 32000 Hz, mono, fltp
Output #0, flv, to 'rtmp://x.rtmp.youtube.com/live2/********************':
  Metadata:
    title           : Media Server
    encoder         : Lavf58.31.104
    Stream #0:0: Video: h264 (Main) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 1280x720, q=2-31, 12 fps, 25 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, mono, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 120; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 200; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 320; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 400; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 480; changing to 557. This may result in incorrect timestamps in the output file.
frame=    7 fps=0.0 q=-1.0 size=      74kB time=00:00:00.56 bitrate=1079.1kbits/s speed=1.06x    
frame=   25 fps= 19 q=-1.0 size=     188kB time=00:00:02.08 bitrate= 741.5kbits/s speed=1.61x    
frame=   49 fps= 22 q=-1.0 size=     330kB time=00:00:04.08 bitrate= 661.9kbits/s speed=1.83x    
frame=   67 fps= 25 q=-1.0 size=     392kB time=00:00:05.66 bitrate= 567.3kbits/s speed=2.07x    
frame=   72 fps= 22 q=-1.0 size=     410kB time=00:00:06.06 bitrate= 553.9kbits/s speed=1.84x    
frame=   76 fps= 20 q=-1.0 size=     488kB time=00:00:06.38 bitrate= 626.5kbits/s speed=1.67x    
frame=   86 fps= 20 q=-1.0 size=     519kB time=00:00:07.26 bitrate= 585.5kbits/s speed=1.68x    
frame=   92 fps= 19 q=-1.0 size=     538kB time=00:00:07.74 bitrate= 569.5kbits/s speed= 1.6x    
frame=   97 fps= 17 q=-1.0 size=     618kB time=00:00:08.11 bitrate= 623.8kbits/s speed=1.45x    
frame=  108 fps= 18 q=-1.0 size=     658kB time=00:00:09.02 bitrate= 597.6kbits/s speed=1.48x    
frame=  114 fps= 17 q=-1.0 size=     679kB time=00:00:09.50 bitrate= 585.3kbits/s speed=1.44x    
frame=  120 fps= 17 q=-1.0 size=     698kB time=00:00:10.02 bitrate= 570.5kbits/s speed=1.41x    
frame=  121 fps= 16 q=-1.0 size=     764kB time=00:00:10.09 bitrate= 619.8kbits/s speed=1.32x    
frame=  132 fps= 16 q=-1.0 size=     802kB time=00:00:11.01 bitrate= 596.7kbits/s speed=1.35x    
frame=  138 fps= 16 q=-1.0 size=     820kB time=00:00:11.57 bitrate= 580.6kbits/s speed=1.34x    
frame=  144 fps= 16 q=-1.0 size=     841kB time=00:00:12.05 bitrate= 571.5kbits/s speed=1.32x    
frame=  149 fps= 15 q=-1.0 size=     923kB time=00:00:12.45 bitrate= 606.8kbits/s speed=1.29x    
frame=  157 fps= 15 q=-1.0 size=     949kB time=00:00:13.13 bitrate= 592.0kbits/s speed=1.28x    
frame=  163 fps= 15 q=-1.0 size=     969kB time=00:00:13.65 bitrate= 581.3kbits/s speed=1.27x    
frame=  169 fps= 15 q=-1.0 size=    1051kB time=00:00:14.09 bitrate= 610.9kbits/s speed=1.22x    
frame=  180 fps= 15 q=-1.0 size=    1091kB time=00:00:15.05 bitrate= 593.6kbits/s speed=1.24x    
frame=  187 fps= 15 q=-1.0 size=    1113kB time=00:00:15.61 bitrate= 583.8kbits/s speed=1.23x    
frame=  192 fps= 15 q=-1.0 size=    1130kB time=00:00:16.05 bitrate= 576.7kbits/s speed=1.21x    
frame=  197 fps= 14 q=-1.0 size=    1212kB time=00:00:16.45 bitrate= 603.2kbits/s speed= 1.2x    
frame=  206 fps= 14 q=-1.0 size=    1241kB time=00:00:17.17 bitrate= 592.1kbits/s speed= 1.2x    
frame=  213 fps= 14 q=-1.0 size=    1265kB time=00:00:17.77 bitrate= 582.8kbits/s speed= 1.2x    
frame=  217 fps= 14 q=-1.0 size=    1340kB time=00:00:18.09 bitrate= 606.6kbits/s speed=1.16x    
frame=  228 fps= 14 q=-1.0 size=    1380kB time=00:00:19.05 bitrate= 593.4kbits/s speed=1.18x    
frame=  234 fps= 14 q=-1.0 size=    1399kB time=00:00:19.57 bitrate= 585.6kbits/s speed=1.17x    
frame=  240 fps= 14 q=-1.0 size=    1418kB time=00:00:20.05 bitrate= 579.4kbits/s speed=1.16x    
[flv @ 000000000310d540] Failed to update header with correct duration.
[flv @ 000000000310d540] Failed to update header with correct filesize.
frame=  241 fps= 14 q=-1.0 Lsize=    1486kB time=00:00:20.05 bitrate= 606.8kbits/s speed=1.14x    
video:1317kB audio:153kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.058846%
Exiting normally, received signal 2.

При просмотре на YouTube аудиопоток искажается, т. Е. Имеет регулярные промежутки в 7 мс между каждыми 32 мс звуковыми частями.

Однако , когда я сохраняю входной поток в файл, звук в порядке. Я экспериментировал с различными вариантами ввода / вывода для ffmpeg, включая транскодирование аудиопотока, но ничего не помогло решить проблему. Я думаю, что здесь виноват ffmpeg, поскольку VL C или другие потоковые сервисы, такие как angelcam et c, могут воспроизводить поток rtsp без каких-либо искажений.

...