Ffmpeg 丢帧,但 CPU 使用率不超过 10-20%

Ffmpeg 丢帧,但 CPU 使用率不超过 10-20%

我有一些旧硬件,所以我不指望奇迹。我想以标准质量从网络摄像头流式传输到 ustream。

我使用的代码如下

sudo ffmpeg -re -f v4l2 -i /dev/video1 -f flv "rtmp://1.16543hvtJ6aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)"

或者

sudo ffmpeg -re -f v4l2 -r 25 -s 640x480 -i /dev/video1 -f flv "rtmp://1.166aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)

我得到的结果如下

Tasks: 102 total,   1 running,  99 sleeping,   2 stopped,   0 zombie
Cpu(s):  5.7%us,  0.7%sy,  0.0%ni, 93.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1920560k total,   339028k used,  1581532k free,    19112k buffers
Swap:  1963004k total,        0k used,  1963004k free,   129300k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3176 root      20   0  222m  31m  24m S  5.0  1.7   0:01.60 ffmpeg
and

  Metadata:
    encoder         : Lavf53.32.100
    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 1k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> flv)
Press [q] to stop, [?] for help
frame=  330 fps=  5 q=2.5 size=     808kB time=00:01:02.70 bitrate= 105.5kbits/s dup=0 drop=137

我怎样才能进一步推动系统发展,或者找出我的瓶颈在哪里?

server@cryo:~$ ffmpeg -re -f v4l2 -r 25 -s 640x480 -i /dev/video0 -f flv "rtmp://1.1654tJ6aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)"  ffmpeg version 0.10.9-7:0.10.9-1~precise1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct  4 2013 06:37:30 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.9-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  avcodec     configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.9-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libvo-amrwbenc
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[video4linux2,v4l2 @ 0x252f4a0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 120370.039311, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p, 640x480, -4 kb/s, 25 tbr, 1000k tbn, 25 tbc
Incompatible pixel format 'yuvj422p' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x253d2c0] w:640 h:480 pixfmt:yuvj422p tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 0x253d6c0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0x253df60] w:640 h:480 fmt:yuvj422p -> w:640 h:480 fmt:yuv420p flags:0x4
Output #0, flv, to 'rtmp://1.16543355.fme.ustream.tv/ustreamVideo/16543355/BGcZ5ejm9mx5WxCXXbJ3xRfLWhvtJ6aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)':
  Metadata:
    encoder         : Lavf53.32.100
    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 1k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> flv)
Press [q] to stop, [?] for help
frame=  198 fps= 12 q=2.0 size=     222kB time=00:00:16.60 bitrate= 109.6kbits/s

或者

server@cryo:~$ ffmpeg -re -f v4l2 -r 25 -s 640x480 -i /dev/video1 -f flv "rtmp://1.16543355.fme.ustream.tv/ustreamVideo/16543355/BGcZ5ejm9mx5WxCXXbJ3xRfLWhvtJ6aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)"
ffmpeg version 0.10.9-7:0.10.9-1~precise1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct  4 2013 06:37:30 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.9-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  avcodec     configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.9-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libvo-amrwbenc
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[video4linux2,v4l2 @ 0x262a4a0] The driver changed the time per frame from 1/25 to 1/30
[video4linux2,v4l2 @ 0x262a4a0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video1':
  Duration: N/A, start: 163282.070169, bitrate: 147456 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 tbr, 1000k tbn, 30 tbc
Incompatible pixel format 'yuyv422' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x26382a0] w:640 h:480 pixfmt:yuyv422 tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 0x2638640] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0x2638ee0] w:640 h:480 fmt:yuyv422 -> w:640 h:480 fmt:yuv420p flags:0x4
Output #0, flv, to 'rtmp://1.16543355.fme.ustream.tv/ustreamVideo/16543355/BGcZ5ejm9mx5WxCXXbJ3xRfLWhvtJ6aU flashver=FME/2.5\20(compatible;\20FMSc\201.0)':
  Metadata:
    encoder         : Lavf53.32.100
    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 1k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> flv)
Press [q] to stop, [?] for help
frame=   83 fps=  5 q=4.4 size=     267kB time=00:00:16.13 bitrate= 135.3kbits/s dup=0 drop=36

相关内容