DV capture for Linux OF Addon

I’ve just finished a new addon for Linux - DV video capture. Unfortunately the Unicap library currently used as video capture for Linux doesn’t yet support DV capture…so this release will hopefully ease that pain for a select few.

This is basically hooking OF to the dvgrab application for recording DV from a camera to hard drive.

I’ve stripped dvgrab of most of the DV recording stuff to make it just a DV frame grabber. It runs on its own thread and performs well. If you are using a PAL camera you should get 720x576 @ 25fps, or 720 x 480 @ 30fps if you have an NTSC camera.
Because the dvgrabber is threaded, your application will run at an independent (and probably much higher) framerate.

However, if you run this addon with the ofUCUtils.cpp file compiled, then you will experience a 5-7 second delay on start up…something in the Unicap library conflicts with the libavc1394 avc1394_check_subunit_type function call used in dvgrab, causing it to sleep mysteriously several times (any ideas Arturo?).

The solution to this is to remove the ofVideoGrabber and ofUCUtils files from your project. You won’t need the ofVideoGrabber because ofDVUtils will be your new grabber. I’ve already done this in the accompanying CodeBlocks project.

When setting up, make sure to put the ofxDVgrab folder in with the rest of the addons.

When you initialise the dvgrabber, you have a choice of 2 different deinterlacing functions…or you can run it without deinterlacing.

There’s still some redundant code in the addon files that I haven’t stripped out, but it should run fine nonetheless.

Additional extras which are missing are things like IEEE 1394 transport control (AV/C) for tape-based grabbing, HDV grabbing support and more interlacing functions…

download the addon at http://www.digitalstar.net/openframeworks/ofxDVgrab.zip

Any bugs, problems…let me know!

oh yeah, and the obligatory mug shot:

nice!

about the issues with unicap, is really strange as ofUCUtils is a class and is not instantiated if you don’t use ofVideoGrabber. I’ll take a look…

Yeah I know…I couldn’t figure it out either. Even using the #define to switch to my old V4L code didn’t help either. Only by making sure the UCUtils object file is not linked into the final binary fixed the problem. I also commented out the ffmpeg conversion stuff from within your code and it wasn’t that either. It’s one of the unicap functions that gets linked in that must be the source of the problems. Maybe libavc1394 is used somewhere in Unicap, and some functions conflict…actually I have no idea really.

Hey pierre

it’s working for me without problem with the unicap files in. I’m using last unicap version 0.9.3, so perhaps is that…

Great! I’m still using the vanilla OF 0.05 release…what unicap version was in that?

don’t remember exactly 0.2.something, but there’s has been many changes since then, indeed they’re going to release 1.0 soon

just tried this in a clean ubuntu install… you will need to install:

apt-get install libiec61883-dev libdv4-dev libavc1394-dev

Yeah, I forgot to mention this stuff…meant to add it but forgot.
Did you test with a camera? Everything worked?

nope, no dv camera since then, was just compiling an app that uses dvgrab in a fresh install

I’ve uploaded a new version of ofxDVgrab:
http://www.digitalstar.net/openframeworks/ofxDVgrab.zip

This fixes an intermittent pause in the dv capture I was getting in ubuntu 8.10 (strangely on 7.04 I wasn’t getting this problem )…solved by moving the interlacing functions out of the dvgrab thread and into the DVUtils class (which is a good thing anyway…the capture thread should not be doing anything other than capturing).

[quote author=“grimus”]I’ve uploaded a new version of ofxDVgrab:
http://www.digitalstar.net/openframeworks/ofxDVgrab.zip

This fixes an intermittent pause in the dv capture I was getting in ubuntu 8.10 (strangely on 7.04 I wasn’t getting this problem )…solved by moving the interlacing functions out of the dvgrab thread and into the DVUtils class (which is a good thing anyway…the capture thread should not be doing anything other than capturing).[/quote]

hi grimus,
first off, thanks for the code, works great with the camcorder i have here on my lappy!

right now, i combined your library with the openCV addon, essentially giving me blob detection on a high rez cam ^_^. there is no problem per say, but i would like to be able to run the openCV demo.

the obvious problem is that open CV displays the output like 6 times, and using the high quality cam means that each box is too big to display six times(in color, b&w, the negative, the new result, the blobs etc). is there a way to scale that pixel array to something more manageable?
maybe a function already exists that does just that.

anyway, thanks again,
r.d.

Hi,
sorry for the slow reply I didn’t see your post…

A quick solution to your problem would be to create a temporary ofxCvColorImage of the same size as the DV pixel array and then resize it using ofxCvColorImage::resize( int w, int h ). This would be less expensive than sending the full sized image to the blob detector.

I could possibly add a resize function to the DV grabber, although this would involve a small performance hit for non-DV resolutions due to the software scaling.

hi Pierre
I am trying to install you addon but I got some compilation - linking errors
I am using ubuntu 9.04 and I installed
libiec61883-dev libdv4-dev libavc1394-dev
us arturo mention before in this post
but when I tried to run the example that you put in the second version of the DVGrab I got this error in codeblocks

…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|9|error: gst/gst.h: No such file or directory|
/home/diediaga/of_preRelease_v0.06_linux_cb_FAT/addons/ofxDVgrab/ofxDVgrabExample/src/testApp.h|6|error: ofDVUtils.h: No such file or directory|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|13|error: ISO C++ forbids declaration of ‘GMainLoop’ with no type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|13|error: expected ‘;’ before ‘*’ token|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|14|error: ISO C++ forbids declaration of ‘GstElement’ with no type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|14|error: expected ‘;’ before ‘*’ token|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|19|error: ‘guint64’ does not name a type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|20|error: ‘guint64’ does not name a type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|130|error: ISO C++ forbids declaration of ‘GstElement’ with no type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|130|error: expected ‘;’ before ‘*’ token|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|131|error: ISO C++ forbids declaration of ‘GstElement’ with no type|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|131|error: expected ‘;’ before ‘*’ token|
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|132|error: ‘gint64’ does not name a type|
/home/diediaga/of_preRelease_v0.06_linux_cb_FAT/addons/ofxDVgrab/ofxDVgrabExample/src/testApp.h|28|error: ‘ofDVUtils’ does not name a type|
||=== Build finished: 14 errors, 0 warnings ===|

could you please take a look

thanks
diego

sorry I forgot to mention that I am usin OF 0.06
thanks
diego

Hey Diego!

Looks like you need to add the ofDVUtils.h to your project. If you have already added, make sure that the include path is correctly set.

Also the other errors are related to the ofVideoPlayer - looks like you need to install Gstreamer. Have you run Arturo’s ubuntu dependency script? Check that all the dependencies were installed correctly…

hi
thanks so much Pierre for your fast resplay!!!
I solvent the first problem. the included path was bad linked
about the second problem, the one related with ofVideoPlayer,
…/…/…/libs/openFrameworks/video/ofVideoPlayer.h|9|error: gst/gst.h: No such file or directory|

Yes I run the arturo’s script (again) and I got this output

./install_dependencies.sh
[sudo] password for diediaga:
Reading package lists… Done
Building dependency tree
Reading state information… Done
libgstreamer0.10-dev is already the newest version.
libgstreamer-plugins-base0.10-dev is already the newest version.
libavcodec-dev is already the newest version.
libavformat-dev is already the newest version.
libavutil-dev is already the newest version.
libswscale-dev is already the newest version.
freeglut3-dev is already the newest version.
libasound2-dev is already the newest version.
libxmu-dev is already the newest version.
libxxf86vm-dev is already the newest version.
g++ is already the newest version.
libgl1-mesa-dev is already the newest version.
libglu1-mesa-dev is already the newest version.
libraw1394-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

it looks that gstreamer is already there…

any idea?

OK that means that Gstreamer is probably installed but can’t be found.

Can you try the following:

  
  
sudo updatedb  
  

and then

  
locate gst.h  

and see what this gives.
On 8.04 I have it at /usr/include/gstreamer-0.10/gst/gst.h
Maybe even logout and login again to make sure all settings have been properly applied.

If this fails, locate the gst file and point to its path manually in the codeblocks search paths…but you shouldn’t have to do this.

hi
I solvent the problem with the gstreamer.
what I did is to add in the project/property/libraries used in project the gstreamer
now I can build without problem (apparently)
when I click in Run I message appear saying that the project has not been build jet, so I click yes and I build the project again
and them I got this output
it looks that there is a linking problem.
do you have idea?
thanks
diego

-------------- Build: Debug in ofxDVGrabExample ---------------

WARNING: Can’t read file’s timestamp: /home/diediaga/of_preRelease_v0.06_linux_cb_FAT/libs/openFrameworks/events/ofAppEvents.cpp
WARNING: Can’t read file’s timestamp: /home/diediaga/of_preRelease_v0.06_linux_cb_FAT/libs/openFrameworks/events/ofAudioEvents.cpp
WARNING: Can’t read file’s timestamp: /home/diediaga/of_preRelease_v0.06_linux_cb_FAT/libs/openFrameworks/events/ofKeyEvents.cpp
WARNING: Can’t read file’s timestamp: /home/diediaga/of_preRelease_v0.06_linux_cb_FAT/libs/openFrameworks/events/ofMouseEvents.cpp
Linking console executable: bin/ofxDVGrabExample_debug
g++: obj/Debug/libs/openFrameworks/events/ofAppEvents.o: No such file or directory
g++: obj/Debug/libs/openFrameworks/events/ofAudioEvents.o: No such file or directory
g++: obj/Debug/libs/openFrameworks/events/ofKeyEvents.o: No such file or directory
g++: obj/Debug/libs/openFrameworks/events/ofMouseEvents.o: No such file or directory
g++: …/…/…/libs/fobs/lib/libfobscore.a: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

it seems you’re trying to compile some old project with 006, that files: ofAppEvents, ofMouseEvents… were in 0.57xxx but doesn’t exist anymore.

try copying one of the examples in 006 and overwriting testApp.h, testApp.cpp… with your own code.

HI arturo
yes, I did (copy from another addons example of version 06 and change the cpp and h files), now it is working.
the only problem I got is the libraries, I also have to add the libraries to the project.

thanks so much for your help.
diego