Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS m3u8 urls? #38

Closed
cannyboy opened this issue Feb 1, 2016 · 13 comments
Closed

HLS m3u8 urls? #38

cannyboy opened this issue Feb 1, 2016 · 13 comments
Assignees

Comments

@cannyboy
Copy link

cannyboy commented Feb 1, 2016

The description of this project is "Fetches Vimeo's mp4 URLs for iOS", so perhaps this is out-of-scope..

Could we fetch the m3u8 URL too (if available)?

For instance, this video: https://vimeo.com/141922873
.. has in its metadata: https://player.vimeo.com/video/141922873/config

the HLS m3u8: https://skyfiregce-a.akamaihd.net/exp=1454348034~acl=%2F141922873%2F%2A~hmac=5cd0c0f7ce4c3704c46f6a93268d3b563c5a55375e5e372e18ff64d0a6b91ba1/141922873/video/425735437,425735440,425735439,425735436/master.m3u8

... which plays in Safari, so I assume it's OK.
(the hmac=XXXX number changes with each /config request I think)

HLS m3u8 URLs are better for iOS because of point 9.4 of the App Store guidelines: https://developer.apple.com/app-store/review/guidelines/
(If an MP4 video is over 10 mins, there is a chance that the app gets rejected, but if it is HLS it is fine)

@SoneeJohn
Copy link
Collaborator

@cannyboy I will look into creating a dictionary to contain these streams separately.

SoneeJohn added a commit to SoneeJohn/YTVimeoExtractor that referenced this issue Feb 1, 2016
SoneeJohn added a commit that referenced this issue Feb 1, 2016
Will assign a value to it soon ;)
#38
SoneeJohn added a commit that referenced this issue Feb 1, 2016
@SoneeJohn
Copy link
Collaborator

@cannyboy I've added this feature you can track the progress in the development branch. I will need to run some tests however, it appears as if most, if not all videos contain a URL for the HLS.

@cannyboy
Copy link
Author

cannyboy commented Feb 3, 2016

ok, i will have a look

@cannyboy
Copy link
Author

cannyboy commented Feb 4, 2016

I haven't found a case of a Vimeo video without HLS, but I check for it just in case.

I play the HTTPLiveStreamURL if it's available. If it's not there, I play the highestQualityStreamURL on wifi, or the lowestQualityStreamURL on cellular.

Here is my code:

YTVimeoExtractor.sharedExtractor().fetchVideoWithVimeoURL(postImage.videoUrl, withReferer: "", completionHandler: { (video, error) -> Void in

    guard let video = video, streamURLs = video.streamURLs where streamURLs.count > 0 else {
        print("vimeo error")
        return
    }

    var vimeoURL = NSURL();
    if let hlsURL = video.HTTPLiveStreamURL {
        vimeoURL = hlsURL
    } else {
        // using fork of https://github.com/Isuru-Nanayakkara/Reach
        let status = Reach().connectionStatus()
        switch status {
        case .Online(.WiFi):
            vimeoURL = video.highestQualityStreamURL()!
        case .Online(.Cellular):
            vimeoURL = video.lowestQualityStreamURL()!
        default: ()
        }
    }

    let playerViewController: AVPlayerViewController = AVPlayerViewController()
    playerViewController.player = AVPlayer(URL: vimeoURL)
    playerViewController.delegate = self
    playerViewController.player?.play()
    self.presentViewController(playerViewController, animated: true, completion: nil)

})

@SoneeJohn
Copy link
Collaborator

@cannyboy looks good, and you're right I haven't been able to find any Vimeo video without the HTTP Live Stream however, just to be on the safe side I will assume that the value can be nil.

@SoneeJohn SoneeJohn self-assigned this Feb 4, 2016
@SoneeJohn
Copy link
Collaborator

@cannyboy Here is suggestion you could check YTVimeoVideo's duration property and see if it's under 600 seconds (10 mins) then if it's not then use the HTS

@cannyboy
Copy link
Author

cannyboy commented Feb 4, 2016

@SoneeJohn - that could be a route to go down. The only reason I would prefer to use HLS for all cases (if its available) is that I'm assuming that Vimeo uses adaptive HLS streams which are suitable for iOS devices. This would mean that, when using HLS, it would automatically switch to suitable streams according to the available bandwidth. So, I step out of a Wifi zone, in to a 3G zone, and the the stream quality goes down automatically without pausing the video.

My assumption might be wrong - I haven't actually inspected the streams. But I've just read this by a member of Vimeo's staff:

You can use adaptive streaming in a third-party player with the HLS links that have been available for awhile.
( https://vimeo.com/forums/help/topic:278740 )

@SoneeJohn
Copy link
Collaborator

I just used the mediastreamvalidator tool on one of the streams that Vimeo reported back. I've attached the report to this comment.
test.json.zip

@SoneeJohn
Copy link
Collaborator

@cannyboy I saw this on the forum:

Hi David,
We've used HLS for a number of years now on iOS. The wider rollout of adaptive streaming is MPEG-DASH. We don't have a specific date, but we definitely want to have it out to everyone by the end of March (most likely it will be sooner).

@cannyboy
Copy link
Author

cannyboy commented Feb 4, 2016

I tried the mediastreamvalidator myself, but I'm too ignorant to understand the output.

But testing a few Vimeo HLS videos with YTVimeoExtractor, I can see the quality smoothly change when I switch between wifi and 3G.

It looks like adaptive streaming is something Vimeo are currently working on: https://vimeo.com/forums/help/topic:279751

@bdougherty

@SoneeJohn
Copy link
Collaborator

@cannyboy I'm moving the progress of this to the HTTPLiveStream branch from the development branch.

@cannyboy
Copy link
Author

cannyboy commented Feb 8, 2016

@SoneeJohn ok, will HLS be in the next version?

@SoneeJohn
Copy link
Collaborator

@cannyboy Yes, I will release it in a later version.

This was referenced Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants