[FFmpeg-devel] av_open_input_file and video4linux2

anouar me.anouar
Wed Feb 25 17:10:58 CET 2009


Sorry if I'm not on the right list. This is my first message.
and thanks for advance for any help

I try to grub images from my v4l2 webcam. It's correctly installed on a 
fedora10 distribution. Works well with MPlayer and ffmpeg (see log at 
the end)

I'm using the last stable ffmpeg
this is my class initialization in my project.
=================
int flux::Init ( const char* campath, int channel, const char* standard, 
int w, int h, int fps, const char* driver )
  {     av_register_all();
     //Register all devices
     avdevice_register_all();
     av_register_all();

     AVFormatParameters formatParams;
     AVInputFormat *iformat;

     videofilename=campath;
     formatParams.channel = channel;
     formatParams.standard =standard;
     formatParams.width = w;
     formatParams.height = h;
     formatParams.time_base= ( AVRational ) {1,fps};
     iformat = av_find_input_format ( driver );

     if ( iformat ) {
        printf ( "API %s found\n", iformat->name );
     } else {
        fprintf ( stderr,"API %s unknown for this ffmpeg version!\n", 
driver );
     }
<--------------------until this line every thing works fine

     int res=av_open_input_file ( &pFormatCtx, videofilename, iformat, 
0, &formatParams ); <-- return -12
     if ( res !=0 ) {
        fprintf ( stderr,"Initialisation failed , [%d] \n",res );
        exit ( -1 );
     }
/*--------------------------*/
}

the av_open_input_file ( &pFormatCtx, videofilename, iformat, 0, 
&formatParams ); return me a -12 so I think it fails to initiliaze the 
webcam.
I'm using exactely the same parameters that I used for running ffmpeg
size= (640x480)
fps= 30
driver=video4linux2
videofilename=/dev/video0



LOGS:Mplayer result

=========================
mplayer tv:// -tv driver=v4l2:width=640:height=480
MPlayer dev-SVN-r27514-4.3.2 (C) 2000-2008 MPlayer 
Team                   CPU: Intel(R) Core(TM)2 CPU          6600  @ 
2.40GHz (Family: 6, Model: 15, Stepping: 6)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 
1                            Compiled with runtime CPU 
detection.                                                   mplayer: 
could not connect to 
socket                                                   mplayer: No 
such file or 
directory                                                     Failed to 
open LIRC support. You will not be able to use your remote 
control.         
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski at zpr.uni-koeln.de>
comment: first try, more to come ;-)
Selected device: Philips SPC 900NC webcam
Capabilites:  video capture  read/write  streaming
supported norms: 0 = webcam;
inputs: 0 = usb;
Current input: 0
Current format: YUV420
v4l2: ioctl set format failed: Invalid argument
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
Selected input hasn't got a tuner!
v4l2: Cannot get fps
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
VDec: vo config request - 640 x 480 (preferred colorspace: Planar I420)
VDec: using Planar I420 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 640x480 => 640x480 Planar I420
Selected video codec: [rawi420] vfm: raw (RAW I420)
==========================================================================
Audio: no sound
Starting playback...
V:   0.0  26/ 26 ??% ??% ??,?% 0 0
================================


FFmpg log:

$ffmpeg -f video4linux2 -s 640x480 -r 30 -i /dev/video0 test.avi
FFmpeg version SVN-r15261, Copyright (c) 2000-2008 Fabrice Bellard, et al.
 configuration: --prefix=/usr --incdir=/usr/include/ffmpeg 
--libdir=/usr/lib --mandir=/usr/share/man --arch=i386 --extra-cflags=-O2 
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables --enable-bzlib --enable-libdc1394 
--enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame 
--enable-libschroedinger --enable-libtheora --enable-libvorbis 
--enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter 
--enable-avfilter-lavf --enable-postproc --enable-swscale 
--enable-pthreads --disable-static --enable-shared --enable-gpl 
--disable-debug --disable-optimizations --disable-stripping 
--shlibdir=/usr/lib --cpu=i386
 libavutil     49.10. 0 / 49.10. 0
 libavcodec    51.71. 0 / 51.71. 0
 libavformat   52.22. 1 / 52.22. 1
 libavdevice   52. 1. 0 / 52. 1. 0
 libavfilter    0. 1. 0 /  0. 1. 0
 libswscale     0. 6. 1 /  0. 6. 1
 libpostproc   51. 2. 0 / 51. 2. 0
 built on Feb  4 2009 19:51:30, gcc: 4.3.2 20081105 (Red Hat 4.3.2-7)
[video4linux2 @ 0x939d7a0][3]Capabilities: 5000001
Input #0, video4linux2, from '/dev/video0':
 Duration: N/A, start: 1235559597.244885, bitrate: 110591 kb/s
   Stream #0.0: Video: rawvideo, yuv420p, 640x480, 110591 kb/s, 30.00 tb(r)
Output #0, avi, to 'test.avi':
   Stream #0.0: Video: mpeg4, yuv420p, 640x480, q=2-31, 200 kb/s, 30.00 
tb(c)
Stream mapping:
 Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  108 fps= 30 q=7.1 Lsize=     323kB time=3.60 bitrate= 735.3kbits/s
video:315kB audio:0kB global headers:0kB muxing overhead 2.579539%






More information about the ffmpeg-devel mailing list