kktuax / youtupi

YouTube (mobile) web frontend for your Raspberry Pi
https://maxtuni.es/2013/02/16/Introducing-YouTuPi.html
20 stars 6 forks source link

The backend invokes omxplayer after a lot of seconds #13

Closed sscarduzio closed 9 years ago

sscarduzio commented 9 years ago

After I press play, it takes a lot of seconds before omxplayer appears in the process list (ps aux |grep omx)

kktuax commented 9 years ago

Most of the time is spent retrieving the video URL. For example:

pi@raspberrypi ~/youtupi $ date && youtube-dl -g https://www.youtube.com/watch?v=n7saS3X3btk && date
Sun Oct  5 18:58:00 UTC 2014
https://r16---sn-aigllm7k.googlevideo.com/videoplayback?id=o-AGCt-HXLq0t7uaLHfYY2_5MEvAAyCOL8knNNwkzlJPbG&key=yt5&signature=32ACEBBFE6889FCF1EA75786265F49C548995016.78DE22EFFB4CEF83F296C77A89C4316DFBD2603D&nh=EAQ&ipbits=0&fexp=916637%2C919121%2C927622%2C930666%2C931983%2C932404%2C934030%2C938682%2C945305%2C946023%2C947209%2C951501%2C952302%2C953801&expire=1412557097&ratebypass=yes&mt=1412535384&sver=3&upn=eKRshKmmuVo&ip=90.165.30.83&sparams=id%2Cip%2Cipbits%2Citag%2Cmm%2Cms%2Cmv%2Cnh%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&requiressl=yes&mm=31&ms=au&itag=22&source=youtube&mv=m
Sun Oct  5 18:58:22 UTC 2014

On my laptop this command just takes about 4 seconds.

Since youtupi delegates in youtube-dl to retrieve the URL this issue has not easy fix. If you select several songs the URLs will be fetched in the background and after the first initial delay the rest of the playback would be fluid.

kktuax commented 9 years ago

There is a project that exposes youtube-dl as a REST server: http://youtube-dl-api-server.readthedocs.org

If the video URL is fetched using and external server the process could be speeded up. They have an online demo, for example it could be parsed the video URL from this response

https://youtube-dl.appspot.com/api/info?url=https://www.youtube.com/watch?v=DKuqcKdlAUs

This type of solution is not perfect since it will depend on the availability of this external server.

sscarduzio commented 9 years ago

Yeah, that's what people says about it in the internetS. But I regularly mps-youtube on the same RaspberryPI and it's blazing fast.

Check it out, it's instant: https://github.com/np1/mps-youtube

It uses Pafy youtube library.

kktuax commented 9 years ago

Thanks for the tip, I didn't know de Pafy library. Indeed its very fast, and its also its coded in python so its a good fit.

sscarduzio commented 9 years ago

Amazing difference with Pafy! Thanks :)