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

How to add codec to the filename #10183

Closed
davidhedlund opened this issue Jul 28, 2016 · 7 comments
Closed

How to add codec to the filename #10183

davidhedlund opened this issue Jul 28, 2016 · 7 comments

Comments

@davidhedlund
Copy link

@davidhedlund davidhedlund commented Jul 28, 2016

youtube-dl -f 251 https://www.youtube.com/watch?v=nhNUlAudx8E -o "%(title)s.%(format_id)s.%(ext)s"

That will download the file as

Electric Universe - Freedom.251.webm

However, "251" will cause confusion as people do not know that it is "Opus". I would like it add the actual codec like this:

Electric Universe - Freedom.opus.webm

How do I do that?

@davidhedlund davidhedlund changed the title How to add codec in filename? --output TEMPLATE missing %(codec)s Jul 28, 2016
@phihag
Copy link
Contributor

@phihag phihag commented Jul 28, 2016

Use the -o option to set an output template, and include %(acodec)s for the audio codec:

$ youtube-dl -f 251 nhNUlAudx8E -o "%(title)s-%(id)s.%(acodec)s.%(ext)s" --get-filename
Electric Universe - Freedom-nhNUlAudx8E.opus.webm

For more information, refer to the documentation.

@phihag phihag closed this Jul 28, 2016
@davidhedlund
Copy link
Author

@davidhedlund davidhedlund commented Jul 28, 2016

@phihag Thank you.

@davidhedlund davidhedlund changed the title --output TEMPLATE missing %(codec)s How to add codec to the filename Jul 28, 2016
@davidhedlund
Copy link
Author

@davidhedlund davidhedlund commented Jul 29, 2016

@phihag Why do

youtube-dl -x -f 251 nhNUlAudx8E

give

Electric Universe - Freedom-nhNUlAudx8E.mp3

rather than this?

Electric Universe - Freedom-nhNUlAudx8E.opus

The solution was

youtube-dl -x --audio-format opus --audio-quality 0 nhNUlAudx8E

However, this is really what I'm requesting with -f 251 which is confusing.

@phihag
Copy link
Contributor

@phihag phihag commented Jul 29, 2016

The default --audio-format happens to be mp3 in some cases.

If you want opus, say so, and don't include -f at all, as you seem to have done. -f 251 literally means: pick format 251 - nothing more, nothing less. It's better to describe the desired result and let youtube-dl figure out how to get there.

@davidhedlund
Copy link
Author

@davidhedlund davidhedlund commented Jul 29, 2016

@phihag

youtube-dl -F nhNUlAudx8E | grep 251
251 webm audio only DASH audio 138k , opus @160k, 6.02MiB

Format 251 is webm with opus, not webm with mp3.

@phihag
Copy link
Contributor

@phihag phihag commented Jul 29, 2016

Indeed, but that's all just the video format (although this happens to be one video format that contains audio only). --audio-format controls the behavior of --extract-audio which advises youtube-dl to extract an audio file from the video file.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 29, 2016

youtube-dl -x -f 251 nhNUlAudx8E works as expected for me:

$ youtube-dl -v -x -f 251 nhNUlAudx8E -o "%(title)s-%(id)s.%(acodec)s.%(ext)s" --get-filename
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', '-x', '-f', '251', 'nhNUlAudx8E', '-o', '%(title)s-%(id)s.%(acodec)s.%(ext)s', '--get-filename']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.07.28
[debug] Git HEAD: 0cacae2
[debug] Python version 3.5.2 - Linux-4.6.5-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.1.1, ffprobe 3.1.1, rtmpdump 2.4
[debug] Proxy map: {}
Electric Universe - Freedom-nhNUlAudx8E.opus.webm
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
3 participants
You can’t perform that action at this time.