Download ONLY audio from a youtube video

后端 未结 2 721
小蘑菇
小蘑菇 2020-12-12 17:44

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

相关标签:
2条回答
  • 2020-12-12 18:06

    After a lot of research I found out that this is not possible and developed 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

    0 讨论(0)
  • 2020-12-12 18:23

    FFmpeg is capable of accepting an URL as input. If the URL is seekable, then FFmpeg could theoretically skip all the video frames, and thus it would need to download only the data for the audio stream.

    Try using

    ffmpeg -i http://myvideo.avi out.mp3
    

    and see if it takes less bandwidth.

    0 讨论(0)
提交回复
热议问题