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

"--merge-output-format mp4" causes ffmpeg merge to fail #16819

Closed
cameronetchart opened this issue Jun 25, 2018 · 4 comments
Closed

"--merge-output-format mp4" causes ffmpeg merge to fail #16819

cameronetchart opened this issue Jun 25, 2018 · 4 comments
Labels

Comments

@cameronetchart
Copy link

@cameronetchart cameronetchart commented Jun 25, 2018

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like this: [x])
  • Use the Preview tab to see what your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.06.25. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • [X ] I've verified and I assure that I'm running youtube-dl 2018.06.25

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add the -v flag to your command line you run youtube-dl with (youtube-dl -v <your command line>), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

PS C:\Users\cameronetchart> youtube-dl https://www.youtube.com/watch?v=frhMomcKT9o -v --merge-output-format mp4
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=frhMomcKT9o', '-v', '--merge-output-format', 'mp4']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2018.06.25
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.17134
[debug] exe versions: ffmpeg N-91330-ga990184007, ffprobe N-91330-ga990184007
[debug] Proxy map: {}
[youtube] frhMomcKT9o: Downloading webpage
[youtube] frhMomcKT9o: Downloading video info webpage
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://r10---sn-bvvbax-cvne.googlevideo.com/videoplayback?sparams=aitags%2Cclen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&gir=yes&requiressl=yes&clen=40833520&mime=video%2Fmp4&ipbits=0&expire=1529977606&c=WEB&fexp=23709359&initcwndbps=1701250&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&fvip=3&key=yt6&ip=2601%3A18a%3Ac680%3A4880%3Ae0d5%3A13bd%3A80da%3A14b7&pl=34&source=youtube&mn=sn-bvvbax-cvne%2Csn-ab5szn7d&mm=31%2C29&signature=80161A2CAFA2097F45DF76EA216864394F58A30C.9764FAB77C1757155C8B96229BC23317672FEAA5&ms=au%2Crdu&ei=pUYxW7OQOpS08wSd4qTgCw&id=o-AJcq0jsUJ8TF6Krntd4inJ-XpxItU4xBkTFLUQjrL5MN&mv=m&mt=1529955916&dur=195.762&keepalive=yes&lmt=1529944014981809&itag=137&ratebypass=yes'
[download] Destination: The New Highway to the Arctic Ocean-frhMomcKT9o.f137.mp4
[download] 100% of 38.94MiB in 00:02
[debug] Invoking downloader on 'https://r10---sn-bvvbax-cvne.googlevideo.com/videoplayback?sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&gir=yes&requiressl=yes&clen=2639490&mime=audio%2Fwebm&ipbits=0&expire=1529977606&c=WEB&fexp=23709359&initcwndbps=1701250&fvip=3&key=yt6&ip=2601%3A18a%3Ac680%3A4880%3Ae0d5%3A13bd%3A80da%3A14b7&pl=34&source=youtube&mn=sn-bvvbax-cvne%2Csn-ab5szn7d&mm=31%2C29&signature=6947275A568CC81537A83A884D1D4F912A339F2F.D13B9CC191F8366ABA5F750439E91813485F45F0&ms=au%2Crdu&ei=pUYxW7OQOpS08wSd4qTgCw&id=o-AJcq0jsUJ8TF6Krntd4inJ-XpxItU4xBkTFLUQjrL5MN&mv=m&mt=1529955916&dur=195.781&keepalive=yes&lmt=1529945487219261&itag=251&ratebypass=yes'
[download] Destination: The New Highway to the Arctic Ocean-frhMomcKT9o.f251.webm
[download] 100% of 2.52MiB in 00:00
[ffmpeg] Merging formats into "The New Highway to the Arctic Ocean-frhMomcKT9o.mp4"
[debug] ffmpeg command line: ffmpeg -y -i "file:The New Highway to the Arctic Ocean-frhMomcKT9o.f137.mp4" -i "file:The New Highway to the Arctic Ocean-frhMomcKT9o.f251.webm" -c copy -map "0:v:0" -map "1:a:0" "file:The New Highway to the Arctic Ocean-frhMomcKT9o.temp.mp4"
ERROR:     Last message repeated 1 times
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpkc931nsv\build\youtube_dl\YoutubeDL.py", line 2047, in post_process
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpkc931nsv\build\youtube_dl\postprocessor\ffmpeg.py", line 479, in run
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpkc931nsv\build\youtube_dl\postprocessor\ffmpeg.py", line 204, in run_ffmpeg_multiple_files
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError:     Last message repeated 1 times


Description of your issue, suggested solution and other information

Bug: Youtube-dl throws python errors when merging a youtube video using the "--merge-output-format mp4" flag. It results in the audio and video files saved separately and a temp file:

  • The New Highway to the Arctic Ocean-frhMomcKT9o.f137.mp4 (working video only)
  • The New Highway to the Arctic Ocean-frhMomcKT9o.f251.webm (working audio only)
  • The New Highway to the Arctic Ocean-frhMomcKT9o.temp.mp4 (zero bytes)

Possible cause: I think this is caused by the default "bestvideo+bestaudio" selecting an opus audio stream as the highest bitrate, and I think opus isn't compatible with mp4. Instead of showing an error or autoselecting the best quality compatible stream, youtube-dl throws python errors.

Workaround: Manually run all downloads using the "--merge-output-format mp4" flag also with specific -f flags to ensure mp4 incompatible streams aren't selected. For example,
youtube-dl https://www.youtube.com/watch?v=frhMomcKT9o -v --merge-output-format mp4 -f 137+140 works but youtube-dl https://www.youtube.com/watch?v=frhMomcKT9o -v --merge-output-format mp4 does not.

Possible fix: make "--merge-output-format mp4" cause youtube-dl to not select mp4 incompatible streams (e.g. vp8, vp9, opus, etc.) for determining bestvideo+bestaudio.

All running on Win10 x64 with latest youtube-dl and ffmpeg (20180619)

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 25, 2018

webm+mp4 can't be merged into mp4 container.

@dstftw dstftw closed this Jun 25, 2018
@dstftw dstftw added the invalid label Jun 25, 2018
@cameronetchart
Copy link
Author

@cameronetchart cameronetchart commented Jun 25, 2018

Right, but do you think it's a bug for yt-dl to automatically select incompatible formats if the user only wants mp4 outputs, then throw python errors? Perhaps add an error message for the user to know to manually use "-f"?

No worries if not, I figured it out eventually, but wanted to report it.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 25, 2018

--merge-output-format have nothing to do with format selection. It's user's responsibility to properly select formats once --merge-output-format is specified. Default format selection always selects best available formats regardless of compatibility. Add error message when? How do you know what is the real cause of failed merge?

@dantheman213
Copy link

@dantheman213 dantheman213 commented Jan 11, 2020

The whole point of using this tool is to take something complex and make it trivial. If two formats have been selected that are incompatible seems obvious for the app to throw exit 1 rather than let an obvious error will occur if the app continues down the chain of events.

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.