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

Youtube to mp3 in 320k #3736

Open
sanishan opened this issue Sep 13, 2014 · 12 comments
Open

Youtube to mp3 in 320k #3736

sanishan opened this issue Sep 13, 2014 · 12 comments

Comments

@sanishan
Copy link

@sanishan sanishan commented Sep 13, 2014

I have both ffmpeg and avconv both are return same result.

/usr/local/bin/youtube-dl --audio-quality 320k --extract-audio --no-part --audio-format mp3 https://www.youtube.com/watch?v='.$id. ' --restrict-filenames -o "mp3/%(id)s.mp3" unable to convert into 320k but always return 128k mp3

Also i have tried everything.

/usr/local/bin/youtube-dl --audio-quality 0 --extract-audio --no-part --audio-format mp3 https://www.youtube.com/watch?v='.$id. ' --restrict-filenames -o "mp3/%(id)s.mp3"

Always same result dose any body now how to fix it.

@iggyvolz
Copy link

@iggyvolz iggyvolz commented Sep 15, 2014

What the heck are you doing here?
https://www.youtube.com/watch?v='.$id. '
I'm guessing you're usually a PHP programmer... in Bash the variables substitute before anything is done, so you should just do:
https://www.youtube.com/watch?v=$id
(you may need to put {} around id depending on your shell)

@sanishan
Copy link
Author

@sanishan sanishan commented Sep 15, 2014

I think you did no understand,

[code]
exec('/usr/local/bin/youtube-dl --audio-format best --no-part --extract-audio https://www.youtube.com/watch?v='.$id. ' --restrict-filenames -o "mp3/%(id)s.m4a" > /dev/null', $output,$return_var);
[/code]

did i am doing something wrong? and please keep in mind video is downloading perfectly so there is no any code problem.

Thanks,

@iggyvolz
Copy link

@iggyvolz iggyvolz commented Sep 15, 2014

Ah, my mistake. I thought you were calling it in native bash, but you're using PHP.

@sanishan
Copy link
Author

@sanishan sanishan commented Sep 15, 2014

That's good, so dose any body have any solution to convert into 320k without calling ffmepg again?

Thanks,

@treaki
Copy link

@treaki treaki commented Sep 16, 2014

just write the video into a temp file and do the post progressing by yourself using ffmpeg, mencoder or lame

@sanishan
Copy link
Author

@sanishan sanishan commented Sep 16, 2014

yep.. right know i am doing this..

Thanks,

@treaki
Copy link

@treaki treaki commented Sep 16, 2014

ive did an quick and ugly test, it is working:

https://github.com/treaki/youtube2mp3

@treaki
Copy link

@treaki treaki commented Sep 16, 2014

let me see your solution

@sanishan
Copy link
Author

@sanishan sanishan commented Sep 16, 2014

well i am doing little bit different,

First i am download m4a and then run 2nd run ffmpeg to convert into mp3

Thanks,

@treaki
Copy link

@treaki treaki commented Sep 16, 2014

would be a good idea to safe trafic but it looks like youtube dosnt provide audio only:

$ youtube-dl -f m4a SomeYTID
[youtube] Setting language
[youtube] Confirming age
[youtube] SomeYTID: Downloading webpage
[youtube] SomeYTID: Downloading video info webpage
[youtube] SomeYTID: Extracting video information
ERROR: requested format not available

so you have to take the hard way and download the video

@sanishan
Copy link
Author

@sanishan sanishan commented Sep 16, 2014

i have created a small script which log the error (for request format errors). only i can see is the restricted video log only.

So far 2000+ videos is downloaded since last 7 day from my website. all m4a found.

If you know any youtube id which did not have m4a then i can test it properly and change my code to video only.

Thanks,

@phihag
Copy link
Contributor

@phihag phihag commented Sep 16, 2014

Can you elaborate how you find out that the bitrate didn't match? Your command is equivalent to the one youtube-dl is invoking. It works fine for me:

$ youtube-dl 8zbg_M6C6V8 -o 'test.%(ext)s' -x --audio-format mp3 --audio-quality 320k
$ mplayer -ao none -identify test.mp3 | grep BITRATE
ID_AUDIO_BITRATE=320000
ID_AUDIO_BITRATE=320000

By the way, if you want youtube-dl to download just an audio file, pass in -f bestaudio, not -f m4a.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.