Downloading YouTube Videos with a Groovy one-liner, and convert it to mpeg4

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)
intrc?i=TF8UySFa intrc?i=NXxC1Mpi intrc?i=iMqmVDPF intrc?i=GDbG3MVV intrc?i=oMtWEFMH intrc?i=7XMsGEMC
144418701
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 当在终端或命令行中使用类似于wget或curl等下载工具时,出现downloading v3.1.0/protobuf-cpp-3.1.0.tar.gz...的提示意味着正在下载protobuf-cpp-3.1.0.tar.gz这个文件。这通常是下载一个开源软件包或源代码。 protobuf-cpp是Google开发的一种高效的序列化数据结构的工具,能够将数据以二进制形式进行编码并进行传输和存储。protobuf-cpp软件包包含了编译器和相应的库文件,以及开发人员使用protobuf-cpp的各种实用程序和示例代码。在下载这个软件包之前,需要检查自己是否已经安装了编译器和相关的库文件,以便可以正确地编译和使用该软件包。 下载完成后,用户可以将protobuf-cpp集成到他们的项目中,利用这个功能强大的工具来序列化和反序列化数据。如果用户遇到了任何问题或需要进一步的帮助,可以去官方网站或社区寻求支持和反馈。 ### 回答2: 出现downloading v3.1.0/protobuf-cpp-3.1.0.tar.gz是指正在下载谷歌开发的 Protocol Buffers 3.1.0 版本中的C++实现库protobuf的软件压缩文件,这是一种轻量级高效数据交换格式,可用于各种服务间的数据通信,同时也是很多开源软件的重要依赖库之一。当出现downloading v3.1.0/protobuf-cpp-3.1.0.tar.gz...时,一般是因为用户正在使用支持自动化编译和依赖管理的软件管理器,如yum、apt-get或者brew等,这些工具会自动下载并安装所需要的软件库及其依赖,极大地方便了程序开发者和系统管理员的工作。同时,这个过程也需要一定的网络连接和下载时间,用户必须确保网络畅通并耐心等待,以保证软件的正常安装和使用。 ### 回答3: 这是提示正在下载版本为3.1.0的protobuf-cpp.tar.gz文件,protobuf-cpp是一种轻量级的数据交换格式,常用于不同系统间的数据通信。在下载过程中可能会出现下载速度变慢或者下载失败等情况,需要注意网络状况和服务器状态。如果下载失败,可以尝试重新下载或者通过其他途径获取所需文件。同时也需要注意要下载正确版本的文件,以避免后续的代码运行问题。下载完成后,需要将文件正确地放置到相应的目录下,并进行相关配置和编译工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值