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

Discussion in 'B4J Questions' started by rbirago, May 17, 2018.

  1. rbirago

    rbirago Member Licensed 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?


  2. moster67

    moster67 Expert Licensed User

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

    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
    "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: May 18, 2018
    inakigarm and DonManfred like this.
  3. rbirago

    rbirago Member Licensed 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.
    Harris likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice