【问题标题】:thread_queue_size during Live Streaming from ffmpegffmpeg 直播期间的 thread_queue_size
【发布时间】:2017-07-24 18:51:47
【问题描述】:

我正在尝试将网络摄像头流从 RaspberryPi-B 流式传输到 Youtube。使用的网络摄像头是罗技 C920。如果我使用来自相机本身的 h264 流,则使用

可以正常工作
ffmpeg -f alsa -i hw:1,0 -f v4l2 -vcodec h264 -video_size 854x480 -r 25 -i /dev/video0 -acodec aac -b:a 64000 -ar 48000 -bufsize 64k -b:v 1200k -bufsize 1024k  -maxrate 1800k -vcodec copy -g 60 -r 30 -f flv
 rtmp://a.rtmp.youtube.com/live2/stream_here

因此,要使其与其他非 h264 相机(如 Pi Cam 或任何其他更便宜的网络摄像头)一起使用,它需要使用原始流并使用 libx264 转换为 h264。这是使用 Pi 的重点。因此是第二个命令集。

ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -i /dev/video0 -framerate 25 -video_size 1280x720  -c:v libx264 -preset veryfast -maxrate 1984k -bufsize 3968k -vf "format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100 -f flv rtmp://a.rtmp.youtube.com/live2/stream_name

所以这会导致以下问题。

ffmpeg version git-2017-03-03-68ee800 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --arch=armhf --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --extra-libs=-lasound --enable-pthreads
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
  Duration: N/A, start: 1488650966.446293, bitrate: 1024 kb/s
    Stream #0:0: Audio: pcm_s16le, 32000 Hz, stereo, s16, 1024 kb/s
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 2227.042654, bitrate: 159252 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 864x480, 159252 kb/s, 24 fps, 24 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x2e42310] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Illegal instruction
pi@raspberrypi:~ $

如果我添加

thread_queue_size 512 

我结束了

pi@raspberrypi:~ $ ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -thread_queue_size 512 -i /dev/video0 -framerate 25 -video_size 1280x720  -c:v libx264 -preset veryfast -maxrate 1984k -bufsize 3968k -vf "format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100 -f flv rtmp://a.rtmp.youtube.com/live2/zqg7-98wy-60b6-f2yx
ffmpeg version git-2017-03-03-68ee800 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --arch=armhf --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --extra-libs=-lasound --enable-pthreads
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
  Duration: N/A, start: 1488651430.836193, bitrate: 1024 kb/s
    Stream #0:0: Audio: pcm_s16le, 32000 Hz, stereo, s16, 1024 kb/s
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 2691.407641, bitrate: 159252 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 864x480, 159252 kb/s, 24 fps, 24 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Illegal instruction
pi@raspberrypi:~ $

具体在哪里

thread_queue_size

属于?

注意事项: ffmpeg 是使用这个reference 构建的 使用了--extra-libs=-lasound & --enable=pthreads

【问题讨论】:

  • Illegal instruction 表明 ffmpeg 已使用错误的 arch 目标进行编译。您的thread_queue_size 位置很好。
  • 只有当我从 raw 编码到 x264 时才会发生这种情况。如果我直接使用来自相机的 h264 流,它可以正常工作。 ffmpeg 是根据我遵循的指南为 armhf 编译的。会不会是 x264 编译不正确?
  • 这似乎很有可能。

标签: ffmpeg streaming


【解决方案1】:

我完全忘记了 RaspberryPI 对 H264 有硬件支持。

所以我关注了这个tutorial,我们在 Raspberry Pi B (ARMV6) 上通过实时流式传输实现了 30% 的 CPU 使用率。

【讨论】:

    猜你喜欢
    • 2020-08-26
    • 2017-09-21
    • 2022-08-20
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2013-04-16
    • 2017-09-18
    • 2018-07-16
    相关资源
    最近更新 更多