Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Recording /dev/video0 on RaspPi

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Thu Jan 30, 2014 12:56 pm    Post subject: Recording /dev/video0 on RaspPi Reply with quote

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:

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:

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:

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
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Jan 30, 2014 1:30 pm    Post subject: Reply with quote

Try redirecting it with the > symbol
Code:
mplayer .... > test.avi
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Jan 30, 2014 2:56 pm    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Thu Jan 30, 2014 4:07 pm    Post subject: Reply with quote

thanks for the replies;

redirect (>) doesn't do anything

with
Code:

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:

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
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Jan 30, 2014 4:31 pm    Post subject: Reply with quote

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:
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)
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Jan 30, 2014 4:33 pm    Post subject: Reply with quote

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 Confused
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Jan 30, 2014 5:20 pm    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Fri Jan 31, 2014 3:25 pm    Post subject: Reply with quote

on the topic of -vo if I do
Code:

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 Sad


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
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Fri Jan 31, 2014 3:43 pm    Post subject: Reply with quote

although I guess I could run
Code:

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
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast