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)
分享到:
相关推荐
groovy-all-2.4.15.jar文件,MAC使用时需存放在/Users/用户名/.gradle/caches/jars-3/某一缓存目录下,找不到就都看一下,我遇到的问题是缓存目录中下载的是2.4.17版本,应该跟gradle版本升级有关
Downloading 4_darknet19_448-main.zip
此压缩包文件"iDRAC-with-Lifecycle-Controller_Firmware_40T1C_WN32_2.63.60.61_A00.zip"是针对iDRAC及其Lifecycle Controller的固件更新程序。版本号2.63.60.61表明这是该组件的一个特定版本,可能包含了性能改进...
Typically, this involves downloading the Groovy distribution package, extracting it to a desired location, and adding the `bin` directory to the system's PATH environment variable. The official ...
The transition from Flex Builder to Eclipse as the primary development environment is a common one, particularly in teams with a strong Java background. This shift leverages the flexibility and ...
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 安装
trivy-db-to trivy-db-to是用于将漏洞信息从迁移/转换到其他数据源的工具。 用法 $ trivy-db-to mysql://root:mypass@127.0.0.1:3306/mydb Fetching and updating Trivy DB ... 19.35 MiB / 19.35 MiB [-----------...
《PyTorch中的torch_scatter模块详解》 在深度学习领域,PyTorch是一个非常流行的框架,它提供了丰富的工具和库来支持模型的构建和训练。`torch_scatter`是其中一个重要的扩展库,专为处理张量的分散操作而设计。...
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...
```groovy plugins { id 'com.github.jakemarsden.robolectric-gradle-plugin' version 'X.Y.Z' } ``` 或者 ```groovy dependencies { classpath '...
onnxruntime-1.9.1-cp310-cp310-linux_armv7l.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...
scipy-1.14.1
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, ...
org.bouncycastle csdn上有 bcprov-jdk15to18-1.72.jar ,但没有 bcprov-ext-jdk15to18-1.72.jar 特此上传,免费下载