[FFmpeg-user] Newbie streaming problem

Steven Occhipinti public at stevenocchipinti.com
Thu Oct 13 14:35:15 CEST 2011


On Thu, Oct 13, 2011 at 3:03 AM, belcampo <belcampo at zonnet.nl> wrote:

> On 10/12/2011 02:07 PM, Steven Occhipinti wrote:
>
>> Thanks, must be close now.
>>
>> I thought the -an would be a little contradicting, but I tried removing
>> one
>> of the -map options instead of removing the -an option. Either way,
>> rearranging the options as you suggested helped, but I'm getting a
>> different
>> error now.
>>
> I'm no webcam/video4linux2 guru, so I'm guessing a little bit.
> Earlier you stated that you could create a playable mp4 with the command
>
>
> ffmpeg -an -f video4linux2 -s 320x240  -r 15 -i /dev/video0
> -vcodec mpeg4 -vtag DIVX /tmp/test.mp4
>
> Does the later used command also produce a playable file?
>
> ffmpeg -i /dev/video0 -vcodec mpeg4 -map 0.3 -map 0.2 -vtag DIVX -f
> video4linux2 -s 320x240 -r 15 /tmp/test.mp4
>

This does not produce a playable file, I get this error:
  [video4linux2 @ 0x823a2c0]Wrong size (0x0)
  /dev/video0: Error while opening file


>
> if not, maybe placing -f  video4linux2
> in front of -i makes a difference
>

I've found the -f video4linux2 must be before the -i /dev/video1, otherwise
I get an "Unknown format" error.
That also matches other examples I have found.

I was also getting a "Wrong size (0x0)" error, and so I have moved all other
arguments between the -f and the -i to fix that.
After a fair amount of experimenting, this is the best I can come up with:

# ffmpeg -f video4linux2 -s 320x240 -r 15 -vcodec mpeg4 -map 0.3 -map 0.2
-vtag DIVX -i /dev/video0 http://localhost:8090/feed1.ffm
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009
Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1.2 --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
--disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl
--enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394
--enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Sep 16 2011 17:04:18, gcc: 4.4.3
[video4linux2 @ 0x9b322d0][3]Capabilities: 4000001
[video4linux2 @ 0x9b322d0]The V4L2 driver changed the video from 320x240 to
176x144
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 1318508978.203480, bitrate: 6082 kb/s
    Stream #0.0: Video: mpeg4, yuyv422, 176x144, 6082 kb/s, 15 tbr, 1000k
tbn, 15 tbc
Number of stream maps must match number of output streams
ioctl(VIDIOC_QBUF)


I also experimented with different -map options, but no luck.
Is there a way I can ensure which streams need to set with -map.
The man page says it maps input streams to output streams, but it looks like
there is only 1 input stream and 4 output streams.

Man page:
-map input_stream_id[:sync_stream_id]
           Set stream mapping from input streams to output streams.  Just
enumerate
           the input streams in the order you want them in the output.
sync_stream_id
           if specified sets the input stream to sync against.

It looks like it take input streams as argument, which I think I only have 1
of.
When I run it without the -map options, it lists 1 input stream and 4 output
streams:
# ffmpeg -f video4linux2 -s 320x240 -r 15 -vcodec mpeg4 -vtag DIVX -i
/dev/video0 http://localhost:8090/feed1.ffm
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009
Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1.2 --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
--disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl
--enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394
--enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Sep 16 2011 17:04:18, gcc: 4.4.3
[video4linux2 @ 0x812c2d0][3]Capabilities: 4000001
[video4linux2 @ 0x812c2d0]The V4L2 driver changed the video from 320x240 to
176x144
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 1318509208.059178, bitrate: 6082 kb/s
    Stream #0.0: Video: mpeg4, yuyv422, 176x144, 6082 kb/s, 15 tbr, 1000k
tbn, 15 tbc
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
    Stream #0.0: Audio: mp2, 44100 Hz, mono, s16, 32 kb/s
    Stream #0.1: Video: mpeg4, yuv420p, 176x144, q=3-31, 64 kb/s, 1000k tbn,
