使用 ffmpeg 将屏幕和麦克风直播到 azure 媒体服务
Live stream the screen and microphone to azure media services with ffmpeg
我可以使用 ffmpeg 将我的屏幕视频流式传输到 Azure 媒体服务,但是当我添加音频输入时,流停止并出现此错误:
ffmpeg: frame= 27 fps=0.0 q=0.0 size= 0kB time=00:00:00.36 bitrate= 8.4kbits/s dup=0 drop=7 speed=0.703x
ffmpeg: frame= 43 fps= 42 q=0.0 size= 0kB time=00:00:00.36 bitrate= 8.4kbits/s dup=0 drop=7 speed=0.356x
ffmpeg: frame= 58 fps= 38 q=27.0 size= 37kB time=00:00:00.36 bitrate= 818.6kbits/s dup=0 drop=7 speed=0.24x
ffmpeg: av_interleaved_write_frame(): End of file
ffmpeg: Last message repeated 1 times
ffmpeg: [flv @ 0633fec0] Failed to update header with correct duration.
ffmpeg: [flv @ 0633fec0] Failed to update header with correct filesize.
ffmpeg: Error writing trailer of rtmp://rtmpurl/stream: End of file
ffmpeg: frame= 59 fps= 32 q=26.0 Lsize= 37kB time=00:00:00.39 bitrate= 764.5kbits/s dup=0 drop=7 speed=0.214x
ffmpeg: video:35kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffmpeg: [libx264 @ 0633c6c0] frame I:1 Avg QP:18.27 size: 30491
ffmpeg: [libx264 @ 0633c6c0] frame P:16 Avg QP:20.68 size: 4210
ffmpeg: [libx264 @ 0633c6c0] frame B:42 Avg QP:23.25 size: 152
ffmpeg: [libx264 @ 0633c6c0] consecutive B-frames: 5.1% 0.0% 0.0% 94.9%
ffmpeg: [libx264 @ 0633c6c0] mb I I16..4: 12.7% 36.9% 50.4%
Ffmpeg Exited
ffmpeg: [libx264 @ 0633c6c0] mb P I16..4: 0.4% 1.0% 0.6% P16..4: 45.6% 10.5% 12.1% 0.0% 0.0% skip:29.8%
ffmpeg: [libx264 @ 0633c6c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 15.5% 0.3% 0.0% direct: 0.3% skip:83.9% L0:46.5% L1:51.0% BI: 2.5%
ffmpeg: [libx264 @ 0633c6c0] 8x8 transform intra:41.1% inter:59.1%
ffmpeg: [libx264 @ 0633c6c0] coded y,uvDC,uvAC intra: 79.9% 96.5% 88.6% inter: 7.8% 15.8% 5.4%
ffmpeg: [libx264 @ 0633c6c0] i16 v,h,dc,p: 20% 13% 6% 61%
ffmpeg: [libx264 @ 0633c6c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 21% 22% 4% 4% 5% 3% 3% 8%
ffmpeg: [libx264 @ 0633c6c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 16% 10% 5% 7% 7% 5% 6% 6%
ffmpeg: [libx264 @ 0633c6c0] i8c dc,h,v,p: 54% 18% 23% 5%
ffmpeg: [libx264 @ 0633c6c0] Weighted P-Frames: Y:0.0% UV:0.0%
ffmpeg: [libx264 @ 0633c6c0] ref P L0: 55.1% 2.9% 29.5% 12.6%
ffmpeg: [libx264 @ 0633c6c0] ref B L0: 79.5% 14.0% 6.6%
ffmpeg: [libx264 @ 0633c6c0] ref B L1: 93.2% 6.8%
ffmpeg: [libx264 @ 0633c6c0] kb/s:333.49
ffmpeg: Conversion failed!
我的 ffmpeg 命令是:
-f dshow -i audio="Microphone device" -strict -2 -c:a aac -f gdigrab -framerate 30 -offset_x 161 -offset_y 203 -video_size 430x322 -show_region 1 -i title="Window Title" -b:v 415K -g 60 -keyint_min 60 -b:a 32K -ar 22050 -filter:a "volume=0.8" -pix_fmt yuv420p -c:v libx264 -preset medium -bufsize 400k -maxrate 400k -f flv rtmp://rtmpurl/stream
我终于找到了解决办法。我不知道为什么,但如果我将视频输入放在音频输入之前,效果很好。
这是我的固定命令,它仍然不完美,但它有效:
-f gdigrab -framerate 30 -offset_x 161 -offset_y 203 -video_size 430x322 -show_region 1 -i title="Window Title" -f dshow -i audio="Microphone Device" -strict -2 -c:a aac -b:v 415K -g 60 -keyint_min 60 -b:a 32K -ar 22050 -filter:a "volume=0.6499733" -pix_fmt yuv420p -c:v libx264 -preset medium -bufsize 4000k -maxrate 4000k -f flv -flvflags no_duration_filesize rtmp://rtmpurl/stream
我可以使用 ffmpeg 将我的屏幕视频流式传输到 Azure 媒体服务,但是当我添加音频输入时,流停止并出现此错误:
ffmpeg: frame= 27 fps=0.0 q=0.0 size= 0kB time=00:00:00.36 bitrate= 8.4kbits/s dup=0 drop=7 speed=0.703x
ffmpeg: frame= 43 fps= 42 q=0.0 size= 0kB time=00:00:00.36 bitrate= 8.4kbits/s dup=0 drop=7 speed=0.356x
ffmpeg: frame= 58 fps= 38 q=27.0 size= 37kB time=00:00:00.36 bitrate= 818.6kbits/s dup=0 drop=7 speed=0.24x
ffmpeg: av_interleaved_write_frame(): End of file
ffmpeg: Last message repeated 1 times
ffmpeg: [flv @ 0633fec0] Failed to update header with correct duration.
ffmpeg: [flv @ 0633fec0] Failed to update header with correct filesize.
ffmpeg: Error writing trailer of rtmp://rtmpurl/stream: End of file
ffmpeg: frame= 59 fps= 32 q=26.0 Lsize= 37kB time=00:00:00.39 bitrate= 764.5kbits/s dup=0 drop=7 speed=0.214x
ffmpeg: video:35kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffmpeg: [libx264 @ 0633c6c0] frame I:1 Avg QP:18.27 size: 30491
ffmpeg: [libx264 @ 0633c6c0] frame P:16 Avg QP:20.68 size: 4210
ffmpeg: [libx264 @ 0633c6c0] frame B:42 Avg QP:23.25 size: 152
ffmpeg: [libx264 @ 0633c6c0] consecutive B-frames: 5.1% 0.0% 0.0% 94.9%
ffmpeg: [libx264 @ 0633c6c0] mb I I16..4: 12.7% 36.9% 50.4%
Ffmpeg Exited
ffmpeg: [libx264 @ 0633c6c0] mb P I16..4: 0.4% 1.0% 0.6% P16..4: 45.6% 10.5% 12.1% 0.0% 0.0% skip:29.8%
ffmpeg: [libx264 @ 0633c6c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 15.5% 0.3% 0.0% direct: 0.3% skip:83.9% L0:46.5% L1:51.0% BI: 2.5%
ffmpeg: [libx264 @ 0633c6c0] 8x8 transform intra:41.1% inter:59.1%
ffmpeg: [libx264 @ 0633c6c0] coded y,uvDC,uvAC intra: 79.9% 96.5% 88.6% inter: 7.8% 15.8% 5.4%
ffmpeg: [libx264 @ 0633c6c0] i16 v,h,dc,p: 20% 13% 6% 61%
ffmpeg: [libx264 @ 0633c6c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 21% 22% 4% 4% 5% 3% 3% 8%
ffmpeg: [libx264 @ 0633c6c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 16% 10% 5% 7% 7% 5% 6% 6%
ffmpeg: [libx264 @ 0633c6c0] i8c dc,h,v,p: 54% 18% 23% 5%
ffmpeg: [libx264 @ 0633c6c0] Weighted P-Frames: Y:0.0% UV:0.0%
ffmpeg: [libx264 @ 0633c6c0] ref P L0: 55.1% 2.9% 29.5% 12.6%
ffmpeg: [libx264 @ 0633c6c0] ref B L0: 79.5% 14.0% 6.6%
ffmpeg: [libx264 @ 0633c6c0] ref B L1: 93.2% 6.8%
ffmpeg: [libx264 @ 0633c6c0] kb/s:333.49
ffmpeg: Conversion failed!
我的 ffmpeg 命令是:
-f dshow -i audio="Microphone device" -strict -2 -c:a aac -f gdigrab -framerate 30 -offset_x 161 -offset_y 203 -video_size 430x322 -show_region 1 -i title="Window Title" -b:v 415K -g 60 -keyint_min 60 -b:a 32K -ar 22050 -filter:a "volume=0.8" -pix_fmt yuv420p -c:v libx264 -preset medium -bufsize 400k -maxrate 400k -f flv rtmp://rtmpurl/stream
我终于找到了解决办法。我不知道为什么,但如果我将视频输入放在音频输入之前,效果很好。 这是我的固定命令,它仍然不完美,但它有效:
-f gdigrab -framerate 30 -offset_x 161 -offset_y 203 -video_size 430x322 -show_region 1 -i title="Window Title" -f dshow -i audio="Microphone Device" -strict -2 -c:a aac -b:v 415K -g 60 -keyint_min 60 -b:a 32K -ar 22050 -filter:a "volume=0.6499733" -pix_fmt yuv420p -c:v libx264 -preset medium -bufsize 4000k -maxrate 4000k -f flv -flvflags no_duration_filesize rtmp://rtmpurl/stream