我使用 Raspberry 3 将 rtsp 相机传输到 youtube。但是 youtube 流中没有音频...
ffmpeg -thread_queue_size 512 -re -f lavfi -i anullsrc -rtsp_transport udp \
-thread_queue_size 512k -i rtsp://admin:@192.168.1.31:554/0/av0 \
-framerate 13 -bufsize 4096k -b:v 2000k -threads 4 \
-q:v 3 -c:v h264_omx -bf 2 -r 25 -strict experimental -c:a aac \
-f flv rtmp://a.rtmp.youtube.com/live2/XXXX-XXX
rtsp 流中有一些音频,我可以用 vlc 听到。我认为 ffmpeg 可以解码和编码音频输入。以下是该命令的结果
ffmpeg version git-2020-03-29-72be5d4 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --enable-gpl --enable-nonfree --enable-mmal --enable-libfreetype --enable-omx --enable-omx-rpi
libavutil 56. 42.102 / 56. 42.102
libavcodec 58. 77.101 / 58. 77.101
libavformat 58. 42.100 / 58. 42.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.101 / 7. 77.101
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, lavfi, from 'anullsrc':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
[udp @ 0x28e8d50] attempted to set receive buffer to size 393216 but it only ended up set as 327680
[udp @ 0x28f8fe0] attempted to set receive buffer to size 393216 but it only ended up set as 327680
[udp @ 0x2909aa0] attempted to set receive buffer to size 393216 but it only ended up set as 327680
[udp @ 0x2919de0] attempted to set receive buffer to size 393216 but it only ended up set as 327680
Guessed Channel Layout for Input Stream #1.1 : mono
Input #1, rtsp, from 'rtsp://admin:@192.168.1.31:554/0/av0':
Metadata:
title : h264.mp4
comment : TAS-Tech Live Cast
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #1:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 11.92 fps, 12.50 tbr, 90k tbn, 23.75 tbc
Stream #1:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (h264 (native) -> h264 (h264_omx))
Stream #0:0 -> #0:1 (pcm_u8 (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_omx @ 0x29406a0] Using OMX.broadcom.video_encode
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/XXX-XXX-XXX':
Metadata:
encoder : Lavf58.42.100
Stream #0:0: Video: h264 (h264_omx) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1920x1080, q=2-31, 2000 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc58.77.101 h264_omx
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.77.101 aac
frame= 4968 fps= 12 q=-0.0 size= 52911kB time=00:06:58.64 bitrate=1035.4kbits/s dup=0 drop=5 speed= 1x
我可以改变什么来获得音频?
谢谢
答案1
我从网上复制了 ffmpeg,但我并没有理解所有内容!我只需要删除
-f lavfi -i anullsrc
答案2
您告诉它使用 anullsrc 过滤器生成的静音音频,而不是来自主输入的音频。使用:
ffmpeg -thread_queue_size 512k -rtsp_transport udp -i rtsp://admin:@192.168.1.31:554/0/av0 -bufsize 4096k -b:v 2000k -c:v h264_omx -bf 2 -r 25 -c:a aac -f flv rtmp://a.rtmp.youtube.com/live2/XXXX-XXX
不相关的更改:
-b:v
和-q:v
是互斥的。只能使用一个。我不熟悉 h264_omx,但我不知道它是否支持-q:v
或忽略它。- 如果要更改输出帧速率,请使用选项
-r
或fps 过滤器,而不是-framerate
选项。该-framerate
选项是某些解复用器使用的输入选项。 -strict experimental
过去需要对 AAC 音频进行编码,但这在 2015 年发生了变化,因此将其删除。-maxrate
流式传输时应添加该选项。