PCLinuxOS-Forums
News: ...FLASH!!! ...New PCLinuxOS Testing board now open. Register today! Be an active contributor to the PCLinuxOS future! ... Read all about it now, on THIS forum!!!..
 
*
Welcome, Guest. Please login or register. May 25, 2012, 03:54:59 AM


Login with username, password and session length


Pages: 1 [2]   Go Down
  Print  
Author Topic: WXcam, any chance to get it back?  (Read 633 times)
Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #15 on: January 25, 2012, 02:08:02 PM »

This is the script I am currently using.
The Camera detection is needed because it is a USB webcam and can take different Card numbers depending on what may be attached.

The recording parameters probably need to be changed (particularly arecord) to get better quality. But at present low quality audio is all I need.

I have some further questions to ask regarding this script and using Zenity, but will take them to the Advanced section.

Comment: Sometimes the result is out of sync, but mostly it is not. I have not been able to determine the cause.

Code:
#!/bin/bash

set -x

NAME="/home/user/Recordings/WebCamVid"

# Select webcam on the assumption only one webcam is plugged in
CAMERA=$(arecord -l | grep Camera | cut -d " " -f2 | cut -d : -f1),0

# Record video with mencoder and audio with acrecord again assuming one video device
mencoder tv:// -tv device=/dev/video0 -ovc lavc -ofps 25 -noautoexpand -nosound -o $NAME.mp4 & arecord -v -D hw:$CAMERA -c 1 -f S16_LE -t wav $NAME.wav
# When stopped kill arecord
   killall arecord
# Mencoder will then mux the audio and video into an .avi file
    mencoder -oac copy -ovc copy -o $NAME.avi -audiofile $NAME.wav $NAME.mp4
# Remove the working audio and video files
rm -rf $NAME.wav
rm -rf $NAME.mp4

exit 0
Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Leiche
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2704


God knows, i'm not an Angel!


WWW
« Reply #16 on: January 25, 2012, 02:15:22 PM »

glade if it's work for you  Wink

I'm not further why here can't record both files together  Undecided
Logged

Leiche
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2704


God knows, i'm not an Angel!


WWW
« Reply #17 on: January 25, 2012, 02:55:32 PM »

glade if it's work for you  Wink

I'm not further why here can't record both files together  Undecided

Im a big step forward now, can you test this code?

Code:
xterm -e mencoder tv:// -tv device=/dev/video0:input=1:fps=25:alsa:adevice=plughw.0,0:audiorate=44100:amode=1:forceaudio:immediatemode=0 -ffourcc DX50 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=1200:keyint=15 -oac mp3lame -o $NAME.mp4

$NAME=test or else  Wink
Logged

Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #18 on: January 25, 2012, 03:12:19 PM »

It combines the audio and the video  Cheesy

Unfortunately the video runs at x2 speed or such ..... needs some figuring out .....  

EDIT
          The only difference I notice is the use of DIVX 5



Quote
Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1288.125 kbit/s  (161015 B/s)  size: 1553801 bytes  9.650 secs  562 frames

Audio stream:  139.529 kbit/s  (17441 B/s)  size: 167662 bytes  9.613 secs
v4l2: ioctl set mute failed: Invalid argument
v4l2: 561 frames successfully processed, -79 frames dropped.


EDIT2
            I tried
mencoder -idx in.avi -ovc copy -oac copy -o out.avi
to see if it would correct the file, but no ......  not that apparently.
Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Leiche
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2704


God knows, i'm not an Angel!


WWW
« Reply #19 on: January 25, 2012, 03:25:36 PM »


EDIT
          The only difference I notice is the use of DIVX 5

can you remove -ffourcc DX50, if you not like Grin

Other question, why is video running faster, get the same result, but i have audio, and video  Cool
Logged

Leiche
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2704


God knows, i'm not an Angel!


WWW
« Reply #20 on: January 25, 2012, 03:28:33 PM »



EDIT2
            I tried
mencoder -idx in.avi -ovc copy -oac copy -o out.avi
to see if it would correct the file, but no ......  not that apparently.

What is result from mediainfo?
Logged

Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #21 on: January 25, 2012, 03:29:39 PM »


EDIT
          The only difference I notice is the use of DIVX 5

can you remove -ffourcc DX50, if you not like Grin

Other question, why is video running faster, get the same result, but i have audio, and video  Cool

I get audio and video .......  but the video runs fast, so only part of the audio is included.
I have been unable to find the reason for the fast video.

I tried without DIVX but no diff in output video speed.

Seems the problem is in the muxing .....  maybe there is no info in the video and the audio length should be taken .......  I know I am not making sense .....  but if the audio is the correct length and if the video used the same time then it would be correct.

Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #22 on: January 25, 2012, 03:38:41 PM »

Are you getting fast video?

Here are my results ....

Code:
mencoder tv:// -tv device=/dev/video0:input=1:fps=25:alsa:adevice=plughw.0,0:audiorate=44100:amode=1:forceaudio:immediatemode=0 -ffourcc DX50 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=1200:keyint=15 -oac mp3lame -o $NAME.mp4

Code:
mediainfo /home/user/Recordings/leiche.mp4
General
Complete name                            : /home/user/Recordings/leiche.mp4
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 984 KiB
Duration                                 : 6s 165ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 307 Kbps
Writing application                      : MEncoder UNKNOWN-4.5.2
Writing library                          : MPlayer

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Simple@L1
Format settings, BVOP                    : No
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : DX50
Codec ID/Hint                            : DivX 5
Duration                                 : 6s 160ms
Bit rate                                 : 1 105 Kbps
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.144
Stream size                              : 831 KiB (84%)
Writing library                          : Lavc53.10.0

Audio
ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Mode                                     : Joint stereo
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 6s 165ms
Bit rate mode                            : Variable
Bit rate                                 : 185 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Compression mode                         : Lossy
Stream size                              : 139 KiB (14%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 26 ms (0.65 video frame)
Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Leiche
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2704


God knows, i'm not an Angel!


WWW
« Reply #23 on: January 25, 2012, 03:51:56 PM »

I record now 1 minutes, and get

Code:
General
Complete name :
/home/daniel/test1.mp4
Format :
AVI
Format/Info :
Audio Video Interleave
File size :
4.31 MiB
Duration :
24s 160ms
Overall bit rate mode :
Variable
Overall bit rate :
1 496 Kbps
Writing application :
MEncoder UNKNOWN-4.5.2
Writing library :
MPlayer
Video
ID :
0
Format :
MPEG-4 Visual
Format profile :
Simple@L1
Format settings, BVOP :
No
Format settings, QPel :
No
Format settings, GMC :
No warppoints
Format settings, Matrix :
Default (H.263)
Codec ID :
FMP4
Duration :
24s 160ms
Bit rate :
1 331 Kbps
Width :
704 pixels
Height :
576 pixels
Display aspect ratio :
1.222
Frame rate :
25.000 fps
Standard :
PAL
Color space :
YUV
Chroma subsampling :
4:2:0
Bit depth :
8 bits
Scan type :
Progressive
Compression mode :
Lossy
Bits/(Pixel*Frame) :
0.131
Stream size :
3.83 MiB (89%)
Writing library :
Lavc53.10.0
Audio
ID :
1
Format :
MPEG Audio
Format version :
Version 1
Format profile :
Layer 3
Mode :
Joint stereo
Mode extension :
MS Stereo
Codec ID :
55
Codec ID/Hint :
MP3
Duration :
24s 85ms
Bit rate mode :
Variable
Bit rate :
152 Kbps
Channel(s) :
2 channels
Sampling rate :
44.1 KHz
Compression mode :
Lossy
Stream size :
446 KiB (10%)
Alignment :
Aligned on interleaves
Interleave, duration :
26 ms (0.66 video frame)

will see why it is.......ö...... Roll Eyes
Logged

Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #24 on: January 25, 2012, 03:52:32 PM »

I ran the command for 30 secs ......  probably less a few seconds for the camera to initialise etc etc.

Here is what is reported at the end


Quote
Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1196.897 kbit/s  (149612 B/s)  size: 2024750 bytes  13.533 secs  733 frames

Audio stream:  185.023 kbit/s  (23127 B/s)  size: 313557 bytes  13.558 secs
v4l2: ioctl set mute failed: Invalid argument
v4l2: 733 frames successfully processed, 195 frames dropped.

Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #25 on: January 25, 2012, 04:04:36 PM »

Code:
mencoder tv:// -tv device=/dev/video0 -ovc lavc -ofps 25  -nosound -o mine.mp4

This records video properly.
Omit the 'nosound' option, and I get problems with frames.

Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
rich2005
Full Member
***
Offline Offline

Posts: 159


« Reply #26 on: January 26, 2012, 08:52:09 AM »

I had to give up with mencoder before I went crazy.

This works here, on this machine - up to date pclos KDE - from past experience no guarentees elsewhere.

ffmpeg -f video4linux2 -i /dev/video0 -r 30  -vcodec mpeg4 -b 1000 -qscale 5 -bt 256k -y -f alsa -i hw:0,0 -ar 44100 `date +%s`.avi

Basically it is a revamped ffmpeg command I use for screen captures.
As mentioned earlier this sets the frame rate at 30 fps which my web cam uses & probably the cause of the out-of-sync audio.

It is worth installing the v4l2 test utility just to check the camera properties and as you see for audio it uses alsa

It is worth noting that there is a simpler solution, wxcam, not in the repo, but the debian version does work. Wink

edit: as here  http://i.imgur.com/IrTI9.jpg
Logged
Just18
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 4610


MLUs Forever!


« Reply #27 on: January 26, 2012, 09:40:25 AM »

I have tried ffmpeg too .....  but also got problems with the muxing. Thanks for posting your command.

I am beginning to wonder if I have a problem with buffer size for Alsa and or the Video ......

Your command above won't work here as it is ......  it seems to want stereo/2 channel audio and errors out

Code:
[alsa @ 0x8229d60] cannot set channel count to 2 (Invalid argument)

Adding the -ac 1  option allows it to record.

I get good quality video and good quality audio.

Unfortunately the audio starts well before the video, so is out of sync.

Other than this sync problem all is well.

There appears to be a delay before correct video frames are grabbed .....  the beginning of the saved video is corrupt or such.

If I could get rid of that .......

EDIT
         Played a little with Avidemux ......  passed the saved video from this command

Code:
ffmpeg -f video4linux2 -i /dev/video0 -r 30  -vcodec mpeg4 -b 1000 -qscale 5 -bt 256k -y -f alsa -ac 1 -i hw:2,0  -ar 44100 `date +%s`.avi

through Avidemux introducing a delay of 1490ms gives me an acceptable result.

That stage should not be be necessary of course ......  and is not if I use my script to record audio and video separately and mux them afterwards.

So it is no real improvement unfortunately  Sad
Logged

MLUs rule the roost!

Linux XPS 3.2.17-pclos1.pae.bfs  32 bit
Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech ‎DVB-T 2 USB DTT
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM