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

-f bestvideo+bestaudio tries mixing codecs that don't match #5298

Closed
RickyRomero opened this issue Mar 27, 2015 · 11 comments
Closed

-f bestvideo+bestaudio tries mixing codecs that don't match #5298

RickyRomero opened this issue Mar 27, 2015 · 11 comments

Comments

@RickyRomero
Copy link

YouTube started adding support for 4K video at 60 FPS today, which youtube-dl actually downloads if you choose that format. Here's their testing playlist: https://www.youtube.com/playlist?list=PLyqf6gJt7KuHCoYaGNWPx8vkHlClmbO9u

Here's an example format list for one of the videos:

[youtube] fEAyDNWaCto: Downloading webpage
[youtube] fEAyDNWaCto: Extracting video information
[youtube] fEAyDNWaCto: Downloading DASH manifest
[info] Available formats for fEAyDNWaCto:
format code  extension  resolution note
171          webm       audio only DASH audio  128k , audio@128k (44100Hz), 2.57MiB
140          m4a        audio only DASH audio  129k , m4a_dash container, aac  @128k (44100Hz), 3.12MiB
141          m4a        audio only DASH audio  255k , m4a_dash container, aac  @256k (44100Hz), 6.19MiB
160          mp4        256x144    DASH video  111k , 15fps, video only, 2.61MiB
278          webm       256x144    DASH video  204k , webm container, VP9, 15fps, video only, 2.36MiB
133          mp4        426x240    DASH video  246k , 30fps, video only, 5.87MiB
242          webm       426x240    DASH video  293k , 30fps, video only, 4.42MiB
243          webm       640x360    DASH video  541k , 30fps, video only, 8.19MiB
134          mp4        640x360    DASH video  607k , 30fps, video only, 9.19MiB
244          webm       854x480    DASH video  975k , 30fps, video only, 14.63MiB
135          mp4        854x480    DASH video 1112k , 30fps, video only, 17.96MiB
247          webm       1280x720   DASH video 1961k , 30fps, video only, 29.53MiB
136          mp4        1280x720   DASH video 2224k , 30fps, video only, 36.12MiB
302          webm       1280x720   DASH video 3123k , VP9, 60fps, video only, 47.73MiB
248          webm       1920x1080  DASH video 3212k , 30fps, video only, 51.73MiB
298          mp4        1280x720   DASH video 3332k , h264, 60fps, video only, 63.46MiB
137          mp4        1920x1080  DASH video 4168k , 30fps, video only, 75.08MiB
303          webm       1920x1080  DASH video 5200k , VP9, 60fps, video only, 81.94MiB
299          mp4        1920x1080  DASH video 5561k , h264, 60fps, video only, 113.71MiB
271          webm       2560x1440  DASH video 9199k , 30fps, video only, 146.26MiB
264          mp4        2560x1440  DASH video 9960k , 30fps, video only, 176.92MiB
308          webm       2560x1440  DASH video 13767k , VP9, 60fps, video only, 229.65MiB
313          webm       3840x2160  DASH video 17713k , VP9, 30fps, video only, 320.36MiB
266          mp4        3840x2160  DASH video 22296k , h264, 30fps, video only, 435.71MiB
315          webm       3840x2160  DASH video 26163k , VP9, 60fps, video only, 488.69MiB
17           3gp        176x144    
36           3gp        320x240    
5            flv        400x240    
43           webm       640x360    
18           mp4        640x360    
22           mp4        1280x720   (best)

I run youtube-dl with the option -f bestvideo+bestaudio so that I don't end up with the old 720p format, since it works every single time (except in this case). So, bestvideo selects 315 (webm), and bestaudio selects 141 (m4a), and then it tries to mix those incompatible formats in ffmpeg and fails.

Technically the selection behavior itself is correct; it is choosing the best audio and video streams available. The issue is that it's trying to mix incompatible audio and video streams.

@RickyRomero
Copy link
Author

As for potential solutions:

  • One way to solve this is to just throw an error (before downloading) when we detect that you're trying to mux incompatible formats. This is the lowest effort solution, but removes the capability to just specify -f bestvideo+bestaudio and be done with it.
  • Another is to mux to a container like mkv, which doesn't care what you throw into it.
  • Yet another is to have another format option, like -f bestvideo+compatibleaudio or somesuch.

@jleclanche
Copy link

Yep:

[19:12:18] adys@azura ~ % youtube-dl -f bestvideo+bestaudio/best "https://www.youtube.com/watch?v=fEAyDNWaCto"
[youtube] fEAyDNWaCto: Downloading webpage
[youtube] fEAyDNWaCto: Extracting video information
[youtube] fEAyDNWaCto: Downloading DASH manifest
[download] Destination: Star Citizen - Pieces of Eight (Piracy and Boarding)-fEAyDNWaCto.f315.webm
[download] 100% of 488.69MiB in 11:04
[download] Destination: Star Citizen - Pieces of Eight (Piracy and Boarding)-fEAyDNWaCto.f141.m4a
[download] 100% of 6.19MiB in 00:07
[ffmpeg] Merging formats into "Star Citizen - Pieces of Eight (Piracy and Boarding)-fEAyDNWaCto.webm"
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

@jaimeMF
Copy link
Collaborator

jaimeMF commented Mar 27, 2015

You can use --merge-output-format mkv or explicity request mp4 and m4a with -f bestvideo[ext=mp4]+bestaudio[ext=m4a].
I would personally try to avoid adding compatibleaudio because it couldn't be used standalone (for example, using -f bestaudio is perfectly valid)

@RickyRomero
Copy link
Author

Interesting, I didn't know about the --merge-output-format option... Thanks. I'll use that as a workaround. I'm prioritizing video framerate/bitrate/resolution over needing to have everything as an mp4 file.

Since the mkv merge is already built-in, maybe throw an error which suggests using it?

It's a shame that the DASH update on YouTube made it trickier to get high-resolution downloads by default (#1578).

@ldmldmldm
Copy link

A webm video and m4a audio cannot be merged by ffmpeg into a mp4 container, however ffmpeg can merge these into a mkv container.

So why not make --merge-output-format mkv default? It will resolve using -f bestvideo+bestaudio. Or possibly pick the output container on the fly depending on the formats to be merged?

@jaimeMF
Copy link
Collaborator

jaimeMF commented Apr 19, 2015

In the next version, if the formats are not compatible they will be merged into a mkv container. Thanks for the report.

@jaimeMF jaimeMF closed this as completed Apr 19, 2015
@dstftw
Copy link
Collaborator

dstftw commented Apr 26, 2015

This has been fixed in youtube-dl 2015.04.26. See our FAQ if you have problems updating.

AndreMiras added a commit to AndreMiras/tubedl that referenced this issue Jan 2, 2016
This fixes 404 errors on some conditions, e.g. when youtube-dl raises:
Requested formats are incompatible for merge and will be merged into mkv

See upstream issue for more details:
ytdl-org/youtube-dl#5298
@desbma
Copy link

desbma commented Sep 30, 2016

I am having a similar problem with recent youtube-dl for some videos:

$ youtube-dl 'http://www.tf1.fr/tmc/quotidien-avec-yann-barthes/videos/ramene-toute-bouffe-a-l-elysee.html'
[TF1] ramene-toute-bouffe-a-l-elysee: Downloading webpage
[wat.tv] 13253897: Downloading JSON metadata
[wat.tv] 13253897: Downloading JSON metadata
[wat.tv] 13253897: Downloading m3u8 information
[wat.tv] 13253897: Downloading f4m manifest
[wat.tv] 13253897: Extracting http url
[wat.tv] 13253897: Checking http-280 URL
[wat.tv] 13253897: Checking http-494 URL
[wat.tv] 13253897: Checking http-706 URL
[wat.tv] 13253897: Checking http-1344 URL
[wat.tv] 13253897: Checking http-1982 URL
[wat.tv] 13253897: Checking http-2729 URL
[wat.tv] 13253897: Downloading MPD manifest
[dashsegments] Total fragments: 72
[download] Destination: Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fdash-video=2510461.mp4
[download] 100% of 42.25MiB in 01:07
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 18
[download] Destination: Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fhls-68.mp4
[download] 100% of 1.22MiB in 00:04
[ffmpeg] Merging formats into "Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.mp4"
ERROR: Conversion failed!

Manually passing --merge-output-format mkv fixes it:

$ youtube-dl --merge-output-format mkv 'http://www.tf1.fr/tmc/quotidien-avec-yann-barthes/videos/ramene-toute-bouffe-a-l-elysee.html'
[TF1] ramene-toute-bouffe-a-l-elysee: Downloading webpage
[wat.tv] 13253897: Downloading JSON metadata
[wat.tv] 13253897: Downloading JSON metadata
[wat.tv] 13253897: Downloading m3u8 information
[wat.tv] 13253897: Downloading f4m manifest
[wat.tv] 13253897: Extracting http url
[wat.tv] 13253897: Checking http-280 URL
[wat.tv] 13253897: Checking http-494 URL
[wat.tv] 13253897: Checking http-706 URL
[wat.tv] 13253897: Checking http-1344 URL
[wat.tv] 13253897: Checking http-1982 URL
[wat.tv] 13253897: Checking http-2729 URL
[wat.tv] 13253897: Downloading MPD manifest
[download] Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fdash-video=2510461.mp4 has already been downloaded
[download] 100% of 42.25MiB
[download] Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fhls-68.mp4 has already been downloaded
[download] 100% of 1.22MiB
[ffmpeg] Merging formats into "Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.mkv"
Deleting original file Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fdash-video=2510461.mp4 (pass -k to keep)
Deleting original file Eric et Quentin  - c'est l'apéro à l'Elysée !-13253897.fhls-68.mp4 (pass -k to keep)

youtube-dl and FFmpeg are up to date:

$ youtube-dl --version
2016.09.24

$ ffmpeg -version
ffmpeg version 3.1.3 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160830
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil      55. 28.100 / 55. 28.100
libavcodec     57. 48.101 / 57. 48.101
libavformat    57. 41.100 / 57. 41.100
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 47.100 /  6. 47.100
libavresample   3.  0.  0 /  3.  0.  0
libswscale      4.  1.100 /  4.  1.100
libswresample   2.  1.100 /  2.  1.100

@yan12125
Copy link
Collaborator

@desbma It's a similar while different bug, see #9913.

@RossComputerGuy
Copy link

Screenshot_20200624-004108_Termux
Screenshot_20200624-005235_Termux

Screenshot_20200624-005257_Termux

@desbma's solution doesn't work on Termux

@yan12125
Copy link
Collaborator

I'm going to lock this issue as the original issue has been resolved for a long time. Please follow #9913 or create a new issue if you believe it's different from #9913.

Also, please paste texts instead of screenshots the next time.

@ytdl-org ytdl-org locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants