We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 3 
Using a dvcam as a web-cam in Linux (Read 13159 times)
Using a dvcam as a web-cam in Linux
May 6th, 2008, 1:10pm
 
Hi

I'm trying to use my dvcam in processing, (firewire using linux).

So far, I've managed to use a utility called dv4l (http://dv4l.berlios.de/) to setup the camera as a webcam in linux.  It works well, and I'm able to view live video in many applications using a special loader, which pipes the video feed as required.  

For example, the following command will allow the dvcam to be used as a webcam in the program 'camorama';

   dv4lstart camorama

So, I put 2+2 together and tried to get processing to work with my cam;

   dv4lstart ./processing

.. only it doesn't work, and the following is output;


#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGBUS (0x7) at pc=0xb790fb0a, pid=17601, tid=3084752560
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_12-b04 mixed mode, sharing)
# Problematic frame:
# V  [libjvm.so+0x313b0a]
#
# An error report file with more information is saved as hs_err_pid17601.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Aborted



To cut the story short - I'm stuck... and was wondering if anyone else has tried the same / had any success / or can offer any tips.

Cheers

Luke
Re: Capturing from a dvcam in linux
Reply #1 - May 6th, 2008, 2:20pm
 
video does not work on linux:
http://processing.org/reference/libraries/video/
Re: Capturing from a dvcam in linux
Reply #2 - May 6th, 2008, 2:27pm
 
hi, thanks for the reply - I'm going to be using a library called GSvideo, which I believe is supported in linux.
Re: Capturing from a dvcam in linux
Reply #3 - May 6th, 2008, 11:58pm
 
As I mentioned before, I'm trying to use my digital camcorder as a webcam with processing(+GSvideo), in linux.

I'm stuck, and not really sure how to progress, so I thought I'd spell out my experience so far - in case anyone has any ideas or wants info on achieving the same.

There's a utility called dv4l(http://dv4l.berlios.de/) which can be used to create an interface between the dvcam and video4linux (v4l).

dv4l can can be used in two different ways;

1. via a utility called 'dv4lstart'
2. via a utility called 'dv4l' + a module called 'vloopback' (http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice )



Method 1;
---------

This should be the simplest route...

run 'dv4lstart ./processing'  

The idea here is to use dv4lstart to create a v4l device at '/dev/video0'; and then load processing, allowing it to make use of the new device.  In theory, the camera negotiations should be invisible to processing (and GSvideo) and all should work well... but, I get an error when I run the command..

# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGBUS (0x7) at pc=0xb78b0b0a, pid=15828, tid=3084363440
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_12-b04 mixed mode, sharing)
# Problematic frame:
# V  [libjvm.so+0x313b0a]
#
# An error report file with more information is saved as hs_err_pid15828.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp

.. so I've had to abandon this idea.  I've successfully managed to load other programs (vlc and camorama) using dv4lstart... so the problem is something specific to processing and/or java.



Method 2;
---------

This route's a little more complicated.  I've divided it into two attempts

ATTEMPT 1;

i) load vloopback by running 'sudo modprobe vloopback'
This will create two devices at /dev/video0 and /dev/video1.  The first is used for video input and the second is used for video output.

ii) run 'dv4l'
This command streams the video from the camcorder (which will then be accessible using v4l at '/dev/video1').  

At this point I thought I was onto something, but I still had a problem ... I need the video to be accessible at '/dev/video0' NOT '/dev/video1'.  After hours of hopelessness, I found that vloopback can take a parameter;

ATTEMPT 2;

i)run 'sudo modprobe vloopback dev_offset=1'
This will create two devices at /dev/video1 and /dev/video2 (crucially, leaving '/dev/video0' unused).  

ii)run 'dv4l'
This is just the same as before .. only now the v4l device will be '/dev/video2'.  
I assumed that I would then be able to finish off the bastard, with a symbolic link;

iii)'sudo ln -s /dev/video2 /dev/video0

Now, I'm no linux expert at all, and all of what I know is cobbled together.. but I believed that this should have worked - and I'm confused to why it hasn't.  If you've read to this point, thanks for baring with me.

Any ideas would be amazing.
Re: Using a dvcam as a web-cam in Linux
Reply #4 - May 7th, 2008, 5:37am
 
I made a new version of the library that allows you to set the input device in linux:

http://codeanticode.wordpress.com/2008/05/07/gsvideo-setting-parameters-of-the-capture-object/

Let me know if it works.
Re: Using a dvcam as a web-cam in Linux
Reply #5 - May 7th, 2008, 1:43pm
 
Hi

I've tried out a couple of the examples (my v4l device is '/dev/video1')

eg.  in Mirror, I swapped..

Code:

video = new GSCapture(this, width, height, 12);


for..

Code:

video = new GSCapture(this, width, height, new String[] {"device"}, new String[] {"/dev/video1"});


Unfortunately I get a blank screen...  am I using the updated code in the right way?
Re: Using a dvcam as a web-cam in Linux
Reply #6 - May 7th, 2008, 5:21pm
 
If dv4l is interfacing with v4l (and not v4l2, which is the default used by gsvideo), then the following might work:

Code:

video = new GSCapture(this, width, height, "v4lsrc", new String[] {"device"}, new String[] {"/dev/video1"});

Re: Using a dvcam as a web-cam in Linux
Reply #7 - May 7th, 2008, 5:59pm
 
