Xubuntu 12.10 和 FFMPEG 网络摄像头

Xubuntu 12.10 和 FFMPEG 网络摄像头

在运行ffmpegffserver全新安装 Xubuntu 12.10。

我刚刚从头安装了 Xubuntu 12.10,然后安装了 ffmpeg。我插入了我的网络摄像头(请注意,我在另一个系统 Ubuntu 12.04 和 11.04 上使用过这个网络摄像头,使用相同的ffserver命令没有任何问题),然后运行 ​​ffmpeg 命令:

ffmpeg -f video4linux2 -i /dev/video0 http://IP:8090/cam1.ffm

从理论上来说这应该可行但我得到的是:

fmpeg version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:49:20 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
ffmpeg: /build/buildd/libav-0.8.4/libavutil/mathematics.c:79: av_rescale_rnd: Assertion `c > 0' failed.
Aborted (core dumped)

我搜索过该错误,但找不到任何地方。因此,我尝试使用 mplayer 查看网络摄像头是否正常工作,如果video0正常工作:

mplayer tv:// -tv device=/dev/video0:driver=v4l2:width=352:height=288

它运行完美并向我显示了我的网络摄像头屏幕。

现在我想,好吧,也许这个愚蠢的弃用事情与它有关,所以我尝试使用 avconv 对 ffmpeg 执行完全相同的命令,但出现了同样的错误。

lsusb给我:

Bus 001 Device 003: ID 04fc:1528 Sunplus Technology Co., Ltd SPCA1527A/SPCA1528 SD card camera (webcam mode)

正如我所说的,我在另外两台安装了不同 Ubuntu 的电脑上安装了完全相同的网络摄像头。

编辑:

我已ffmpeg根据以下说明重新编译: https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

它可以工作,如果我使用与上面相同的命令,它就会运行,CPU 以 100% 运行,就像它在转换一样。但没有输出ffmpeg,它只是无限期地挂在这里,直到我ctrl-c

ffmpeg version git-2013-01-01-fde1305 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan  1 2013 11:42:21 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
  configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 85.100 / 54. 85.100
  libavformat    54. 58.102 / 54. 58.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 30.102 /  3. 30.102
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[video4linux2,v4l2 @ 0x97c8200] DTS discontinuity in stream 0: packet 3 with DTS 21527529506, packet 4 with DTS 21527577460

然后我ctrl-c两次得到这个:

^CEstimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 21527.513483, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p, 320x240, -2147483 kb/s, 18.08 tbr, 1000k tbn, 1000k tbc
http://IP:8090/cam1.ffm: Input/output error
Received signal 2: terminating.

好的,让我看看如果我指定帧速率会发生什么:

ffmpeg -r 2 -f video4linux2 -i /dev/video0 http://IP:8090/cam1.ffm

ffmpeg version git-2013-01-01-fde1305 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan  1 2013 11:42:21 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
  configuration: --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 85.100 / 54. 85.100
  libavformat    54. 58.102 / 54. 58.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 30.102 /  3. 30.102
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[video4linux2,v4l2 @ 0xa5fa2a0] DTS discontinuity in stream 0: packet 3 with DTS 21627329870, packet 4 with DTS 21627409821
[video4linux2,v4l2 @ 0xa5fa2a0] max_analyze_duration 5000000 reached at 5000000
[video4linux2,v4l2 @ 0xa5fa2a0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 21627.313851, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p, 320x240, 0 kb/s, 2 fps, 0.25 tbr, 1000k tbn, 2 tbc
Incompatible pixel format '(null)' for codec 'flv', auto-selecting format '(null)'
    Last message repeated 1 times
[flv @ 0xa6046c0] Specified pixel format yuvj420p is invalid or not supported
Output #0, ffm, to 'http://198.144.186.224:8090/cam1.ffm':
  Metadata:
    creation_time   : now
    Stream #0:0: Video: flv1 ([0][0][0][5] / 0x5000000), yuvj420p, 320x2, q=255-255, 200 kb/s, 1000k tbn, 2 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> flv)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

我的ffserver配置文件如下所示(尽管我说过它之前在另一台电脑上运行良好):

Port 8090
BindAddress IP
MaxHTTPConnections 30
MaxClients 20
MaxBandwidth 2000
CustomLog - 

<Feed cam1.ffm> 
File /tmp/cam1.ffm
FileMaxSize 10000K
</Feed> 

<Stream cam1.flv> 
Feed cam1.ffm 
Format flv 
VideoCodec flv 
VideoFrameRate 2
VideoBufferSize 20000 
VideoBitRate 200 
VideoQMin 5
VideoQMax 10 
VideoSize qvga
PreRoll 0 
Noaudio 
AVOptionVideo flags +global_header
</Stream>

<Stream stat.html>
Format status
</Stream>

编辑2:

刚刚确认在我的 Ubuntu 11.04 机器上运行它工作正常,命令有点不同,但它有效:

ffmpeg -r 10 -s 320x240 -f video4linux2 -aspect 4:3 -i /dev/video0 http://IP:8090/cam1.ffm

所以我将此命令复制到其他 Xubuntu 系统中,并遇到了missing yuvj420p之前的问题:

[video4linux2,v4l2 @ 0xb1c53e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 27867.321194, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p, 320x240, -1 kb/s, 10 tbr, 1000k tbn, 10 tbc
Incompatible pixel format '(null)' for codec 'flv', auto-selecting format '(null)'
    Last message repeated 1 times
[flv @ 0xb1ca6e0] Specified pixel format yuvj420p is invalid or not supported
Output #0, ffm, to 'http://198.144.186.224:8090/cam1.ffm':
  Metadata:
    creation_time   : now
    Stream #0:0: Video: flv1 ([0][0][0][5] / 0x5000000), yuvj420p, 320x10, q=255-255, 200 kb/s, 1000k tbn, 10 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> flv)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

ffmpeg上面发布了我在 Xubuntu 机器上运行时的配置信息,下面是我ffmpeg在 Ubuntu 11 机器上运行时显示的内容:

FFmpeg version 0.6.6-4:0.6.6-0ubuntu0.11.04.1, Copyright (c) 2000-2010 the Libav developers
  built on Jun 12 2012 16:28:21 with gcc 4.5.2
  configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  WARNING: library configuration mismatch
  libavutil   configuration: --extra-version=4:0.6.6-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-libopenjpeg --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libfaad --enable-libdirac --enable-libfaad --enable-libmp3lame --enable-librtmp --enable-libx264 --enable-libxvid --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libavcodec  configuration: --extra-version=4:0.6.6-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-libopenjpeg --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libfaad --enable-libdirac --enable-libfaad --enable-libmp3lame --enable-librtmp --enable-libx264 --enable-libxvid --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libavformat configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libavdevice configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libavfilter configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libswscale  configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libpostproc configuration: --extra-version=4:0.6.6-0ubuntu0.11.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0

因此,它当然是用不同的选项进行编译的,但是哪个选项是支持的yuvj420p,或者既然我知道问题“似乎”是什么,我该如何消除该错误?

编辑3:

我使用我正在使用的 Ubuntu 11 系统中的开关重新进行了编译:

./configure --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame   --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora   --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3 --enable-shared --enable-libv4l2 --enable-avfilter --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-pthreads --enable-zlib --disable-stripping --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-libdc1394 --disable-static

应该--enable-sharedyuvj子集。

这样就完成了,所有开关都已切换,现在我运行它并得到:

[video4linux2,v4l2 @ 0x9d1d0e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 36365.493926, bitrate: 36863 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 36863 kb/s, 10 tbr, 1000k tbn, 10 tbc
Incompatible pixel format '(null)' for codec 'flv', auto-selecting format '(null)'
    Last message repeated 1 times
[flv @ 0x9d22440] Warning min_rate > 0 but min_rate != max_rate isn't recommended!
[flv @ 0x9d22440] bitrate below min bitrate
Output #0, ffm, to 'http://IP:8090/cam1.ffm':
  Metadata:
    creation_time   : now
    Stream #0:0: Video: flv1 ([0][0][0][5] / 0x5000000), yuv420p, 640x10, q=255-255, 200 kb/s, 1000k tbn, 10 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> flv)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

所以现在它可以运行并找到东西,但由于 ,仍然不让我使用bitrate below min bitrate。我尝试设置-b 200k-b 600k但仍然是同样的情况。我认为这是因为 FFM 文件显示 200,但我希望它在 200。

那么现在我该如何禁用比特率检查?

我猜这就是现在的问题,说实话,我很想在这个系统上安装 Ubuntu 11.04 然后放弃它,每个新版本的软件都会让事情变得越来越困难。

相关内容