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 #6865

Closed
horaceho opened this issue Sep 15, 2015 · 7 comments

Comments

@horaceho
Copy link

$ youtube-dl -U
youtube-dl is up-to-date (2015.09.09)

$ youtube-dl 'https://www.youtube.com/watch?v=ShttAt5xtto'
[youtube] ShttAt5xtto: Downloading webpage
[youtube] ShttAt5xtto: Downloading video info webpage
[youtube] ShttAt5xtto: Extracting video information
[youtube] ShttAt5xtto: Downloading DASH manifest
[youtube] ShttAt5xtto: Downloading DASH manifest
[download] HUMAN Extended version VOL.2-ShttAt5xtto.f248.webm has already been downloaded
[download] 100% of 900.79MiB
[download] HUMAN Extended version VOL.2-ShttAt5xtto.f251.webm has already been downloaded
[download] 100% of 65.12MiB
[ffmpeg] Merging formats into "HUMAN Extended version VOL.2-ShttAt5xtto.webm"
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

$ youtube-dl 'https://www.youtube.com/watch?v=ShttAt5xtto' --verbose
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'https://www.youtube.com/watch?v=ShttAt5xtto', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.09.09
[debug] Python version 2.7.9 - Linux-3.2.40-armv7l-with-glibc2.4
[debug] exe versions: ffmpeg 2.0.2
[debug] Proxy map: {}
[youtube] ShttAt5xtto: Downloading webpage
[youtube] ShttAt5xtto: Downloading video info webpage
[youtube] ShttAt5xtto: Extracting video information
[youtube] ShttAt5xtto: Downloading DASH manifest
[youtube] ShttAt5xtto: Downloading DASH manifest
[debug] Invoking downloader on 'https://r1---sn-i3co-i3bd.googlevideo.com/videoplayback?id=4a1b6d02de71b6da&itag=248&source=youtube&requiressl=yes&ms=au&pcm2cms=yes&mm=31&mn=sn-i3co-i3bd&mv=m&pl=21&ratebypass=yes&mime=video/webm&gir=yes&clen=944543539&lmt=1441841852526088&dur=5177.480&key=dg_yt0&fexp=9408710,9409069,9409207,9412514,9415365,9415436,9415485,9416023,9416053,9416126,9416328,9416515,9416729,9417353,9417437,9417707,9417950,9418153,9418251,9418392,9418448,9419444,9419785,9419966,9420078,9420348,9420798&mt=1442308997&sver=3&signature=45FB403676510E0B6886DA88D27C63C881340CB3.540FFF30882B8C506FD459CF6DFEE6770BE9CC23&upn=ZjRbWDTslC8&ip=119.247.7.132&ipbits=0&expire=1442330650&sparams=ip,ipbits,expire,id,itag,source,requiressl,ms,pcm2cms,mm,mn,mv,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] HUMAN Extended version VOL.2-ShttAt5xtto.f248.webm has already been downloaded
[download] 100% of 900.79MiB
[debug] Invoking downloader on u'https://r1---sn-i3co-i3bd.googlevideo.com/videoplayback?ip=119.247.7.132&pcm2cms=yes&keepalive=yes&gir=yes&id=o-AH8n28L2u1ZuDJHgmZXKjxPAdxkzNplzYIzXc9YZrX1F&sver=3&sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpcm2cms%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&mn=sn-i3co-i3bd&mm=31&upn=7xvAvYj6Rm0&pl=21&mv=m&mt=1442308997&ms=au&signature=A8D31DCAD35D206F4BF3032CCFD8D7B219C0612E.4F4A86C0A31790525F7B074B6AE07E74227C3EE8&source=youtube&expire=1442330649&clen=68285477&itag=251&requiressl=yes&initcwndbps=3497500&ipbits=0&mime=audio%2Fwebm&key=yt5&lmt=1441834869777536&dur=5177.521&fexp=9408710%2C9409069%2C9409207%2C9412514%2C9415365%2C9415436%2C9415485%2C9416023%2C9416053%2C9416126%2C9416328%2C9416515%2C9416729%2C9417353%2C9417437%2C9417707%2C9417950%2C9418153%2C9418251%2C9418392%2C9418448%2C9419444%2C9419785%2C9419966%2C9420078%2C9420348%2C9420798&ratebypass=yes'
[download] HUMAN Extended version VOL.2-ShttAt5xtto.f251.webm has already been downloaded
[download] 100% of 65.12MiB
[ffmpeg] Merging formats into "HUMAN Extended version VOL.2-ShttAt5xtto.webm"
[debug] ffmpeg command line: ffmpeg -y -i 'HUMAN Extended version VOL.2-ShttAt5xtto.f248.webm' -i 'HUMAN Extended version VOL.2-ShttAt5xtto.f251.webm' -c copy -map 0:v:0 -map 1:a:0 'HUMAN Extended version VOL.2-ShttAt5xtto.temp.webm'
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Traceback (most recent call last):
  File "/var/services/homes/ohho//tool/youtube-dl/youtube_dl/YoutubeDL.py", line 1704, in post_process
    files_to_delete, info = pp.run(info)
  File "/var/services/homes/ohho//tool/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 403, in run
    self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
  File "/var/services/homes/ohho//tool/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 151, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError

@dstftw
Copy link
Collaborator

dstftw commented Sep 15, 2015

Update ffmpeg.

@dstftw dstftw closed this as completed Sep 15, 2015
@jbergknoff
Copy link

There seems to have been a change between 2015.08.28 to 2015.09.03. From these logs, it looks like the change involved preferring webm audio over m4a audio.

2015.09.03 failure

$ youtube-dl -f bestvideo[ext=mp4]+bestaudio --prefer-ffmpeg --merge-output-format mp4 --verbose https://www.youtube.com/watch?v=pmCkoAWArcE
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-f', u'bestvideo[ext=mp4]+bestaudio', u'--prefer-ffmpeg', u'--merge-output-format', u'mp4', u'--verbose', u'https://www.youtube.com/watch?v=pmCkoAWArcE']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2015.09.03
[debug] Python version 2.7.10 - Linux-3.16.0-29-generic-x86_64-with
[debug] exe versions: ffmpeg 2.8, ffprobe 2.8
[debug] Proxy map: {}
[youtube] pmCkoAWArcE: Downloading webpage
[youtube] pmCkoAWArcE: Downloading video info webpage
[youtube] pmCkoAWArcE: Extracting video information
[youtube] pmCkoAWArcE: Downloading DASH manifest
[youtube] pmCkoAWArcE: Downloading DASH manifest
[debug] Invoking downloader on 'https://r6---sn-q4fl6ne7.googlevideo.com/videoplayback?id=a660a4a00580adc1&itag=137&source=youtube&requiressl=yes&mm=31&mn=sn-q4fl6ne7&pl=20&mv=m&ms=au&nh=IgpwcjAxLmRmdzA2KgkxMjcuMC4wLjE&ratebypass=yes&mime=video/mp4&gir=yes&clen=83187324&lmt=1443936229003830&dur=274.065&mt=1444662397&key=dg_yt0&fexp=9407157,9408213,9408710,9409069,9412857,9414764,9416126,9417707,9418203,9418448,9419786,9419886,9420348,9420718,9421013,9421523,9421544,9421606,9421745,9422362&signature=7B017859C2F91726FBBF5C1CEAFA829CE692F9B8.863A6D4F7C183585AEFA13919F21AF82F6926149&sver=3&upn=noXOHhH9N8w&ip=70.122.244.227&ipbits=0&expire=1444684077&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,pl,mv,ms,nh,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f137.mp4
[download] 100% of 79.33MiB in 00:1437MiB/s ETA 00:000
[debug] Invoking downloader on u'https://r6---sn-q4fl6ne7.googlevideo.com/videoplayback?pl=20&upn=iQb6JR41Wr8&ipbits=0&mm=31&gir=yes&mn=sn-q4fl6ne7&id=o-ANaIepztiWhHN179-ZIEIZ6wUxbhpJ9hO-tTHIILI1F6&ip=70.122.244.227&initcwndbps=1577500&source=youtube&signature=7EE3050E3C88A6D7856E36C3D1CB0F2CF3F8BC79.8F7C32CD4B44288D1FD97611A8437E1BBB461D8A&mt=1444662397&mv=m&ms=au&lmt=1443952144949430&clen=4417768&keepalive=yes&dur=274.081&mime=audio%2Fwebm&key=yt6&sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpcm2%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&expire=1444684077&nh=IgpwcjAxLmRmdzA2KgkxMjcuMC4wLjE&fexp=9407157%2C9408213%2C9408710%2C9409069%2C9412857%2C9414764%2C9416126%2C9417707%2C9418203%2C9418448%2C9419786%2C9419886%2C9420348%2C9420718%2C9421013%2C9421523%2C9421544%2C9421606%2C9421745%2C9422362&sver=3&requiressl=yes&pcm2=yes&itag=251&ratebypass=yes'
[download] Destination: Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f251.webm
[download] 100% of 4.21MiB in 00:0022MiB/s ETA 00:005
[ffmpeg] Merging formats into "Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f137.mp4' -i 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f251.webm' -c copy -map 0:v:0 -map 1:a:0 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.temp.mp4'
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 1699, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/lib/python2.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 403, in run
    self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
  File "/usr/lib/python2.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 151, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError

