Download ONLY audio from a youtube video

后端 未结 2 730
小蘑菇
小蘑菇 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

提交回复
热议问题