Closed hassanyawar closed 4 months ago
The repo currently doesn't support live videos out of the box. Live videos are in the m3u8 format, which the default video player doesn't recognize.
Understood. Thank you for reply. Can you point to some kind of direction that if one has to achieve rendering of YouTube live streaming in Unity, what should be the starting point to it?
So as I said, Live videos are in the m3u8 format, which the default video player doesn't recognize.
The YoutubePlayer
can return a link to the m3u8, e.g.
var url = await youtubePlayer.GetRawVideoUrlAsync("https://www.youtube.com/watch?v=VIDEO_ID");
// returned url is a string in the format "https://www.something.com/path/to/some/file.m3u8"
But then you might need to parse it, or use another tool to parse it and play the video.
m3u8 file is essentially a text file with links to the pieces of the live video. There are a couple of asset store tools (I heard that AVPro, or EasyMovieTexture can do that) but I can't vouch for them, as I have not tried these.
Hi, I tried your approach. This is the live stream I was trying to work on. Using your code I was able to get a url ending with "...index.m3u8". Its complete form is like this:
https://manifest.googlevideo.com/api/manifest/hls_variant/expire/1619185177/ei/uXmCYOP4CITv1gbckqHQCw/ip/2400%3Aadc5%3A123%3Aff00%3Aa409%3A10f2%3Afc38%3A1d1a/id/epsGPMoXRA0.1/source/yt_live_broadcast/requiressl/yes/tx/23964900/txs/23964900%2C23964901%2C23964902%2C23964903%2C23964904%2C23964907/hfr/1/playlist_duration/30/manifest_duration/30/maudio/1/vprv/1/go/1/nvgoi/1/keepalive/yes/fexp/24001373%2C24007246/dover/11/itag/0/playlist_type/DVR/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Ctx%2Ctxs%2Chfr%2Cplaylist_duration%2Cmanifest_duration%2Cmaudio%2Cvprv%2Cgo%2Citag%2Cplaylist_type/sig/AOq0QJ8wRQIhAKVpdNgDSKN09ZwDPZ5nuGKGWFla66UAV_hhuzFoMAYEAiB9BWmnjo6LtcCPf1FQci04m5Otvuizdhc84S81jC2I-w%3D%3D/file/index.m3u8
This is the string which I received. I also even managed to use EasyMovieTexture for testing. When I pass this URL in it, I get the message: No video tracks found in ...<URL Above>
. I even tried this url in some of the online m3u8 players. None of them can play this live stream.
Any thoughts?
Try opening that url in vlc. You will see it has the right streams.
Hi, I tried your approach. This is the live stream I was trying to work on. Using your code I was able to get a url ending with "...index.m3u8". Its complete form is like this:
https://manifest.googlevideo.com/api/manifest/hls_variant/expire/1619185177/ei/uXmCYOP4CITv1gbckqHQCw/ip/2400%3Aadc5%3A123%3Aff00%3Aa409%3A10f2%3Afc38%3A1d1a/id/epsGPMoXRA0.1/source/yt_live_broadcast/requiressl/yes/tx/23964900/txs/23964900%2C23964901%2C23964902%2C23964903%2C23964904%2C23964907/hfr/1/playlist_duration/30/manifest_duration/30/maudio/1/vprv/1/go/1/nvgoi/1/keepalive/yes/fexp/24001373%2C24007246/dover/11/itag/0/playlist_type/DVR/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Ctx%2Ctxs%2Chfr%2Cplaylist_duration%2Cmanifest_duration%2Cmaudio%2Cvprv%2Cgo%2Citag%2Cplaylist_type/sig/AOq0QJ8wRQIhAKVpdNgDSKN09ZwDPZ5nuGKGWFla66UAV_hhuzFoMAYEAiB9BWmnjo6LtcCPf1FQci04m5Otvuizdhc84S81jC2I-w%3D%3D/file/index.m3u8
This is the string which I received. I also even managed to use EasyMovieTexture for testing. When I pass this URL in it, I get the message:
No video tracks found in ...<URL Above>
. I even tried this url in some of the online m3u8 players. None of them can play this live stream.Any thoughts?
If you have not been able to get it working, I have a messy workaround that is functional. Also, if you cannot compile the vlc for unity yourself because it has a million dependencies and is seemingly impossible to do, the compiled version in the asset store works well. I have not tried to get the m3u8 stream into vlc yet. It sounds interesting and possibly a way around this.
Anyway, instead of passing the live stream directly in the setup, I set up an rtsp output from obs. Then I use vlc to stream the rtsp feed. This also opens up the ability to use any rtsp feed you can generate. Directly from a phone using an app that can send video and audio for live broadcasting into the scene. This works for my needs but may be too much for what you need.
I never followed up on this thread. In last conversation, you told me that live stream video has m3u8 format. I was able to feed that url in AV Pro for Unity. I managed to make live stream work.
However, I thought to do the same process again recently using your plugin and AV Pro. One thing I noticed is that normal YouTube videos raw url is being extracted fine but live stream raw url extraction is giving an error now. It wasn't happening before.
By the way, previously I was using Unity 2019.4 LTS but now I'm using Unity 2020.3.12f1. This is the error what I'm getting:
JsonReaderException: Input string '15.0' is not a valid integer. Path 'formats[0].fps', line 1, position 11287. Newtonsoft.Json.JsonTextReader.ParseReadNumber
and originating from
Library/PackageCache/com.ibicha.youtube-player@1.6.0/Runtime/YoutubeDl/LocalYoutubeDl.cs:36)
Hello, Any solution to play a live video in unity?
Closing - this will not be possible until the Unity video player start supporting HLS videos The feature is still under consideration https://forum.unity.com/threads/unity-video-player-hls-support.581719/#post-9127138
It plays normal videos like a charm but when I gave a url for a live YouTube video then I received an error something like "No video tracks found in ...".
Am I doing something wrong or does it not supports live video at this stage?