I have a problem with running an FFMPEG command from within a Python script. When I run the following command from the terminal, I can stream video and audio from my attached webcam (Logitech C310) and output to file "out.avi" without any errors.
ffmpeg -f alsa -i default -itsoffset 00:00:00 -f video4linux2 -s 1280x720 -r 25 -i /dev/video0 out.avi
When I run the same command in a Python script below,
def call_command(command):
subprocess.Popen(command.split(' '))
call_command("ffmpeg -f alsa -i default -itsoffset 00:00:00 -f video4linux2 -s 1280x720 -r 25 -i /dev/video0 out.avi")
it gives me this error:
Input #0, alsa, from 'default':
Duration: N/A, start: 1317762562.695397, bitrate: N/A
Stream #0.0: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s
[video4linux2 @ 0x165eb10]Cannot find a proper format for codec_id 0, pix_fmt -1.
/dev/video0: Input/output error
Could anyone shed some light on what could be going on here? I've tried using os.system() as well as subprocess.call() and it gives me the same errors. I'm not sure where to start on what could be going wrong here. I tried searching for the "video4linux2 Cannot find a proper format for codec_id 0, pix_fmt -1" error, but couldn't find anything consistent.