3 tbc
    Stream #0.2: Audio: mp2, 22050 Hz, mono, s16, 64 kb/s
    Stream #0.3: Video: msmpeg4, yuv420p, 352x240, q=3-31, 256 kb/s, 1000k
tbn, 15 tbc
Could not find input stream matching output stream #0.0
ioctl(VIDIOC_QBUF)

These "streams" still confuse me :S


> So maybe try
>  ffmpeg -f video4linux2 -i /dev/video0 -vcodec mpeg4 -map 0.3 -map 0.2
> -vtag DIVX
> -s 320x240 -r 15 /tmp/test.mp4
>


>> # ffmpeg -i /dev/video0 -vcodec mpeg4 -map 0.3 -map 0.2 -vtag DIVX -f
>> video4linux2 -s 320x240 -r 15 http://localhost:8090/feed1.**ffm<http://localhost:8090/feed1.ffm>
>> FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009
>> Fabrice Bellard, et al.
>>   configuration: --extra-version=4:0.5.1-**1ubuntu1.2 --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
>> --disable-stripping --disable-vhook --enable-runtime-cpudetect
>> --enable-gpl
>> --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394
>> --enable-shared --disable-static
>>   libavutil     49.15. 0 / 49.15. 0
>>   libavcodec    52.20. 1 / 52.20. 1
>>   libavformat   52.31. 0 / 52.31. 0
>>   libavdevice   52. 1. 0 / 52. 1. 0
>>   libavfilter    0. 4. 0 /  0. 4. 0
>>   libswscale     0. 7. 1 /  0. 7. 1
>>   libpostproc   51. 2. 0 / 51. 2. 0
>>   built on Sep 16 2011 17:04:18, gcc: 4.4.3
>> /dev/video0: Unknown format
>>
>>
>> Sorry to keep asking like this :(
>> I wouldn't have thought it would compain about "-f video4linux2" as that
>> was
>> one of the options I thought I got right initially when I recorded my
>> first
>> video clip.
>>
>> Any ideas?
>> I appreciate you help!
>>
>>
>> On Wed, Oct 12, 2011 at 1:42 AM, belcampo<belcampo at zonnet.nl>  wrote:
>>
>>  On 10/11/2011 12:15 PM, Steven Occhipinti wrote:
>>>
>>>  On Tue, Oct 11, 2011 at 6:43 PM, belcampo<belcampo at zonnet.nl>   wrote:
>>>>
>>>>  On 10/11/2011 04:26 AM, Steven Occhipinti wrote:
>>>>>
>>>>>  Hi,
>>>>>>
>>>>>> I'm pretty new to ffmpeg and am a little confused on how ffserver
>>>>>> works.
>>>>>> My goal is to stream a webcam from one machine to (one or more)
>>>>>> others.
>>>>>> Ideally I would want the client machine to only require a web browser
>>>>>> and the basic plugins, etc. to view the stream.
>>>>>>
>>>>>> I have Ubuntu 10.04.3 server installed and ffmpeg/ffserver from the
>>>>>> repo.
>>>>>> If I run this command to test the webcam and it starts up and a video
>>>>>> file is successfully recorded /tmp/test.mp4:
>>>>>>   #>     ffmpeg -an -f video4linux2 -s 320x240  -r 15 -i /dev/video0
>>>>>> -vcodec mpeg4 -vtag DIVX /tmp/test.mp4
>>>>>> I copied /etc/ffserver.conf to my home dir - I think I need to tweak
>>>>>> this file a bit, but need a little help.
>>>>>> I ran this command and it started a server on localhost:8090
>>>>>>   #>     ffserver -f ~/ffserver.conf
>>>>>> I then ran
>>>>>>   #>     ffmpeg -an -f video4linux2 -s 320x240  -r 15 -i /dev/video0
>>>>>> -vcodec mpeg4 -vtag DIVX http://localhost:8090/feed1.****ffm<http://localhost:8090/feed1.**ffm>
>>>>>> <http://localhost:8090/**feed1.ffm <http://localhost:8090/feed1.ffm>>
>>>>>>
>>>>>>
>>>>>> and this is the output I get:
>>>>>>
>>>>>>   #>     ffmpeg -an -f video4linux2 -s 320x240  -r 15 -i /dev/video0
>>>>>> -vcodec mpeg4 -vtag DIVX http://localhost:8090/feed1.****ffm<http://localhost:8090/feed1.**ffm>
>>>>>> <http://localhost:8090/**feed1.ffm <http://localhost:8090/feed1.ffm>>
>>>>>>
>>>>>> FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009
>>>>>> Fabrice Bellard, et al.
>>>>>>   configuration: --extra-version=4:0.5.1-****1ubuntu1.2 --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
>>>>>> --disable-stripping --disable-vhook --enable-runtime-cpudetect
>>>>>> --enable-gpl --enable-postproc --enable-swscale --enable-x11grab
>>>>>> --enable-libdc1394 --enable-shared --disable-static
>>>>>>   libavutil     49.15. 0 / 49.15. 0
>>>>>>   libavcodec    52.20. 1 / 52.20. 1
>>>>>>   libavformat   52.31. 0 / 52.31. 0
>>>>>>   libavdevice   52. 1. 0 / 52. 1. 0
>>>>>>   libavfilter    0. 4. 0 /  0. 4. 0
>>>>>>   libswscale     0. 7. 1 /  0. 7. 1
>>>>>>   libpostproc   51. 2. 0 / 51. 2. 0
>>>>>>   built on Sep 16 2011 17:04:18, gcc: 4.4.3
>>>>>> [video4linux2 @ 0x89092c0][3]Capabilities: 4000001
>>>>>> [video4linux2 @ 0x89092c0]The V4L2 driver changed the video from
>>>>>> 320x240 to 176x144
>>>>>> Input #0, video4linux2, from '/dev/video0':
>>>>>>   Duration: N/A, start: 1318298315.446232, bitrate: 6082 kb/s
>>>>>>     Stream #0.0: Video: rawvideo, yuyv422, 176x144, 6082 kb/s, 15 tbr,
>>>>>> 1000k tbn, 15 tbc
>>>>>> Output #0, ffm, to 'http://localhost:8090/feed1.****ffm<http://localhost:8090/feed1.**ffm>
>>>>>> <http://localhost:8090/**feed1.ffm <http://localhost:8090/feed1.ffm>>
>>>>>>
>>>>>> ':
>>>>>>     Stream #0.0: Audio: mp2, 44100 Hz, mono, s16, 32 kb/s
>>>>>>     Stream #0.1: Video: mpeg1video, yuv420p, 176x144, q=3-31, 64 kb/s,
>>>>>> 1000k tbn, 3 tbc
>>>>>>     Stream #0.2: Audio: mp2, 22050 Hz, mono, s16, 64 kb/s
>>>>>>     Stream #0.3: Video: msmpeg4, yuv420p, 352x240, q=3-31, 256 kb/s,
>>>>>> 1000k tbn, 15 tbc
>>>>>> Could not find input stream matching output stream #0.0
>>>>>> ioctl(VIDIOC_QBUF)
>>>>>>
>>>>>>
>>>>>> I'm assuming I need to setup a more suitable<feed>     definition to
>>>>>> match the input, but after some fiddling I can't seem to get it
>>>>>> working.
>>>>>>
>>>>>>  Your camera is providing 2 video and 2 audio streams you need to use
>>>>> the
>>>>> map
>>>>> function to make it work.
>>>>> Adding -map 0.3 -map 0.2 to your ffmpeg command line will choose the
>>>>> higher
>>>>> definition video and audio.
>>>>>
>>>>>  I've attached my ffserver.conf - Any help is much appreciated.
>>>>>>
>>>>>>
>>>>>> Cheers,
>>>>>> Steve
>>>>>>
>>>>>>
>>>>>> ______________________________****_________________
>>>>>> ffmpeg-user mailing list
>>>>>> ffmpeg-user at ffmpeg.org
>>>>>> http://ffmpeg.org/mailman/****listinfo/ffmpeg-user<http://ffmpeg.org/mailman/**listinfo/ffmpeg-user>
>>>>>> <http://**ffmpeg.org/mailman/listinfo/**ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>>>>> >
>>>>>>
>>>>>>  ______________________________****_________________
>>>>> ffmpeg-user mailing list
>>>>> ffmpeg-user at ffmpeg.org
>>>>> http://ffmpeg.org/mailman/****listinfo/ffmpeg-user<http://ffmpeg.org/mailman/**listinfo/ffmpeg-user>
>>>>> <http://**ffmpeg.org/mailman/listinfo/**ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>>>> >
>>>>>
>>>>>
>>>>>  Thanks for your prompt reply.
>>>> Your reply makes sense to me, but when I add those 2 map options, I
>>>> get this error:
>>>> "Number of stream maps must match number of output streams"
>>>>
>>>>  I think the order of options is important, try to change in something
>>> like:
>>>
>>> ffmpeg -i /dev/video0 -vcodec mpeg4 -map 0.3 -map 0.2 -vtag DIVX -f
>>> video4linux2 -s 320x240 -r 15
>>> http://localhost:8090/feed1.****ffm <http://localhost:8090/feed1.**ffm><
>>> http://localhost:8090/**feed1.ffm <http://localhost:8090/feed1.ffm>>
>>>
>>>
>>>
>>>  I tried just the video stream too, but that gives the same result..
>>>> what are the output streams?
>>>>
>>>> # ffmpeg -map 0.3 -map 0.2 -an -f video4linux2 -s 320x240  -r 15 -i
>>>> /dev/video0 -vcodec mpeg4 -vtag DIVX http://localhost:8090/feed1.****
>>>> ffm <http://localhost:8090/feed1.**ffm><http://localhost:8090/**
>>>> feed1.ffm <http://localhost:8090/feed1.ffm>>
>>>>
>>>>  You choose 0.3 and 0.2 as input and therefore output,and then disable
>>> audio
>>> with -an that won't work.
>>>
>>>  FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.2, Copyright (c) 2000-2009
>>>> Fabrice Bellard, et al.
>>>>   configuration: --extra-version=4:0.5.1-****1ubuntu1.2 --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
>>>> --disable-stripping --disable-vhook --enable-runtime-cpudetect
>>>> --enable-gpl --enable-postproc --enable-swscale --enable-x11grab
>>>> --enable-libdc1394 --enable-shared --disable-static
>>>>   libavutil     49.15. 0 / 49.15. 0
>>>>   libavcodec    52.20. 1 / 52.20. 1
>>>>   libavformat   52.31. 0 / 52.31. 0
>>>>   libavdevice   52. 1. 0 / 52. 1. 0
>>>>   libavfilter    0. 4. 0 /  0. 4. 0
>>>>   libswscale     0. 7. 1 /  0. 7. 1
>>>>   libpostproc   51. 2. 0 / 51. 2. 0
>>>>   built on Sep 16 2011 17:04:18, gcc: 4.4.3
>>>> [video4linux2 @ 0x9ce02c0][3]Capabilities: 4000001
>>>> [video4linux2 @ 0x9ce02c0]The V4L2 driver changed the video from
>>>> 320x240 to 176x144
>>>> Input #0, video4linux2, from '/dev/video0':
>>>>   Duration: N/A, start: 1318328002.348537, bitrate: 6082 kb/s
>>>>     Stream #0.0: Video: rawvideo, yuyv422, 176x144, 6082 kb/s, 15 tbr,
>>>> 1000k tbn, 15 tbc
>>>> Number of stream maps must match number of output streams
>>>> ioctl(VIDIOC_QBUF)
>>>> ______________________________****_________________
>>>> ffmpeg-user mailing list
>>>> ffmpeg-user at ffmpeg.org
>>>> http://ffmpeg.org/mailman/****listinfo/ffmpeg-user<http://ffmpeg.org/mailman/**listinfo/ffmpeg-user>
>>>> <http://**ffmpeg.org/mailman/listinfo/**ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>>> >
>>>>
>>>>  ______________________________****_________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/****listinfo/ffmpeg-user<http://ffmpeg.org/mailman/**listinfo/ffmpeg-user>
>>> <http://**ffmpeg.org/mailman/listinfo/**ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>> >
>>>
>>>  ______________________________**_________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/**listinfo/ffmpeg-user<http://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>>
>
>


More information about the ffmpeg-user mailing list