B4J Question how to save a webcam video stream in Vlcj?

rbirago

Active Member
Licensed User
Longtime User
Hi, I've tried Vlcj lib to show a webcam stream and it works fine...but how to save the stream on disc using a rec-start/rec-stop button?

thanks

Roberto
 

moster67

Expert
Licensed User
Longtime User
You could try something like this (tested some time ago when I wrote the wrapper):

B4X:
Dim Options() As String
Options = Array As String(":dshow-vdev=Microsoft® LifeCam HD-3000", $":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:file{dst=C:\Users\moste\_test5.mp4,no-overwrite}"$)

Dim jo As JavaObject = vlc1.player
jo.RunMethodjo("getMp",Null).RunMethod("playMedia", Array("dshow://", Options))

Replace "webcam-info" and "sout-string" with your configuration.

Basically, you create a String array for the options.
Then, using JavaObject, you can access an overload method of "playMedia" (which I did not expose in my library) which also takes "mediaOptions" as an argument.

Those options have really nothing to do with vlcj, rather they are VLC streaming/transcoding options so if you have problems, you should look at the VLC documentation.

PS: you may also need to explicitly invoke release() on the media player before your saved file will be ready.

PS2: Probably you want to save the raw stream rather than transcoding it - you need to experiment.
 
Last edited:
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
thanks for the answer. Effectively I was just looking in that direction. Your suggestion confirms that it's the right way. When I'll reach some success I shall inform you.
 
Upvote 0
Top