0

I need to record a video from my webcam with ffmpeg.

I tried with this command : ffmpeg -re -f video4linux2 -i /dev/video0 video.avi.

And I received that : The v4l2 frame is 24384 bytes, but 153600 bytes are expected.

When I try the same operation with avconv with this command : avconv -f video4linux2 -i /dev/video0 video.avi I received the same error.

But I can receive the video from my webcam with this command: gstreamer-properties.

How to configure v4l2 to get signal video from my webcam ?

ShoxSpartan
  • 11
  • 1
  • 5
  • WHat is video size of your input video (webcam)? Try to use option -s and specify size of video, like -s 640x480. – ptQa Dec 05 '13 at 22:09
  • I tried with many different sizes. I tried to reduce frames, to change size, to change codecs, to delimit record time... – ShoxSpartan Dec 06 '13 at 08:05
  • But when I try with the size 160x120 the program go in an infinite loop and don't send me any error or warning. – ShoxSpartan Dec 06 '13 at 08:23
  • Ok. Please, provide full ffmpeg output when you run command and output of command "v4l2-ctl --all" – ptQa Dec 06 '13 at 08:26
  • Driver Info (not using libv4l2): Driver name : uvcvideo Card type : HD Webcam C525 Bus info : usb-0000:00:0b.0-1 Driver version: 3.8.13 Capabilities : 0x84000001 Video Capture Streaming Format Video Capture: Width/Height : 160/120 Pixel Format : 'YUYV' Field : None Bytes per Line: 320 Size Image : 38400 Colorspace : SRGB Crop Capability Video Capture: Bounds : Left 0, Top 0, Width 160, Height 120 Default : Left 0, Top 0, Width 160, Height 120 Pixel Aspect: 1/1 – ShoxSpartan Dec 06 '13 at 08:44
  • Video input : 0 (Camera 1: ok) Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 Priority: 2 I received that and my last command set size at 160x120. If I set size at 320x240 all this size settings will change to 320x240. – ShoxSpartan Dec 06 '13 at 08:45
  • Have you tried set pixel format of input? – ptQa Dec 06 '13 at 08:48
  • I tried some like mp4, avi, wma or h264. – ShoxSpartan Dec 06 '13 at 08:53
  • You are talking about media containers and codecs. I'm talking about pixel format like 444yuv, 420yuv etc. See full list of available pixel formats using command "ffmpeg -pix_fmts" – ptQa Dec 06 '13 at 08:58
  • I will try with different pixel format. – ShoxSpartan Dec 06 '13 at 09:05
  • ffmpeg change automatically pixel format to yuyv422 whatever I set in the command. – ShoxSpartan Dec 06 '13 at 09:10
  • I see. Ok if you use 160x120 you have valid output or not? Also try to set framerate to lower values, like 5-10 fps. – ptQa Dec 06 '13 at 09:39
  • I have nothing if I use 160x120. The program do nothing after opening /dev/video0.I tried with different frame rates. – ShoxSpartan Dec 06 '13 at 09:51
  • Sorry, I have no idea then. – ptQa Dec 06 '13 at 13:53
  • Thanks anyway, if someone else have an idea? – ShoxSpartan Dec 06 '13 at 13:59

1 Answers1

0

The problem come from virtual box. It recognize my webcam the first time during my test but after just as a USB device. I set USB device to webcam and now I can stream or convert videos with ffmpeg.

ShoxSpartan
  • 11
  • 1
  • 5