2015.08.28 success

$ youtube-dl -f bestvideo[ext=mp4]+bestaudio --prefer-ffmpeg --merge-output-format mp4 --verbose https://www.youtube.com/watch?v=pmCkoAWArcE
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-f', u'bestvideo[ext=mp4]+bestaudio', u'--prefer-ffmpeg', u'--merge-output-format', u'mp4', u'--verbose', u'https://www.youtube.com/watch?v=pmCkoAWArcE']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2015.08.28
[debug] Python version 2.7.10 - Linux-3.16.0-29-generic-x86_64-with
[debug] exe versions: ffmpeg 2.8, ffprobe 2.8
[debug] Proxy map: {}
[youtube] pmCkoAWArcE: Downloading webpage
[youtube] pmCkoAWArcE: Downloading video info webpage
[youtube] pmCkoAWArcE: Extracting video information
[youtube] pmCkoAWArcE: Downloading DASH manifest
[youtube] pmCkoAWArcE: Downloading DASH manifest
[debug] Invoking downloader on 'https://r6---sn-q4fl6ne7.googlevideo.com/videoplayback?id=a660a4a00580adc1&itag=137&source=youtube&requiressl=yes&ms=au&mv=m&mn=sn-q4fl6ne7&mm=31&nh=IgpwcjAxLmRmdzA2KgkxMjcuMC4wLjE&pl=20&ratebypass=yes&mime=video/mp4&gir=yes&clen=83187324&lmt=1443936229003830&dur=274.065&sver=3&mt=1444662397&fexp=9406004,9408710,9409069,9414764,9415436,9416126,9416837,9417707,9417814,9418199,9418394,9418448,9418999,9419065,9419309,9419785,9420328,9420348,9420500,9421013,9421133,9421655,9421801,9421923&signature=02DCA9308EF805A5AA1DFB965715C607DC6584AE.2BBE49681FCBA02C4B70909233C3A69DF0CB496B&upn=3PxNWNQTAYc&key=dg_yt0&ip=70.122.244.227&ipbits=0&expire=1444684149&sparams=ip,ipbits,expire,id,itag,source,requiressl,ms,mv,mn,mm,nh,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f137.mp4
[download] 100% of 79.33MiB in 00:1690MiB/s ETA 00:000
[debug] Invoking downloader on 'https://r6---sn-q4fl6ne7.googlevideo.com/videoplayback?id=a660a4a00580adc1&itag=140&source=youtube&requiressl=yes&ms=au&mv=m&mn=sn-q4fl6ne7&mm=31&nh=IgpwcjAxLmRmdzA2KgkxMjcuMC4wLjE&pl=20&ratebypass=yes&mime=audio/mp4&gir=yes&clen=4355012&lmt=1443936130938067&dur=274.134&sver=3&mt=1444662397&fexp=9406004,9408710,9409069,9414764,9415436,9416126,9416837,9417707,9417814,9418199,9418394,9418448,9418999,9419065,9419309,9419785,9420328,9420348,9420500,9421013,9421133,9421655,9421801,9421923&signature=754C4B3074C5A4C7FDE8892EC47966730CE87FA9.0DEBC48447769467D6C80C61F6E6E6784A334D43&upn=3PxNWNQTAYc&key=dg_yt0&ip=70.122.244.227&ipbits=0&expire=1444684149&sparams=ip,ipbits,expire,id,itag,source,requiressl,ms,mv,mn,mm,nh,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f140.m4a
[download] 100% of 4.15MiB in 00:0005MiB/s ETA 00:005
[ffmpeg] Merging formats into "Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f137.mp4' -i 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.temp.mp4'
Deleting original file Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f137.mp4 (pass -k to keep)
Deleting original file Vivolytics pitches at REACH NeXT 2015-pmCkoAWArcE.f140.m4a (pass -k to keep)

