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

ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument #9534

Closed
hadmut opened this issue May 18, 2016 · 4 comments

Comments

@hadmut
Copy link

@hadmut hadmut commented May 18, 2016

Hi,

youtube-dl does not properly convert audio. e.g. when doing

youtube-dl -v --audio-format aac --merge-output-format mp4 'https://www.youtube.com/results?search_query=vjf3WMzPvpY'
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'--audio-format', u'aac', u'--merge-output-format', u'mp4', u'https://www.youtube.com/results?search_query=vjf3WMzPvpY']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.05.10
[debug] Python version 2.7.11+ - Linux-4.4.0-22-generic-x86_64-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 2.8.6-1ubuntu2, avprobe 2.8.6-1ubuntu2, ffmpeg 2.8.6-1ubuntu2, ffprobe 2.8.6-1ubuntu2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube:search_url] vjf3WMzPvpY: Downloading webpage
[download] Downloading playlist: vjf3WMzPvpY
[youtube:search_url] playlist vjf3WMzPvpY: Downloading 1 videos
[download] Downloading video 1 of 1
[youtube] vjf3WMzPvpY: Downloading webpage
[youtube] vjf3WMzPvpY: Downloading video info webpage
[youtube] vjf3WMzPvpY: Extracting video information
[youtube] vjf3WMzPvpY: Downloading MPD manifest
[debug] Invoking downloader on u'https://r1---sn-cxg7ene7.googlevideo.com/videoplayback?id=be37f758cccfbe96&itag=137&source=youtube&requiressl=yes&pl=17&initcwndbps=1792500&mn=sn-cxg7ene7&mm=31&mv=m&ms=au&ratebypass=yes&mime=video/mp4&gir=yes&clen=101607074&lmt=1463391925128486&dur=487.353&upn=MT_fUCY56t4&sver=3&fexp=9410706,9413139,9416126,9416891,9419452,9421084,9422596,9428398,9429014,9431012,9432057,9433096,9433946,9434086,9435265,9435772,9436323,9436348,9436446,9436617,9436810,9436871&signature=57A60CA80A34245E7BFAFF31BEEF27F87AC9DBE8.8538FF753BD7BC4A2C1A5B97B9C982DAF2408780&key=dg_yt0&mt=1463594106&ip=91.64.206.115&ipbits=0&expire=1463616010&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,initcwndbps,mn,mm,mv,ms,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.f137.mp4
[download] 100% of 96.90MiB in 17:07
[debug] Invoking downloader on u'https://r1---sn-cxg7ene7.googlevideo.com/videoplayback?id=be37f758cccfbe96&itag=251&source=youtube&requiressl=yes&pl=17&initcwndbps=1792500&mn=sn-cxg7ene7&mm=31&mv=m&ms=au&ratebypass=yes&mime=audio/webm&gir=yes&clen=8694398&lmt=1463271709121292&dur=487.361&upn=MT_fUCY56t4&sver=3&fexp=9410706,9413139,9416126,9416891,9419452,9421084,9422596,9428398,9429014,9431012,9432057,9433096,9433946,9434086,9435265,9435772,9436323,9436348,9436446,9436617,9436810,9436871&signature=0E784D73A4A2E1917671D436DBBDB6D5270CEB6E.84FA260856408B1EC763AA78EC0E6FFF3892B964&key=dg_yt0&mt=1463594106&ip=91.64.206.115&ipbits=0&expire=1463616010&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,initcwndbps,mn,mm,mv,ms,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.f251.webm
[download] 100% of 8.29MiB in 01:28
[ffmpeg] Merging formats into "Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.mp4"
[debug] ffmpeg command line: avconv -y -i 'file:Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.f137.mp4' -i 'file:Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.f251.webm' -c copy -map 0✌️0 -map 1🅰️0 'file:Russischer Historiker über vier Einschränkungen der deutschen Souveränität durch 2+4-Vertrag-vjf3WMzPvpY.temp.mp4'
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1781, in post_process
files_to_delete, info = pp.run(info)
File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 445, in run
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 168, in run_ffmpeg_multiple_files
raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError

it tries to put opus audio into mp4, which seems to cause an error message by avconv. Just try to run the avconv from command line.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 18, 2016

it tries to put opus audio into mp4

Cause you tell it to do so:

--merge-output-format mp4

Correct command is -x --audio-format aac to download audio. --audio-format is only used for extracting audio - you can't just convert audio alone and mux with bestvideo.

@dstftw dstftw closed this May 18, 2016
@hadmut
Copy link
Author

@hadmut hadmut commented May 18, 2016

Maybe it would help to read the report before answering and closing it.

youtube-dl should generate an mp4 file with avc video and aac audio, as usual.

it does not do that because it downloads opus and does not convert it.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 18, 2016

You did not tell it to convert (-x) that's why it followed default flow to download bestvideo+bestaudio. At the same time you've specified --merge-output-format mp4 that forces mux container to mp4 that is incompatible as merge targed for mp4+webm.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 18, 2016

The closest thing you can do in order to achieve

video with AVC video codec, AAC audio codec, and both packed into mp4

(you had to mention this in the OP post in the first place since it's not possible to decipher whether your intention was actually to download audio, convert it, download video and mux them or just download audio and convert it or whatever else, needless to say you did not even follow new issue template and provide all information we require for a report).

is to download formats separately (-f bestvideo[ext=mp4] and -f bestaudio -x --audio-format aac) and mux them by hand
aac is actually available as original format without conversion so plain -f bestvideo[ext=mp4]+bestaudio[ext=m4a] should do what you want.

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
2 participants
You can’t perform that action at this time.