从YouTube视频下载只有音频 [英] Download ONLY audio from a youtube video

查看:360
本文介绍了从YouTube视频下载只有音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一百万种方式可以从YouTube下载视频,然后将其转换为音频或进行其他处理。但最近,我惊讶的发现一个名为YoutubeToMp3的应用程序在Mac上实际显示Skipping X mb of video,据说只能从视频中下载音频,而无需使用bandwith下载整个视频,然后转换。我想知道这是否真的是正确的,可能的,因为我无法找到任何办法。你有什么想法吗?



编辑:
经过一些测试后,有一些关于该主题的附加信息。我试图获得音频的视频只是一个来自互联网的mp4文件:



http://download.wavetlan.com/SVV/Media/HTTP/MP4/ConvertedFiles/MediaCoder/MediaCoder_test6_1m9s_XVID_VBR_306kbps_320x240_25fps_MPEG1Layer3_CBR_320kbps_Stereo_44100Hz.mp4



我尝试过



ffmpeg -i输入out.mp3 / p>

ffmpeg -i输入-vn out.mp3



ffmpeg -i输入-vn -ac 2 -ar 44100 -ab 320k -f mp3 output.mp3



ffmpeg -i输入-vn -acodec copy output.mp3



不幸的是,这些命令似乎没有使用较少的带宽。他们都下载整个视频。现在你有视频可以确认是否有一个命令只下载音频流,降低带宽使用率?谢谢!

解决方案

经过大量的研究,我发现这是不可能的,开发人员是一种替代方法:


  1. 下载mp4标题

  2. 解析标题并获取音频字节的位置

  3. 使用http范围请求和偏移量下载音频字节

  4. 组合音频字节并将其包装在简单的ADTS容器中,以产生播放的m4a文件

只有使用音频字节的带宽。如果你找到一个更好的做法,请让我知道。



对于一个示例Android APP和实现,请查看:



https://github.com/feribg/audiogetter/blob/master/audiogetter/src/main/java/com/github/feribg/audiogetter/tasks/download/VideoTask.java


I know that there are a million ways to download a video from youtube and then convert it to audio or do further processing on it. But recently I was surprised to see an app called YoutubeToMp3 on mac actually showing "Skipping X mb of video" and supposedly only downloading the audio from the video, without the need to use bandwith to download the entire video and then convert it. I was wondering if this is actually correct and possible at all because I cant find any way to do that. Do you have any ideas ?

EDIT: After some tests here is some additional information on the topic. The video which I tried to get the audio from is just a sample mp4 file from the internet:

http://download.wavetlan.com/SVV/Media/HTTP/MP4/ConvertedFiles/MediaCoder/MediaCoder_test6_1m9s_XVID_VBR_306kbps_320x240_25fps_MPEG1Layer3_CBR_320kbps_Stereo_44100Hz.mp4

I tried

ffmpeg -i "input" out.mp3

ffmpeg -i "input" -vn out.mp3

ffmpeg -i "input" -vn -ac 2 -ar 44100 -ab 320k -f mp3 output.mp3

ffmpeg -i "input" -vn -acodec copy output.mp3

Unfortunately non of these commands seems to be using less bandwith. They all download the entire video. Now that you have the video can you confirm if there is actually a command that downloads only the audio stream from it and lowers the bandwith usage? Thanks!

解决方案

After a lot of research I found out this is not possible and developer an alternative approach:

  1. Download the mp4 header
  2. Parse the header and get the locations of the audio bytes
  3. Download the audio bytes with http range requests and offsets
  4. Assemble the audio bytes and wrap them in a simple ADTS container to produce a playing m4a file

That way only bandwidth for the audio bytes is used. If you find a better approach of doing it please let me know.

For a sample Android APP and implementation check out:

https://github.com/feribg/audiogetter/blob/master/audiogetter/src/main/java/com/github/feribg/audiogetter/tasks/download/VideoTask.java

这篇关于从YouTube视频下载只有音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