View previous topic :: View next topic |
Author |
Message |
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Mon Sep 06, 2010 2:17 pm Post subject: [SOLVED] Stop mencoder interactively |
|
|
Hello, I'm trying to record a stream from my webcam with the following command (I don't think the exact command line is relevant):
Code: | mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ovc lavc -o test.avi -nosound
|
and everything works great, but I can't find a way to stop the recording at some point without losing a lot of it. I tried Cntrl-c, but that just kills the process so I lose whatever mencoder hasn't written to disk yet (which is often a lot). Is there a way to send it a signal so that it will stop getting new information but will finish encoding what it has captured so far before exiting?
Thanks.
Last edited by evlich on Sat Sep 11, 2010 2:19 pm; edited 1 time in total |
|
Back to top |
|
|
tuam l33t
Joined: 04 May 2004 Posts: 765 Location: CGN, Germany
|
Posted: Wed Sep 08, 2010 9:59 pm Post subject: |
|
|
Do you know the recording length before you start? Then you could use -endpos .
FF,
Daniel _________________ Logic clearly dictates that the needs of the many outweigh the needs of the few. - Spock
The needs of the one outweigh the needs of the many. - Kirk
I refuse to let arithmetic decide questions like that. - Picard |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Wed Sep 08, 2010 10:01 pm Post subject: |
|
|
I don't know the recording length. Basically I'm trying to use my webcam as a very cheap video camera, so I'd like to be able to start and stop capture based on what is happening. |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Thu Sep 09, 2010 2:10 pm Post subject: |
|
|
Hi evlich,
There is "buffersize" option for "tv://...". Maybe experimenting with rather small values could help?!
An other way could be to use mplayer (with small caching) to write to a file or to a pipe with "dumpstream" and then use mencoder to encode it on the fly (or afterwards).
When you want to stop the recording you can "kill" mplayers process and mencoder can still run on the data from the pipe or file. |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Thu Sep 09, 2010 2:22 pm Post subject: |
|
|
Doesn't simply pressing 'q' work? I thought it makes mencoder finish current encoding and quit. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Thu Sep 09, 2010 4:52 pm Post subject: |
|
|
I'll look into dumpstream (right now it is just saying "core dumped " and generating a 0 size file, so maybe there is something that I'm doing wrong.
I can't get 'q' to work, it seems to keep recording (unless it takes several minutes to encode a few seconds worth of video, but the camera light is still on, so it seems like it is still capturing. |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Thu Sep 09, 2010 10:46 pm Post subject: |
|
|
That's ok. There should be a new file in the current working directory called "stream.dump".
You can encode it afterwards or play it directly as unencoded stream...
You also can do it like this:
Code: | mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -dumpstream ; mencoder stream.dump -ovc lavc -o test.avi -nosound |
...and then hit STRG+c when you want to stop recording.
Quote: | An other way could be to use mplayer (with small caching) to write to a file or to a pipe with "dumpstream" and then use mencoder to encode it on the fly (or afterwards). |
Just forget about this. |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Fri Sep 10, 2010 12:58 pm Post subject: |
|
|
Hmmm...I'm not sure what the problem is, but mplayer always immediately crashes when i give it dumpstream.
Code: | $ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -dumpstream ; mencoder stream.dump -ovc lavc -o test.avi -nosound
MPlayer SVN-r29796-4.3.4 (C) 2000-2009 MPlayer Team
Playing tv://.
Core dumped ;)
Exiting... (End of file)
MEncoder SVN-r29796-4.3.4 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x0
Seek failed
============ 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...
|
Any idea what would cause this? Is there a USE flag that I'm missing or something like that?
Thanks. |
|
Back to top |
|
|
py-ro Veteran
Joined: 24 Sep 2002 Posts: 1734 Location: Velbert
|
Posted: Fri Sep 10, 2010 1:06 pm Post subject: |
|
|
Just to clarifie this "Core dumped! " is not an error message!
Py |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Fri Sep 10, 2010 3:33 pm Post subject: |
|
|
I used this command and it worked for me with dvb://. Strange.
Quote: | Hmmm...I'm not sure what the problem is, but mplayer always immediately crashes when i give it dumpstream. |
But the webcam is not turned off or such
You could post the output of the mplayer part with -v switch.
You then could try the -dumpvideo option.
Or instead of mplayer use
Code: | mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ovc copy -nosound -of rawvideo -o test.raw |
The above should result in a raw stream, also.
Please be aware that raw video streams in general cost very much disk space!
Quote: | and everything works great, but I can't find a way to stop the recording at some point without losing a lot of it. |
How much are you losing, when you speak of "alot"? I wonder because I think a decent computer should accomplish encoding to mpeg4 almost in real time?! |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Fri Sep 10, 2010 5:01 pm Post subject: |
|
|
I'll look into -v when I get home. By "alot" I mean 60% of it depending on the length. It actually seems like it does the first 20 seconds or so fine and then it just stops. So even if it is 5 minutes long, I end up with at most 30 seconds. |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Fri Sep 10, 2010 5:18 pm Post subject: |
|
|
Quote: | So even if it is 5 minutes long, I end up with at most 30 seconds. |
You say, let the command run for 5 minutes, you end up with a video showing the first 30s of it??
That's weird.
But try to capture a raw stream first, and see if there is something missing. |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Fri Sep 10, 2010 5:22 pm Post subject: |
|
|
Perhaps you may want to look up "motion" and see if it suites your needs. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Fri Sep 10, 2010 10:00 pm Post subject: |
|
|
Here's what I get with -v:
Code: | $ mplayer tv:// -v -dumpstream
MPlayer SVN-r29796-4.3.4 (C) 2000-2009 MPlayer Team
CPU vendor name: GenuineIntel max cpuid level: 10
CPU: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz (Family: 6, Model: 15, Stepping: 11)
extended cpuid-level: 8
extended cache-info: 268468288
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNowExt: 0 SSE: 1 SSE2: 1 SSSE3: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2 SSSE3 CMOV
get_path('codecs.conf') -> '/home/gmalecha/.mplayer/codecs.conf'
Reading /home/gmalecha/.mplayer/codecs.conf: Can't open '/home/gmalecha/.mplayer/codecs.conf': No such file or directory
Reading /etc/mplayer/codecs.conf: Can't open '/etc/mplayer/codecs.conf': No such file or directory
Using built-in default codecs.conf.
Configuration: --cc=x86_64-pc-linux-gnu-gcc --host-cc=x86_64-pc-linux-gnu-gcc --prefix=/usr --confdir=/etc/mplayer --datadir=/usr/share/mplayer --libdir=/usr/lib64 --enable-network --disable-arts --disable-fribidi --disable-ftp --disable-lirc --disable-lircc --disable-apple-ir --disable-libnut --disable-smb --disable-svga --disable-svgalib_helper --disable-joystick --disable-cdparanoia --charset=UTF-8 --disable-tv-bsdbt848 --disable-ivtv --disable-tv-teletext --disable-radio-v4l2 --disable-radio-bsdbt848 --disable-liba52 --disable-musepack --disable-libopencore_amrnb --disable-libopencore_amrwb --disable-liblzo --xanimcodecsdir=/usr/lib/xanim/mods --disable-libbs2b --disable-gif --disable-mad --disable-mng --disable-pnm --disable-tga --realcodecsdir=/usr/lib64/codecs --disable-directfb --disable-aa --disable-fbdev --disable-caca --disable-zr --disable-gui --disable-dga1 --disable-dga2 --disable-dxr3 --disable-ggi --enable-menu --disable-vidix --disable-vidix-pcidb --disable-xvmc --disable-3dfx --disable-tdfxvid --disable-tdfxfb --disable-esd --disable-jack --disable-openal --disable-pulse --disable-ossaudio
CommandLine: 'tv://' '-v' '-dumpstream'
init_freetype
Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay
get_path('fonts') -> '/home/gmalecha/.mplayer/fonts'
Using nanosleep() timing
get_path('input.conf') -> '/home/gmalecha/.mplayer/input.conf'
Can't open input config file /home/gmalecha/.mplayer/input.conf: No such file or directory
Parsing input config file /etc/mplayer/input.conf
Input config file /etc/mplayer/input.conf parsed: 90 binds
get_path('.conf') -> '/home/gmalecha/.mplayer/.conf'
Playing tv://.
get_path('sub/') -> '/home/gmalecha/.mplayer/sub/'
STREAM: [tv] tv://
STREAM: Description: TV Input
STREAM: Author: Benjamin Zores, Albeu
STREAM: Comment:
Core dumped ;)
vo: x11 uninit called but X11 not initialized..
Exiting... (End of file)
|
I'm still getting the 0 size stream.dump file as the result. It looks like there is a missing codecs.conf and then something about "vo: x11 uninit...", but I'm not really sure whether these are real problems.
Thanks. |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Sat Sep 11, 2010 11:55 am Post subject: |
|
|
Code: | vo: x11 uninit called but X11 not initialized.. |
...is because mplayer tries to uninitialize the x11-video-out, while it wasn't initialized at all because no valid video stream was found.
Just because I am curios: You get a picture if you just type: mplayer tv:// ?? |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Sat Sep 11, 2010 12:50 pm Post subject: |
|
|
I do get a picture with just mplayer tv:// |
|
Back to top |
|
|
evlich Tux's lil' helper
Joined: 17 Oct 2007 Posts: 107
|
Posted: Sat Sep 11, 2010 1:27 pm Post subject: |
|
|
So I don't have a solution to mplayer, but ffmpeg will do it (it accepts q to quit encoding).
Code: | ffmpeg -y -f video4linux2 -s 640x480 -r 15 -i /dev/video0 next-out.avi |
Thanks for all your help. |
|
Back to top |
|
|
dermund Apprentice
Joined: 28 Aug 2007 Posts: 205 Location: Sprawl
|
Posted: Sat Sep 11, 2010 2:38 pm Post subject: |
|
|
Nice you found a solution that works for you. |
|
Back to top |
|
|
|