Search code examples
ffmpegraspberry-piffserver

Can't get ffmpeg to stream webcam


I have a rapsberry with ffmpeg installed and a microsoft hd3000 cam installed I run the following command: ffserver -f /etc/ffserver.conf & ffmpeg -framerate 21 -re -f video4linux2 -i /dev/video0 -f alsa -i sysdefault:CARD=HD3000 http://localhost:8090/feed1.ffm

and i get the following:

/etc/ffserver.conf:164: Setting default value for video bit rate tolerance = 16000. Use NoDefaults to disable it.
/etc/ffserver.conf:164: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
/etc/ffserver.conf:164: Setting default value for video max rate = 6229744. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for audio sample rate = 22050. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for audio channel count = 1. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video bit rate tolerance = 64000. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video max rate = 6369328. Use NoDefaults to disable it.
bind(port 8090): Address already in use
Wed Nov 29 13:17:49 2017 Could not start server
[video4linux2,v4l2 @ 0x1a35630] The driver changed the time per frame from 1/21 to 1/10
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 12116.079136, bitrate: 147456 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'sysdefault:CARD=HD3000':
  Duration: N/A, start: 1511961469.424072, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[tcp @ 0x1a44160] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
Wed Nov 29 13:17:49 2017 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
[tcp @ 0x1a63ca0] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
[mpeg1video @ 0x1a6ecb0] bitrate tolerance 21333 too small for bitrate 64000, overriding
[mpeg1video @ 0x1a6ecb0] MPEG-1/2 does not support 3/1 fps
Stream mapping:
  Stream #1:0 -> #0:0 (pcm_s16le (native) -> mp2 (native))
  Stream #0:0 -> #0:1 (rawvideo (native) -> mpeg1video (native))
  Stream #1:0 -> #0:2 (pcm_s16le (native) -> wmav2 (native))
  Stream #0:0 -> #0:3 (rawvideo (native) -> msmpeg4v3 (msmpeg4))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
Wed Nov 29 13:17:49 2017 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 0
[2]+  Exit 1                  ffserver -f /etc/ffserver.conf

I use the default /etc/ffserver.conf. I can't seem to figur out what is the problem.


Solution

  • MPEG-1/2 does not support 3/1 fps

    This is the error that is causing the failure. Although you set a frame rate of 21 it appears the webcam is changing it.

    From the ffmpeg side you have two options:

    • Use a different encoder other than mpeg1video/mpeg2video that can support arbitrary frame rates, or

    • If you want to keep using mpeg1video see the -r and/or -vsync options to properly deal with the output frame rate.

    Note that ffserver is being planned for removal soon from FFmpeg. You may want to find an alternative.