Recording /dev/video0 on RaspPi

The place to post if you need help or advice

Moderators: ChrisThornett, LXF moderators

Recording /dev/video0 on RaspPi

Postby bobthebob1234 » Thu Jan 30, 2014 12:56 pm

Hello

I've got a USB easycap video capture thingy plugged into my raspberry pi. After a bit of faffing I've managed to get it to work. This command will show me the video 'live'
Code: Select all
mplayer tv:// -tv driver=v4l2:norm=PAL_BGHIN:width=640:height=480:outfmt=uyvy:device=/dev/video0:input=1:fps=10 -vo sdl -hardframedrop


I would like to record this instead of showing now. However I can't work out how to, all the things I have tried on the intertubes fail :'(

Code: Select all
mencoder tv:// -tv driver=v4l2:norm=PAL_BGHIN:width=640:height=480:outfmt=uyvy:device=/dev/video0:input=1:fps=10 -ffourcc DX50 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=1200:keyint=100 -vf pp=lb,scale=640:480 -o test.avi

says

Selected input hasn't got a tuner!
Unable to open '/dev/dsp': No such file or directory
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
============ Sorry, this file format is not recognized/supported =============
=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===
Cannot open demuxer.

Exiting...


Code: Select all
avconv -f video4linux2 -channel 1 -i /dev/video0 -vcodec mpeg4 -vtag DX50 -b 1200k -r 25 -acodec libmp3lame -ar 44100 -ac 2 -ab 128k -vf yadif,scale=640:480  -y test.avi

says

avconv version 0.8.6-6:0.8.6-1+rpi1, Copyright (c) 2000-2013 the Libav developers
  built on Mar 31 2013 13:58:10 with gcc 4.6.3
[video4linux2 @ 0x1280be0] The v4l2 frame is 690586 bytes, but 691200 bytes are expected
[video4linux2 @ 0x1280be0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, bitrate: 165722 kb/s
    Stream #0.0: Video: rawvideo, uyvy422, 720x480, 165722 kb/s, 29.97 tbr, 1000k tbn, 29.97 tbc
Incompatible pixel format 'uyvy422' for codec 'mpeg4', auto-selecting format 'yuv420p'
[buffer @ 0x1288580] w:720 h:480 pixfmt:uyvy422
[yadif @ 0x1274b60] mode:0 parity:-1 auto_enable:0
[yadif @ 0x1274b60] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'Parsed filter 0 yadif'
[scale @ 0x1275720] w:720 h:480 fmt:uyvy422 -> w:720 h:480 fmt:yuv420p flags:0x4
[scale @ 0x1274fc0] w:720 h:480 fmt:yuv420p -> w:640 h:480 fmt:yuv420p flags:0x4
Output #0, avi, to 'test.avi':
  Metadata:
    ISFT            : Lavf53.21.1
    Stream #0.0: Video: mpeg4, yuv420p, 640x480, q=2-31, 1200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg4)
Press ctrl-c to stop encoding
[video4linux2 @ 0x1280be0] The v4l2 frame is 685464 bytes, but 691200 bytes are expected
frame=    0 fps=  0 q=0.0 Lsize=       6kB time=10000000000.00 bitrate=   0.0kbits/s   
video:0kB audio:0kB global headers:0kB muxing overhead inf%




I'm not an mplayer/mencoder/ffmpeg expert, so am I missing anything obvious?

Cheers
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1373
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Postby Dutch_Master » Thu Jan 30, 2014 1:30 pm

Try redirecting it with the > symbol
Code: Select all
mplayer .... > test.avi
Dutch_Master
LXF regular
 
Posts: 2453
Joined: Tue Mar 27, 2007 1:49 am

Postby nelz » Thu Jan 30, 2014 2:56 pm

Use the command that works for viewing the video and add the -dumpstream option.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8527
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby bobthebob1234 » Thu Jan 30, 2014 4:07 pm

thanks for the replies;

redirect (>) doesn't do anything

with
Code: Select all
mplayer tv:// -tv driver=v4l2:norm=PAL_BGHIN:width=640:height=480:outfmt=uyvy:device=/dev/video0:input=1:fps=10 -vo sdl -hardframedrop -dumpstream -dumpfile test.avi


I just get
Code: Select all
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
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://.
dump: 0 bytes written to 'test.avi'.
Core dumped ;)

Exiting... (End of file)


the smiley face seems to just rub some salt into my wounds :'(

read the FAQ, I have a stream.dump file but it is 0 bytes large...

any more ideas?

I've tried vlc but that won't even play it for some reason...
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1373
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Postby nelz » Thu Jan 30, 2014 4:31 pm

I get the same here, I hadn't used -dumpstream with a video device before but assumed it would work. However, ffmpeg does work

Code: Select all
ffmpeg -f video4linux2 -i /dev/video1 out.avi


You'll probably want to fiddle with bitrates etc.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8527
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby Dutch_Master » Thu Jan 30, 2014 4:33 pm

Right, back to basics then:
  • are you sure you're using the correct flags, in the proper order?
  • are the permissions right?
It's odd the redirect doesn't work, in Linux everything is a file and should be redirect-able :?
Dutch_Master
LXF regular
 
Posts: 2453
Joined: Tue Mar 27, 2007 1:49 am

Postby nelz » Thu Jan 30, 2014 5:20 pm

mplayer sends the video stream to wherever the -vo flag tells it to, it only sends information about the video and process to stdout and stderr., although AFAIR there is an option to stream the video to stdout (although that may be for mencoder).
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8527
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby bobthebob1234 » Fri Jan 31, 2014 3:25 pm

on the topic of -vo if I do
Code: Select all
mplayer tv:// -tv driver=v4l2:norm=PAL_BGHIN:width=640:height=480:outfmt=uyvy:device=/dev/video0:input=1:fps=10 -vo png -hardframedrop


so with -vo png I do get a sequence of png images. Yay

I'd rather not have to make an animation of pngs though :(


although saying that I don't need sound so that could be a possibility...
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1373
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Postby bobthebob1234 » Fri Jan 31, 2014 3:43 pm

although I guess I could run
Code: Select all
mencoder mf://*.png -mf w=640:h=480:fps=25:type=png -ovc copy -oac copy -o output.avi


after getting all the pngs....
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1373
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field


Return to Help!

Who is online

Users browsing this forum: No registered users and 3 guests