dv4l does use v4l (rather than v4l2)...
I tried the modified code - but no luck... does gsvideo require a particular type of stream?  yuv / rgb ..??
Re: Using a dvcam as a web-cam in Linux
Reply #8 - May 7th, 2008, 6:08pm
 
mmm, not sure at this point what the problem could be.

Did you try creating a pipeline manually with gst-launch, to see if you can get the image from the camera?

If that works, I don't see why gsvideo is not picking the capture from video1...
Re: Using a dvcam as a web-cam in Linux
Reply #9 - May 7th, 2008, 6:49pm
 
I didn't know about gst-launch... I now know that the problem is definitely with gstreamer.

----

I pretty much know that dv4l is doing _something_ because videolan is playing the stream produced at /dev/video1, without any problem...

Running..
Code:

gst-launch --gst-debug-level=0 v4lsrc device=/dev/video1


produces..
Code:

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /pipeline0/v4lsrc0: Could not negotiate format
Additional debug info:
gstbasesrc.c(2359): gst_base_src_start (): /pipeline0/v4lsrc0:
Check your filtered caps, if any
Setting pipeline to NULL ...
FREEING pipeline ...


So maybe I need to parse some more parameters to gstreamer to solve the Code:
ERROR: from element /pipeline0/v4lsrc0: Could not negotiate format 

error??

If I work out what's required to get gstreamer working with dv4l, I'll post the results here

cheers

luke
Re: Using a dvcam as a web-cam in Linux
Reply #10 - May 10th, 2008, 12:27pm
 
I haven't been able to get the camcorder to work with v4l + gstreamer.  However I have managed to get gstreamer working using the following command:

Code:

gst-launch dv1394src ! queue ! dvdemux ! ffdec_dvvideo ! ffmpegcolorspace ! video/x-raw-yuv, width=720 ! xvimagesink


Is there any way that this pipe could be used with gsvideo?
Re: Using a dvcam as a web-cam in Linux
Reply #11 - May 10th, 2008, 6:47pm
 
Yes, that pipe can certainly be created inside gsvideo.

I'm just thinking of a general way to do it. Perhaps I could add a new class called GSCustom or something like that where you can specify any pipeline you want, and gsvideo will create it. For example:

String pipe[] = { "dv1394src",  "queue", "dvdemux" "ffdec_dvvideo", "ffmpegcolorspace (video/x-raw-yuv, width=720" };
capture = new GSCustom(pipe);

where the input array contains each element that defines the pipeline (and caps between parenthesis).

Or even simpler:

capture = new GSCustom("dv1394src | queue | dvdemux | ffdec_dvvideo | ffmpegcolorspace video/x-raw-yuv, width=720");

All of this is fairly easy to implement. Internally, gsvideo would add a buffer grabber to direct frames to the processing canvas, instead of using xvimagesink.

What interface you think would be better? Or this possibility of defining custom pipes should be as a part of GSCapture? Personally, I think it would be better if custom pipes are handled by a separate object.
Re: Using a dvcam as a web-cam in Linux
Reply #12 - May 10th, 2008, 8:01pm
 
I think it would be great to have full control on creating custom pipes.

Reading about gstreamer, I found out a bit about filters and they seem like a really simple & powerful way of transforming a video feed.  So, being able to stack them up before using a feed within processing would be great.

I think the second definition seems better - but that's because I'm not very familiar with the syntax for gstreamer (I read something about 'bins' and 'caps', but it all went over my head..)

Thanks for all the work on you're doing on the library - if you need a hand working on documentation or anything like that, let me know and I'll do what I can to help.

Code:

gst-launch dv1394src ! queue ! dvdemux ! ffdec_dvvideo ! videoscale ! video/x-raw-yuv, width=320 ! cairotimeoverlay ! ffmpegcolorspace ! xvimagesink


Re: Using a dvcam as a web-cam in Linux
Reply #13 - May 12th, 2008, 8:21pm
 
Check out this new version of the library:

http://users.design.ucla.edu/~acolubri/processing/gsvideo/gsvideo-lib-customtest.zip

I wrote a little example (Examples/Custom/dv1934src) using the pipeline you are trying out. Let me know how it goes.
Re: Using a dvcam as a web-cam in Linux
Reply #14 - May 13th, 2008, 12:33pm
 
Code:


Creating element dv1394src
Creating element queue
Creating element dvdemux
Creating element ffdec_dvvideo
Creating element ffmpegcolorspace
Creating capsfilter video/x-raw-yuv, width=720
adding dv1394src to pipeline
adding queue to pipeline
linking queue to dv1394src
adding dvdemux to pipeline
linking dvdemux to queue
adding ffdec_dvvideo to pipeline
linking ffdec_dvvideo to dvdemux
adding ffmpegcolorspace to pipeline
linking ffmpegcolorspace to ffdec_dvvideo
adding video/x-raw-yuv, width=720 to pipeline
linking video/x-raw-yuv, width=720 to ffmpegcolorspace
setting caps video/x-raw-yuv, width=720
adding videoSink to pipeline
linking videoSink to video/x-raw-yuv, width=72



I've tried out the new library... but I get a grey screen :/

I did get the following error in the processing console:

Code:

rom1394_0 warning: read failed: 0x0000fffff000040c
send oops
send oops


Is 'rom1394_0' the name of a specific raw1394 device, or a typo?

Just after that, I tried running the example pipe using gst-launch; that produces a video stream.

Is there anything I can try out to narrow down the error?
Pages: 1 2 3