Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download only Audio bytes #9754

Open
WiS3 opened this issue Jun 11, 2016 · 6 comments
Open

Download only Audio bytes #9754

WiS3 opened this issue Jun 11, 2016 · 6 comments
Labels

Comments

@WiS3
Copy link

WiS3 commented Jun 11, 2016

I want to download from YouTube the best Audio Quality possible.
Since the Audio Only files are at low bitrate (usually 128k), i have to download the whole Audio+Video (format 22 usually has the best audio), and then extract the audio.

But i don't want to download the entire video file to only get the audio.

I know it is possible to download only Audio bytes by parsing the format header and skip all video frames to save bandwidth.

For example 4K Video Downloader does this with YouTube to get the best Audio quality from a video.
It parses the MP4 header, and download only the audio bytes.

it is possible to implement this functionality?

@yan12125
Copy link
Collaborator

I know it is possible to download only Audio bytes by parsing the format header and skip all video frames to save bandwidth.

Is there an existing command line tool for this? I don't think MP4 parsing is something trivial.

@yan12125
Copy link
Collaborator

Related: #9302

@WiS3
Copy link
Author

WiS3 commented Jun 11, 2016

I don't know if there is, anyway by searching a bit i found a project that seems to do that.
But it's for Android and it's written in Java. Maybe someone can port it.

https://github.com/feribg/audiogetter/blob/master/audiogetter/src/main/java/com/github/feribg/audiogetter/tasks/download/VideoTask.java
from
http://stackoverflow.com/questions/15241076/download-only-audio-from-a-youtube-video

@yan12125
Copy link
Collaborator

On https://github.com/feribg/audiogetter it says:

This is a work in progress, currently it doesn't compile or run

And I indeed got non-trivial compile errors. Do you have a working example?

@WiS3
Copy link
Author

WiS3 commented Jun 11, 2016

https://github.com/gpac/gpac

Just tried and it is working. But it doesn't support files over HTTP.
I tried with MP4 downloaded by youtube-dl

mp4box -single 2 "input.mp4" -out "output.m4a"

@kidol
Copy link
Contributor

kidol commented Jun 11, 2016

@WiS3
From what I can see in network sniffer, the 4K Video Downloader simply downloads the m4a file which you can get with youtube-dl too. It just uses multiple threads (1 range-request for each thread). I tested with a 4k video.

Regarding the idea:

I have downloaded a 10 minute mp4 from YT. When I open it in an app called Mp4Explorer to show the mp4 moov structure, it lists 1.269 "chunk box offsets" for the audio track.

Based on the audiogetter source code

long[] chunkOffsets = chunkOffsetBox.getChunkOffsets();
...
for (int i = 0; i < chunkOffsets.length; i++) {
   ...
   chunks.add(new Chunk(i, chunkStartOffset, chunkEndOffset, offsetInFile));
}

it looks like one has to do a http range-request for every chunk to download the audio data.
That's about 2 range-requests for 1 second of audio (based on my test file with 1.269 chunks).

That would be overkill if correct and would probably get ip banned pretty fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants