Search Unity

[400usd] UVLC (Android, ios and windows standalone)

Discussion in 'Assets and Asset Store' started by arklay_corp, Nov 25, 2016.

  1. jasonbeakr

    jasonbeakr

    Joined:
    Aug 7, 2017
    Posts:
    1
    Hi @arklay_corp

    I'm working on a project that requires low latency video playback using unity. I came across the UVLC asset in the store and I have a few questions.

    -Does UVLC have all the options that can be found in the standalone VLC player under Preferences -> Input/Codecs -> Show All?
    -Can you set x264 codec options like in the standalone VLC player?
    -Can you set skip the loop filter for H.264 decoding?
    -Can you adjust the buffer/cache? (stuff like the File cache, Live capture cache, Disc caching, and Network caching)
     
  2. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi Jason,

    Sorry for the delay, I'm on holidays right now and I don't check the forums so often.

    About your questions, uvlc is an improved wrapper around libvlc for unity, to find out if it meets your needs I would check:
    - the official vlc for the platform you are targeting, anything you can tweak there, can be tweaked in vlc
    - libvlc documents (for version 3.0.0), the official vlc release doesn't cover all of libvlc functionality. For example you can setup handlers to manage a lot of things from the audio processing to http downloading and cache managing

    Uvlc doesn't implement the whole range of functions provided by libvlc but it can be easily expanded by just getting the method signature from the libvlc documentation and implement it on the c# code base following already implemented methods.

    Sorry I cannot help you further but your needs are pretty specific and I didn't dipped that deep into libvlc
     
  3. FabrizioFilizola

    FabrizioFilizola

    Joined:
    May 4, 2017
    Posts:
    2
    Hi,

    I have an issue with this plugin.

    Using the new version of Unity (2017.0.1f3) on Windows10/64bit, UVlc (v 2.6) freezes the editor.

    This problem seems be related to the .NET framework used.
    In fact if I use an older version of Unity (ie 5.6.x) or if I use the current one (2017.0.1f3) but setting up:
    • Scripting Runtime Version: stable .NET 3.5 Equivalent
    • Api Compatibility level: .NET 2.0 Subset (also with no subset)
    the freeze doesn't come!

    Only when I set up, with Unity (2017.0.1f3), mono to .net 4.6 equivalent and Api Compatibility Level to .NET 4.6 I have this behavior:
    1. open an example scene and set the vlc url to a rstp stream (http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4)
    2. play the editor and run the application
    3. make stuffs like, play, pause or also nothing
    4. stop the editor
    5. then when I go to play again the editor I have a freeeze of unity editor and I must to kill unity process
    PS: if I make a bundle and I run the exe I have no freeze or problems. Anyway this problem is too stressing during the development.

    Can you help me?

    Regards,
    thanks in advance
     
  4. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi Matteo,

    It seems to be a small issue with the new net 4.6 version

    I'm on holidays right now and I cannot check it on detail, do you need the net 4.6 features? I will get this fixed but it might take a couple of weeks
     
  5. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    I am considering develop a video conferencing app using your UVLC plugin. Does your plugin support the following features? (I have checked that VLC player 2.2.6 in windows support these features)

    1) Stream video file or camera to network (act as rtsp/rtp/mms/http streaming server)

    2) Play video from memory buffer or MemoryStream (i.e. imem input support)
     
  6. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Yeah you can do both: you can stream video from network or camera and play video from memory (in this case you just need to implement an interface to feed the player)
     
  7. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    Thanks for reply. Regarding point 2), does that mean the plugin already has C# interface for the imem access module, and I just need to implement the delegates (the equivalent of imem-get, imem-release callbacks in C) defined in the interface?
     
  8. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    sorry, (im on holidays and i was speaking from memory, now im checking the actual code).

    is not an interface what you should implement but a few callbacks.

    basically you call the function:
    Code (CSharp):
    1. public static extern IntPtr libvlc_media_new_callbacks(
    2.                                        IntPtr instance,
    3.                                        [MarshalAs(UnmanagedType.FunctionPtr)]libvlc_media_open_cb open_cb,
    4.                                        [MarshalAs(UnmanagedType.FunctionPtr)]libvlc_media_read_cb read_cb,
    5.                                        [MarshalAs(UnmanagedType.FunctionPtr)]libvlc_media_seek_cb seek_cb,
    6.                                        [MarshalAs(UnmanagedType.FunctionPtr)]libvlc_media_close_cb close_cb,
    7.                                        IntPtr opaque);
    To set the needed callbacks... just keep in mind is quite tricky, but it is doable (i implemented my own custom downloader using it)

    You can find more info here:
    https://www.videolan.org/developers...media.html#ga591c3cbe56444f1949165b2b9b75d8e2
     
  9. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    Thanks but it seems difficult to me since I am not familiar with C interops in C#. Does your plugin include sample code on how to use libvlc_media_new_callbacks, or would you mind share the C# code snippet using that api since you have implemented once?
     
  10. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    In this case, the interop features are already implemented, you just need to invoke libvlc_media_new_callbacks (swhich is already a C# method) and pass the required functions (again their signatures are defined in c#as delegater named libvlc_media_open_cb, libvlc_media_read_cb, libvlc_media_seek_cb and libvlc_media_close_cb)
     
  11. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    I have bought the plugin (with my work unity account) and tinker with it but I am still not able to use the callback media for playback.

    The attached file contain a simple scene which has a input field for entering file path. When clicked the play as file button it will load the file in movieUrl, while the play as callback button will use my callback media implementation (which just open a FileStream of the file and read the content into the buffer).
    The play as file function worked fine but the play as callback function will freeze the program.

    The output_log file shows that vlc have called my open_cb and read_cb but not the close_cb.

    Can you check what is going wrong as I have no idea about it.

    Below are the changes I have made to the VlcPlayer class to support callback media:

    I have added a new method to the VlcPlayer class to setup a callback media (Assets/VlcPlayerCustomMedia.cs file in the attached file),

    and make some changes the VlcPlayer.SetupMedia() method in Assets/Arklay/U3D/VlcUnity/Implementation/VlcPlayer_Setup_Cleanup.cs so that it will use the callback media when the vlc player gameobject is enabled.
    Code (CSharp):
    1.  
    2.         private void SetupMedia()
    3.         {
    4.             if (callbackMedia == null) {
    5.                 m_media = libvlc.libvlc_media_new_location (m_vlc, movieUrl.Replace (" ", "%20"));
    6.             } else {
    7.                 m_media = libvlc.libvlc_media_new_callbacks (
    8.                     m_vlc,
    9.                     callbackMedia.open_cb,
    10.                     callbackMedia.read_cb,
    11.                     callbackMedia.seek_cb,
    12.                     callbackMedia.close_cb,
    13.                     callbackMedia.opaque
    14.                 );
    15.             }
    16.  
    17.             libvlc.libvlc_media_add_option(m_media, "no-videotoolbox-zero-copy");
    18.  
    19.             // remaining code skipped...
    20.  
    21.         }
    22.  
     

    Attached Files:

  12. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    You don't keep your filestream object so garbage collector can decide to close it before the close callback is called so it might be invalid.

    I would suggest to use the opaque data just as a reference to the filestream: on open save the filestream into a dictionary<int, Filestream> and return the integer as the opaque data. Then use that opaque data to find the actual Filestream you need.

    Even if you wont support seeking, is better to implement the seek callback, VLC will try to read the beggining and the end of the file to be able to start playing faster.
     
  13. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    I tried your suggestion but it is still not working. I even tried read the whole mp4 file into a byte array beforehand (read_cb just copy content from byte[] to IntPtr) but the vlcplayer still not able to play the video (I can confirm open, read and seek callback are called).

    Have you successfully played any media using the callback method? I would like to check with some working code to understand why my code does not work.

    I am using Unity 5.6.0 if that matter.
     
  14. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
  15. achan_

    achan_

    Joined:
    Aug 14, 2017
    Posts:
    6
    It looks like my code uploaded in the previous post is correct. Yesterday I updated Unity to 5.6.3 and the same code can play the movie using the media callbacks.

    Thanks for @arklay_corp's support especially for pointing out which callbacks are required.
     
  16. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Thanks achan_, just so you know, implementing those callbacks is quite tricky... good luck :)
     
  17. mpalazzo

    mpalazzo

    Joined:
    Oct 17, 2017
    Posts:
    1
    Does it work in the HoloLens? Does it support rstp:// ?
     
  18. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    It does support rstp and UWP (there are some post about it) I dont have a HoloLens to try myself but it should work
     
  19. icyAce89

    icyAce89

    Joined:
    Aug 31, 2017
    Posts:
    2
    upload_2017-10-25_20-18-15.png Hello, It will report this error in a standalone(64bit Windows10 Builded by Unity2017), anyone give some help, thanks
     
  20. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi @icyAce89 ,

    Does it work inside the editor?
    Did you build it using unity's build menu or the custom pipeline (Tools/Build system)? You need to use the custom build system to get all the needed dll's copied (or copy them manually)
     
  21. icyAce89

    icyAce89

    Joined:
    Aug 31, 2017
    Posts:
    2
    Thanks, it works~
     
  22. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    :)
     
  23. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @arklay_corp hello, Support video Network Sync? thanks!

     
  24. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    hi @LostPanda

    Sorry, but I have to say that I have no idea! I was trying to try but i dont know how to configure libvlc for that.
     
  25. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    ok thanks
     
  26. mbrzechwa

    mbrzechwa

    Joined:
    Jun 3, 2017
    Posts:
    5
    @arklay_corp
    HI, I just purchased your plugin and got it running in my own scene. 2 things:

    1. Your readme didn't say anything about needing to setup a game object with your dispatcher script.

    2. Is there some way to deal with videos being flipped both vertically and horizontally? Every video I load is displaying upside down and backwards. I have no control over the encoding of the videos.
     
  27. mbrzechwa

    mbrzechwa

    Joined:
    Jun 3, 2017
    Posts:
    5
    correction: The video is only flipped vertically.
    Is there a way to detect this so I can invert the transform to compensate?
    The videos play correctly in the stand-alone VLC player.
     
  28. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    you can just invert the texture's UV coordinates
     
  29. mbrzechwa

    mbrzechwa

    Joined:
    Jun 3, 2017
    Posts:
    5
    @arklay_corp I know how to correct the inverted video I want to know if there is a way to detect that the video is inverted. I don't want to flip all videos in case some render correctly.
     
  30. ivaylopg

    ivaylopg

    Joined:
    Dec 17, 2015
    Posts:
    2
    Hi @arklay_corp

    Is it possible to use this asset to stream a unity camera view (for example using a render texture) from one unity application to another over a local network?
     
  31. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Im pretty sure the inverted video happens on the source, here there are a lot of streams: http://streams.videolan.org/streams/ if you can give me your source i can test it
     
  32. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Yes, it's possible, but is exactly the opposite porpouse of vlc, I suggest you take a look to ffmpeg and how to integrate it with unity. I have a plugin that can fits you as a starting porint:
    https://www.assetstore.unity3d.com/#!/content/63708
    But the whole solution is very complicated and far from the scope of that plugin
     
  33. wangxiaotian_hi

    wangxiaotian_hi

    Joined:
    Aug 16, 2017
    Posts:
    1
    hello i want to buy this plugin & i need ask some question to confirm it whether meet the needs or not.

    1. does this plugin support uwp platform . if it support, does this plugin use vlc to play not just win10 sdk to decode media file?
    2. this plugin's native code (just like your modified vlc's c++ code & c++ dll interactive with c# code) could share if we buy, or additional cost to buy it?
    3. is there contain ffmpeg or not?
     
  34. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi:
    1) yep, it does
    2) he native code is an unmodified libvlc 3.0.0, its source code is available for free on their website (a compiled version is included in the plugin to make your life easier)
    3) no, there is no need for ffmpeg
     
  35. AndreasScholl

    AndreasScholl

    Joined:
    Oct 16, 2015
    Posts:
    12
    @arklay_corp

    I have a question regarding the performance on android devices. We are already using VLC for android to stream videos (udp-streams) in our application. The implementation is using the vlc output to memory. In a native renderplugin we copy the picture from memory to the unity created texture2d. However this is slow on many android devices. Did you use a different (faster) approach for your android implementation (i.e. using native surface views or similar)?
     
  36. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    Hi @AndreasScholl

    To support low end devices or high resolutions on android you need to copy the native surface natively, implementing it on C++ on the render thread

    This part is not included in the asset, but is easy to find examples online
     
  37. karbasi

    karbasi

    Joined:
    May 27, 2016
    Posts:
    2
    Hi there, DO you support .flv on android ?
     
  38. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    yes, flv container is supported
     
  39. djmario

    djmario

    Joined:
    Feb 17, 2017
    Posts:
    4
    I have an idea and want to make video streaming using RTMP
    I have reached UVLC but didn't know it can support this protocol or not

    please help to give me an advice

    Many thanks
     
  40. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    rtmp is supported (it is supported by libvlc directly)
     
  41. djmario

    djmario

    Joined:
    Feb 17, 2017
    Posts:
    4
    many thanks for quickly response

    but please help to confirm more about support RTMP for mobile (Android/IOs) platforms

    Thanks
     
  42. arklay_corp

    arklay_corp

    Joined:
    Apr 23, 2014
    Posts:
    242
    it does, you might need to implement the frame copying in a native plugin to make it smoother