Today I used LiveHTTPHeaders to take a closer look at how the youtube video streams are directed to the browser. And I found that my previous attempt actually has some redundency in it. To get the flv video stream, simply request the URL:
http://cache.googlevideo.com/get_video?video_id=${vid}
where vid is simply the v string in the original URL. e.g. http://www.youtube.com/watch?v=5C0I7Ef4gQI
So the simplified version is one line of code even shorter now.
def vid = (args[0] =~ (/(?<=v=).*$/)).getAt(0)
new File(“${vid}.flv”).withOutputStream{os -> new URL(“http://cache.googlevideo.com/get_video?video_id=${vid}”).openStream().eachByte{it -> os.write(it)}}
And now here’s a bonus. Grab ffmpeg and put the ffmpeg executable to your system path. Then add the following line to the Groovy script above, and the downloaded flv file will be converted to an mpeg4 format mpg file immediately. You can also play with many ffmpeg parameters to fine tune your convertion.
For Windows
Runtime.getRuntime().exec([‘cmd’, ‘/c’, “ffmpeg -i ${vid}.flv ${vid}.mpg”] as String)
For Linux
Runtime.getRuntime().exec([’sh’, ‘-c’, “ffmpeg -i ${vid}.flv ${vid}.mpg”] as String)
分享到:
相关推荐
带Lifecycle的iDrac控制器固件v2.63.60.61,firmimg.d7用于iDrac网页控制台更新,exe用于windows
This book is your step-by-step guide to building your business website in Drupal, complete with a blog, events calendar, catalogue of products and services, and more. In this book, we will build a ...
Python常用库,官方原版whl文件,文件下载到本地后, 直接终端 pip install xxx.whl 安装
It includes Unity integrated tools and standalone version (if someone prefers to use it). You can export Unity integrated P.A.T.C.H. for each supported platform, thanks to Unity. Standalone P.A.T.C.H...
The Internet is almost synonymous with change--that's one of its charms, and one of its headaches. You may think you know the Internet, but are you really up to speed on internet telephones, movie and...
pandas-1.4.3-cp38-cp38-win_amd64.whl
convmv is meant to help convert a single filename, a directory tree and the contained files or a whole filesystem into a different encoding. It just converts the filenames, not the content of the ...
-a, --append-output=FILE append messages to FILE. -d, --debug print lots of debugging information. -q, --quiet quiet (no output). -v, --verbose be verbose (this is the default). -nv, --no-verbose...
one of the longest established programming languages, is to improve the productivity of programmers and the maintainability and performance of code, and develop a deeper understanding of the language ...
The side effect for this is that YOUR app must check if the host is a host name or a IP address, in my app I remove the periods and try to convert the result to a float (long integers don‘t work, ...
In order to get the most out of this book, you should be comfortable with downloading and installing software and understand basic business concepts such as sales, purchasing, inventory management, ...
Cython-3.0.0a9-cp310-cp310-win_amd64
downloading-web-page-source-code-android-app:一个可下载指定网页源代码的android应用
* Written and developed by Camera Design Dept.53 * * Copyright Canon Inc. 2006 All Rights Reserved * * * ******************************************************************************* * File Update ...
On-Line MCMC Bayesian Model Selection This demo ... In the header of the demo file, one can select to monitor the simulation progress (with par.doPlot=1) and modify the simulation parameters.
Practical jQuery is your step-by-step guide to using jQuery in the real world, taking you from downloading jQuery all the way to extending it by writing your own plug-ins and testing the DOM using ...
It’s perfect for project and product managers, stakeholders, and other team members who want to collaborate on a development project—whether it’s to review and comment on work in progress or to ...
In Pro JavaFX 2: A Definitive Guide to Rich Clients with Java Technology, Jim Weaver, Weiqi Gao, Stephen Chin, Dean Iverson, and Johan Vos show you how you can use the JavaFX platform to create rich-...
SocketTools is a suite of .NET components, ActiveX controls and libraries for software developers who need to integrate Internet functionality into their Windows applications. Using SocketTools, you ...
Computer savvy kids and can be found surfing the web, chatting with friends, downloading music, and playing games - all at the same time. Many, however, want to do more. Not only do they want to use ...