Videotexture Video4Linux2

Game Engine, Players & Web Plug-in, Virtual Reality, support for other engines

Moderators: jesterKing, stiv

darkshine
Posts: 2
Joined: Wed Sep 28, 2011 11:54 am

Videotexture Video4Linux2

Postby darkshine » Wed Sep 28, 2011 12:11 pm

Hi People,

im working right now the first time with VideoTextures in Blender.
I have right now a little problem, I know that my webcam is a Video4Linux2 Device - is it possible that it can work with the actual Blender Version?

I saw this post -> http://www.blender.org/forum/viewtopic. ... hlight=v4l and I thought - maybe there is already a solution for this? (Because the post is from 2008).


This is the Code that i use - is there something wrong?

Code: Select all

import GameLogic as G
import VideoTexture as VT

def init_world():
   cont = G.getCurrentController()
   obj = cont.owner

   matID = VT.materialID(obj, 'MAvideo')
   G.video = VT.Texture(obj, matID)

   S1 = G.expandPath("/dev/video0")
   video_source = VT.VideoFFmpeg(S1, 1, 25.0, 320, 240)
   video_source.repeat = -1
   video_source.scale = True
   #video_source.flip = False
   #video_source.deinterlace = True

   G.video.source = video_source
   G.video.source.play()
   
   #sound = cont.actuators["a_sound"]
   #cont.activate(sound)

   #G.sound = sound

def update():
   G.video.refresh(True)


Thank you for your help :)

darkshine
Posts: 2
Joined: Wed Sep 28, 2011 11:54 am

Re: Videotexture Video4Linux2

Postby darkshine » Wed Sep 28, 2011 5:07 pm

darkshine wrote:Hi People,

im working right now the first time with VideoTextures in Blender.
I have right now a little problem, I know that my webcam is a Video4Linux2 Device - is it possible that it can work with the actual Blender Version?

I saw this post -> http://www.blender.org/forum/viewtopic. ... hlight=v4l and I thought - maybe there is already a solution for this? (Because the post is from 2008).


This is the Code that i use - is there something wrong?

Code: Select all

import GameLogic as G
import VideoTexture as VT

def init_world():
   cont = G.getCurrentController()
   obj = cont.owner

   matID = VT.materialID(obj, 'MAvideo')
   G.video = VT.Texture(obj, matID)

   S1 = G.expandPath("/dev/video0")
   video_source = VT.VideoFFmpeg(S1, 1, 25.0, 320, 240)
   video_source.repeat = -1
   video_source.scale = True
   #video_source.flip = False
   #video_source.deinterlace = True

   G.video.source = video_source
   G.video.source.play()
   
   #sound = cont.actuators["a_sound"]
   #cont.activate(sound)

   #G.sound = sound

def update():
   G.video.refresh(True)


Thank you for your help :)


Ok I found a solution :D
I changed in /source/gameengine/VideoTexture.cpp Line: 623

Code: Select all

inputFormat = av_find_input_format("video4linux");


to

Code: Select all

inputFormat = av_find_input_format("video4linux2");


I hope it helps someone :)

Thillbucci
Posts: 6
Joined: Thu Nov 24, 2011 2:13 pm

Postby Thillbucci » Mon Jan 02, 2012 1:18 am

Thanks for this hint Darkshine!

In Blender Version 2.6 this change has to be made in file /source/gameengine/VideoTexture/VideoFFmpeg.cpp Line: 625

Unfortunately it's not working for me on a Mac to access the stream of the iSight camera, but this may have other reasons...

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Mon Jan 02, 2012 2:47 am

S1 = G.expandPath("/dev/video0")


Pardon my ignorance on the subject, but is that the name of the video device under OSX?

Thillbucci
Posts: 6
Joined: Thu Nov 24, 2011 2:13 pm

Postby Thillbucci » Mon Jan 02, 2012 1:23 pm

stiv wrote:Pardon my ignorance on the subject, but is that the name of the video device under OSX?


Unfortunately not and it seems none too easy to grab a camera stream on OSX this way (http://stackoverflow.com/questions/6557655/mac-webcam-get-the-device)

I'm trying to use OpenCV now... Or is there anybody who knows another solution?

Maybe I should open a new thread for further questions regarding to video-streams on OSX :?

sphaero
Posts: 17
Joined: Tue Feb 28, 2012 3:19 pm

Postby sphaero » Tue Feb 28, 2012 3:22 pm

Thillbucci wrote:
stiv wrote:I'm trying to use OpenCV now... Or is there anybody who knows another solution?

Maybe I should open a new thread for further questions regarding to video-streams on OSX :?


Just to confirm: FFmpeg does not support video capturing on OSX currently.

Rg,

Arnaud

sphaero
Posts: 17
Joined: Tue Feb 28, 2012 3:19 pm

Postby sphaero » Mon Apr 02, 2012 2:06 pm

Just to note I've suggested a patch for BGE to incorporate an extra parameter to set the format. This fixes the hardcoded video4linux problem.

http://projects.blender.org/tracker/ind ... 9&atid=127

My suggestion to get OSX capture support is to add a VideoGstreamer module like the VideoFFMpeg. Just not my cup of tea yet as I'm just staryting to get into the source :S

Rg,

Arnaud

ldo
Posts: 544
Joined: Sun Nov 07, 2010 11:30 pm
Location: Hamilton, New Zealand

Postby ldo » Tue Apr 03, 2012 12:26 am

Things like this used to be done on the Mac through QuickTime APIs—you had the low-level video-capture “components” that knew about specific hardware, and the higher-level sequence-grabber on top of that, that kind of thing.

Does that not work any more?

offtools
Posts: 3
Joined: Thu May 03, 2012 11:49 pm

Re: patch

Postby offtools » Thu May 10, 2012 5:22 am

sphaero wrote:Just to note I've suggested a patch for BGE to incorporate an extra parameter to set the format. This fixes the hardcoded video4linux problem.

http://projects.blender.org/tracker/ind ... 9&atid=127

My suggestion to get OSX capture support is to add a VideoGstreamer module like the VideoFFMpeg. Just not my cup of tea yet as I'm just staryting to get into the source :S

Rg,

Arnaud


The patch opens some new possibilities. x11grab works with it, which is a cool thing. Unfortunately my easycap dc60 usb capture device still doesnt work in the bge. av_open_input_file fails. The problem is the deprecated api code, which is still used. Who maintains the VideoFFmpeg Code. I've started to add some changes too, but I can test only on Linux.

offtools
Posts: 3
Joined: Thu May 03, 2012 11:49 pm

gstreamer

Postby offtools » Thu May 10, 2012 5:24 am

Yes and Gstreamer would be awesome :)


Return to “Interactive 3d”

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests