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

Prefer output format mp4 if possible #20655

Closed
kik4444 opened this issue Apr 12, 2019 · 9 comments
Closed

Prefer output format mp4 if possible #20655

kik4444 opened this issue Apr 12, 2019 · 9 comments
Labels

Comments

@kik4444
Copy link

@kik4444 kik4444 commented Apr 12, 2019

Is there any syntax that I'm missing for --merge-output-format that allows you to set it to prefer mp4 over mkv? Currently I'm downloading with this format -f bestvideo[fps=60]+bestaudio/bestvideo+bestaudio/best, and sometimes, depending on the video, the result can be merged into an mp4, but sometimes it can't, so I set --merge-output-format to mkv. However, is it possible to set it to prefer mp4 if possible and fall back to mkv if not?

@ealgase
Copy link
Contributor

@ealgase ealgase commented Apr 13, 2019

It always prefers mp4 by default. If that doesn't work, it merges to mkv instead.

(bionic)ealgase@localhost:~/Downloads/youtube-dl$ youtube-dl -f bestvideo+140 kJQP7kiw5Fk
[youtube] kJQP7kiw5Fk: Downloading webpage
[youtube] kJQP7kiw5Fk: Downloading video info webpage
[download] Destination: Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f137.mp4
[download] 100% of 122.13MiB in 00:15
[download] Destination: Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f140.m4a
[download] 100% of 4.27MiB in 00:00
[ffmpeg] Merging formats into "Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.mp4"
Deleting original file Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f137.mp4 (pass -k to keep)
Deleting original file Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f140.m4a (pass -k to keep)
(bionic)ealgase@localhost:~/Downloads/youtube-dl$ youtube-dl -f bestvideo+bestaudio kJQP7kiw5Fk
[youtube] kJQP7kiw5Fk: Downloading webpage
[youtube] kJQP7kiw5Fk: Downloading video info webpage
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f137.mp4
[download] 100% of 122.13MiB in 00:15
[download] Destination: Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f251.webm
[download] 100% of 4.40MiB in 00:00
[ffmpeg] Merging formats into "Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.mkv"
Deleting original file Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f137.mp4 (pass -k to keep)
Deleting original file Luis Fonsi - Despacito ft. Daddy Yankee-kJQP7kiw5Fk.f251.webm (pass -k to keep)
@remitamine
Copy link
Collaborator

@remitamine remitamine commented Apr 13, 2019

if you want to always get an mp4 file, then use a format selector with compatible formats.
https://github.com/ytdl-org/youtube-dl#format-selection-examples

@remitamine remitamine closed this Apr 13, 2019
@kik4444
Copy link
Author

@kik4444 kik4444 commented Apr 13, 2019

But if I don't specify anything, it'll merge everything into a webm. And if I specify mp4 when that's not possible, I get ERROR: Stream #1:0 -> #0:1 (copy)

@remitamine remitamine added the question label Apr 13, 2019
@kik4444
Copy link
Author

@kik4444 kik4444 commented Apr 13, 2019

if you want to always get an mp4 file, then use a format selector with compatible formats.
https://github.com/ytdl-org/youtube-dl#format-selection-examples

I'm not talking about the quality from -format, I'm talking about merging it into a mp4 with --merge-output-format. I don't always want mp4, I want the best quality, and I'd prefer it to be merged into an mp4 if possible, and if not, then an mkv.

@kik4444
Copy link
Author

@kik4444 kik4444 commented Apr 13, 2019

For example, when using -format you can use the / character to prefer some other format if your first choice isn't available, so I thought that using something like --merge-output-format mp4/mkv would work with the same logic, but it doesn't. Is there something I'm missing?

@remitamine
Copy link
Collaborator

@remitamine remitamine commented Apr 13, 2019

and @ealgase already answered this, don't touch the --merge-output-format option then, this option is used to force a particular container, youtube-dl by default will choose an appropriate container for the selected formats.

@kik4444
Copy link
Author

@kik4444 kik4444 commented Apr 13, 2019

and @ealgase already answered this, don't touch the --merge-output-format option then, this option is used to force a particular container, youtube-dl by default will choose an appropriate container for the selected formats.

Exactly, my question is whether it's possible to force it to use the mp4 container whenever possible (for example when the video format is mp4) with the ability to fall back to mkv (if the format is webm for example)

@ealgase
Copy link
Contributor

@ealgase ealgase commented Apr 13, 2019

@kik4444 webm is literally just mkv with a different file extension.

@remitamine
Copy link
Collaborator

@remitamine remitamine commented Apr 13, 2019

I said don't use --merge-output-format and you will get what you want.

@ytdl-org ytdl-org locked as resolved and limited conversation to collaborators Apr 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.