Video resolution for live YouTube stream

This forum is about all development around libVLC.
leftwing
New Cone
New Cone
Posts: 9
Joined: 03 May 2017 01:51

Video resolution for live YouTube stream

Postby leftwing » 06 Jan 2018 19:02

I have used information from the forum to write a C++ app that displays live YouTube streams. For every live YouTube URL I've tried to use, I always receive 256x144 video but I know other resolutions are available. Here is output from youtube-dl that shows 6 available resolutions for the popular NASA live channel.

$ youtube-dl -F RtU_mdL2vBM -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-F', u'RtU_mdL2vBM', u'-v']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.12.31
[debug] Python version 2.7.12 - Linux-4.10.0-42-generic-x86_64-with-Ubuntu-16.04-xenial
[debug] exe versions: ffmpeg 3.3.3-2, ffprobe 3.3.3-2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] RtU_mdL2vBM: Downloading webpage
[youtube] RtU_mdL2vBM: Downloading video info webpage
[youtube] RtU_mdL2vBM: Extracting video information
[youtube] RtU_mdL2vBM: Downloading m3u8 information
[youtube] RtU_mdL2vBM: Downloading MPD manifest
[info] Available formats for RtU_mdL2vBM:
format code extension resolution note
91 mp4 256x144 HLS 197k , avc1.42c00b, 30.0fps, mp4a.40.5@ 48k
92 mp4 426x240 HLS 338k , avc1.4d4015, 30.0fps, mp4a.40.5@ 48k
93 mp4 640x360 HLS 829k , avc1.4d401e, 30.0fps, mp4a.40.2@128k
94 mp4 854x480 HLS 1380k , avc1.4d401f, 30.0fps, mp4a.40.2@128k
95 mp4 1280x720 HLS 2593k , avc1.4d401f, 30.0fps, mp4a.40.2@256k
96 mp4 1920x1080 HLS 4715k , avc1.640028, 30.0fps, mp4a.40.2@256k (best)

However, using the usual method based on extracting the first libvlc_media_t item from a libvlc_media_list_t list (note that libvlc_media_list_count() says there is only one item in the list), I always get the lowest resolution. Below is the MRL for the libvlc_media_t item that is in position 0 in the list.

https://manifest.googlevideo.com/api/ma ... 35.124.33/itag/0/ei/WwZRWt6QNrishwbS-aeoDA/maudio/1/hfr/1/ipbits/0/signature/6014B5FB2BCAD858AF9429921A3F89AE05A41D43.3DB953211F5956EA7CC0BCA76BE5233DFBCE7240/playlist_type/DVR/dover/8/keepalive/yes/playlist_duration/30/manifest_duration/30/file/index.m3u8

I think the itag/0 field results in selection of a default resolution. I would like to use format code 93 shown in the youtube-dl output. Is there any way I can do that programming with the libvlc API?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Video resolution for live YouTube stream

Postby Jean-Baptiste Kempf » 14 Jan 2018 11:19

When you play with VLC, does it take the correct version?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

leftwing
New Cone
New Cone
Posts: 9
Joined: 03 May 2017 01:51

Re: Video resolution for live YouTube stream

Postby leftwing » 18 Jan 2018 00:21

When I play with VLC the 256x144 stream is also used. However when I play from the YouTube site the 640x360 stream is used. For my current purposes, that's the one I actually want.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Video resolution for live YouTube stream

Postby Jean-Baptiste Kempf » 20 Jan 2018 19:29

Then the issue is the VLC lua script for youtube.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

leftwing
New Cone
New Cone
Posts: 9
Joined: 03 May 2017 01:51

Re: Video resolution for live YouTube stream

Postby leftwing » 25 Jan 2018 21:14

I got youtube.lua from GitHub @ https://github.com/videolan/vlc/blob/ma ... outube.lua and I think it's a recent revision. I don't know LUA or enough VLC internals so I decided to try to solve this problem another way. I found that information about the available streams at different resolutions, usually about 5 or 6, is posted to the log file. I examine the strings passed to my log_callback and I pick the MRL for the resolution I want. The process involves starting at the resolution I get from the media list, which has always been 256x144 for live streams, and then switching to a higher-res steam when information about the streams is available in the log.

It works fine right now but it will break if log entries change in the future. Maybe if I learn more I'll look at the LUA script.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 1 guest