@dstftw
Copy link
Collaborator

dstftw commented Oct 12, 2015

@jbergknoff since c9afb51 quality metadata for formats that have no such metadata in DASH manifest is extracted from an alternative source. In your particular case, bitrate of best audio format (251) is now recognized and correctly accepted as bestaudio. Since you force --merge-output-format to mp4 (note that mp4 + webm can't be merged into mp4 container) then it's solely your responsibility to properly select bestaudio like you do for bestvideo.

@jbergknoff
Copy link

@dstftw ah, thank you very much for the explanation.

@ralyodio
Copy link

ralyodio commented Jul 26, 2016

@dstftw how do you properly select bestaudio?

I'm still getting this error:

$ youtube-dl -f bestvideo[ext=mp4]+bestaudio 'https://www.youtube.com/watch?v=LIC0_fDp1Xw' -o "%(autonumber)s-%(title)s.%(ext)s" --merge-output-format mp4
[youtube] LIC0_fDp1Xw: Downloading webpage
[youtube] LIC0_fDp1Xw: Downloading video info webpage
[youtube] LIC0_fDp1Xw: Extracting video information
[youtube] LIC0_fDp1Xw: Downloading MPD manifest
[download] Destination: 00001-Lightning Strike Hits Pole in Chicago. July 24th 2016.f136.mp4
[download] 100% of 7.42MiB in 00:00
[download] Destination: 00001-Lightning Strike Hits Pole in Chicago. July 24th 2016.f251.webm
[download] 100% of 357.52KiB in 00:00
[ffmpeg] Merging formats into "00001-Lightning Strike Hits Pole in Chicago. July 24th 2016.mp4"
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

@yan12125
Copy link
Collaborator

For https://www.youtube.com/watch?v=LIC0_fDp1Xw, bestaudio selects webm (itag 251). This is not compatible with an MP4 container. The solution is forcing m4a audios:

youtube-dl -v -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' 'https://www.youtube.com/watch?v=LIC0_fDp1Xw' -o "%(autonumber)s-%(title)s.%(ext)s" --merge-output-format mp4

@lakhman
Copy link

lakhman commented Jun 22, 2017

Just had this error, the issue was using an old version of ffmpeg.
I (perhaps like many others) had ffmpeg installed via homebrew on Mac.

A simple brew upgrade ffmpeg fixed this. Hope this helps someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants