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

Post-processing failure #10328

Closed
kunal394 opened this issue Aug 13, 2016 · 7 comments
Closed

Post-processing failure #10328

kunal394 opened this issue Aug 13, 2016 · 7 comments

Comments

@kunal394
Copy link

@kunal394 kunal394 commented Aug 13, 2016

I am using youtube-dl with python.
$ youtube-dl --version
2016.08.12

Python code for downloading a video from youtube and then converting it to mp3 format is as follows:

import youtube_dl, sys

mp3 = {
        'verbose': True,
        'fixup': 'detect_or_warn',  # Automatically correct known faults of the file.
        'format': 'bestaudio/best', # choice of quality
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '320',
            }],
        'extractaudio' : True,      # only keep the audio
        'audioformat' : "mp3",      # convert to mp3 
        'outtmpl': '%(title)s',     # name the file the title of the video
        'noplaylist' : True,        # only download single song, not playlist
    }

mp4 = {
        'verbose': True,
        'fixup': 'detect_or_warn',  # Automatically correct known faults of the file.
        'format': 'bestvideo+bestaudio/bestvideo[ext=mp4]+bestaudio/bestvideo[ext=mkv]+bestaudio/best', # choice of quality
        #'extractaudio' : True,      # only keep the audio
        'videoformat' : "mp4",      # convert to mp4
        'outtmpl': '%(title)s',     # name the file the title of the video
        'noplaylist' : True,        # only download single song, not playlist
    }

mp3_playlist = {
        'verbose': True,
        'fixup': 'detect_or_warn',  # Automatically correct known faults of the file.
        'format': 'bestaudio/best', # choice of quality
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '320',
            }],
        'extractaudio' : True,      # only keep the audio
        'audioformat' : "mp3",      # convert to mp3 
        'outtmpl': '%(title)s',     # name the file the title of the video
        'noplaylist' : False,        # only download single song, not playlist
    }

mp4_playlist = {
        'verbose': True,
        'fixup': 'detect_or_warn',  # Automatically correct known faults of the file.
        'format': 'bestvideo+bestaudio/bestvideo[ext=mp4]+bestaudio/bestvideo[ext=mkv]+bestaudio/best', # choice of quality
        'videoformat' : "mp4",      # convert to mp4 
        'outtmpl': '%(title)s',     # name the file the title of the video
        'noplaylist' : False,        # only download single song, not playlist
    }

def down(url, t):
    if t == 'mp4':                                                                                                                                    
        options = mp4
    elif t == 'mp3':
        options = mp3
    elif t == 'mp4p':
        options = mp4_playlist
    elif t == 'mp3p':
        options = mp3_playlist
    ydl = youtube_dl.YoutubeDL(options)
    r = ydl.extract_info(url)

if __name__ == "__main__":
    url = sys.argv[1]
    t = sys.argv[2]
    down(url, t)

But sometimes the post-processing faces the following error:

$ ytd 'https://www.youtube.com/watch?v=saxV9TtubV8&list=PLMy-e1JL4mgvDHXin6IsfnAu4zpzqbpwU&index=2' mp3p
WARNING: Parameter outtmpl is bytes, but should be a unicode string. Put  from __future__ import unicode_literals  at the top of your code file or consider switching to Python 3.x.
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.08.12
[debug] Python version 2.7.12 - Linux-4.4.0-34-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
[debug] Proxy map: {'ftp': 'ftp://proxy.iiit.ac.in:8080/', 'all': 'socks://proxy.iiit.ac.in:8080/', 'http': 'http://proxy.iiit.ac.in:8080/', 'https': 'https://proxy.iiit.ac.in:8080/', 'no': 'localhost, 127.0.0.1, iiit.ac.in, .iiit.ac.in, iiit.net, .iiit.net, 172.16.0.0/12, 192.168.0.0/16, 10.0.0.0/8', 'socks': 'socks://proxy.iiit.ac.in:8080/'}
[youtube:playlist] Downloading playlist PLMy-e1JL4mgvDHXin6IsfnAu4zpzqbpwU - add --no-playlist to just download video saxV9TtubV8
[youtube:playlist] PLMy-e1JL4mgvDHXin6IsfnAu4zpzqbpwU: Downloading webpage
[download] Downloading playlist: Log Horizon OST
[youtube:playlist] playlist Log Horizon OST: Downloading 35 videos
[download] Downloading video 1 of 35
[youtube] pdg7Q9f4tvo: Downloading webpage
[youtube] pdg7Q9f4tvo: Downloading video info webpage
[youtube] pdg7Q9f4tvo: Extracting video information
[youtube] pdg7Q9f4tvo: Downloading MPD manifest
[debug] Invoking downloader on u'https://r5---sn-o3o-itql.googlevideo.com/videoplayback?id=a5d83b43d7f8b6fa&itag=251&source=youtube&requiressl=yes&pcm2cms=yes&mn=sn-o3o-itql&mm=31&ms=au&mv=m&initcwndbps=10407500&pl=24&ratebypass=yes&mime=audio/webm&gir=yes&clen=3292766&lmt=1409062005469245&dur=163.001&sver=3&upn=uq4_HQEud8A&key=dg_yt0&mt=1471090057&fexp=9419452,9422596,9428398,9429983,9431012,9433096,9433223,9433946,9435526,9435667,9436835,9438327,9438662,9438805,9439580,9439811,9440833,9440903,9441192,9442094,9442331,9442424,9442426,9442550,9442982,9443269,9443423,9443680&signature=9848B8681C28CEA374BD62AA22EAE6E248DCCFCC.5D7B320C28688E019C932FACF54B139229F9514B&ip=14.139.82.6&ipbits=0&expire=1471112317&sparams=ip,ipbits,expire,id,itag,source,requiressl,pcm2cms,mn,mm,ms,mv,initcwndbps,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Log Horizon OST 1 - Main 'Log Horizon' Theme has already been downloaded
[download] 100% of 3.14MiB
[debug] avconv command line: avprobe -show_streams 'file:Log Horizon OST 1 - Main '"'"'Log Horizon'"'"' Theme'
[ffmpeg] Destination: mp3
[debug] ffmpeg command line: avconv -y -i 'file:Log Horizon OST 1 - Main '"'"'Log Horizon'"'"' Theme' -vn -acodec libmp3lame -b:a 320k file:mp3
ERROR: audio conversion failed: file:mp3: Invalid argument
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1832, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/postprocessor/ffmpeg.py", line 294, in run
    'audio conversion failed: ' + e.msg)
PostProcessingError

Traceback (most recent call last):
  File "/home/networking/Desktop/ks/iiit/network_sec/ytdl/ytdl.py", line 80, in <module>
    down(url, t)
  File "/home/networking/Desktop/ks/iiit/network_sec/ytdl/ytdl.py", line 75, in down
    r = ydl.extract_info(url)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 702, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 863, in process_ie_result
    extra_info=extra)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 755, in process_ie_result
    extra_info=extra_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 702, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 748, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1430, in process_video_result
    self.process_info(new_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1768, in process_info
    self.post_process(filename, info_dict)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1834, in post_process
    self.report_error(e.msg)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 565, in report_error
    self.trouble(error_message, tb)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 535, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: audio conversion failed: file:mp3: Invalid argument

I am not able to figure out whether I have made some mistake in the code or if this is a bug? But since this does not happens every time, I am guessing this is a bug. Also, I think everyone can notice that the file parameter is missing from the avconv command, so maybe this bug is present in the post-processing part of the youtube-dl module.

Also please suggest any other changes I should make to my code so that the file being downloaded always gets converted to the mp3 format.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 13, 2016

Please post the command you use and the outputs.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 13, 2016

Add extension to outtmpl: %(title)s.%(ext)s.

@dstftw dstftw closed this Aug 13, 2016
@kunal394
Copy link
Author

@kunal394 kunal394 commented Aug 13, 2016

@dstftw, does the line 'audioformat' : "mp3" has any reason to be there?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 13, 2016

No since you manage postprocessors by yourself.

@kunal394
Copy link
Author

@kunal394 kunal394 commented Aug 13, 2016

yeah thought so. anyway thanks!

@WojtekReu
Copy link

@WojtekReu WojtekReu commented Oct 28, 2016

youtube-dl --version
2016.10.26
youtube-dl --verbose --extract-audio --audio-format m4a https://www.youtube.com/watch?v=ss7EJ-PW2Uk
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--verbose', u'--extract-audio', u'--audio-format', u'm4a', u'https://www.youtube.com/watch?v=ss7EJ-PW2Uk']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.10.26
[debug] Python version 2.7.9 - Linux-3.16.0-4-amd64-x86_64-with-debian-8.6
[debug] exe versions: avconv 11.8-6, avprobe 11.8-6, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] ss7EJ-PW2Uk: Downloading webpage
[youtube] ss7EJ-PW2Uk: Downloading video info webpage
[youtube] ss7EJ-PW2Uk: Extracting video information
[youtube] {22} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] ss7EJ-PW2Uk: Downloading player https://s.ytimg.com/yts/jsbin/player-en_US-vflx7_SPL/base.js
[youtube] {43} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {18} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {36} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {17} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {136} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {247} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {135} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {244} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {134} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {243} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {133} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {242} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {160} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {278} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {140} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {171} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {249} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {250} signature length 42.42, html5 player en_US-vflx7_SPL
[youtube] {251} signature length 42.42, html5 player en_US-vflx7_SPL
[debug] Invoking downloader on u'https://r1---sn-f5f7ln7z.googlevideo.com/videoplayback?initcwndbps=1923750&dur=10810.841&nh=IgpwcjAyLndhdzAyKgkxMjcuMC4wLjE&ipbits=0&key=yt6&upn=K56VBGiDe-w&keepalive=yes&itag=251&clen=210198311&mime=audio%2Fwebm&ip=79.98.147.86&requiressl=yes&pl=24&mn=sn-f5f7ln7z&mm=31&source=youtube&mv=m&gcr=pl&ms=au&id=o-AGy9bE_VQephBYvjVRhFGoymQh6oCV9-iWiqoAaVvm88&expire=1477670371&gir=yes&lmt=1449626085202287&sparams=clen%2Cdur%2Cei%2Cgcr%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&mt=1477648538&ei=gyETWOidDoGlW7SXt-AB&signature=BCB7C2DBD1ABE20FB2AF216F7C730D8BCF312DC2.A0BE05EFA5EDA7505B2ABE2D3FD593D525875840&ratebypass=yes'
[download] Destination: 3 Hour Relaxing Guitar Music - Meditation Music, Instrumental Music, Calming Music, Soft Music, ☯2432-ss7EJ-PW2Uk.webm
[download] 100% of 200.46MiB in 01:12
[debug] avconv command line: avprobe -show_streams 'file:3 Hour Relaxing Guitar Music - Meditation Music, Instrumental Music, Calming Music, Soft Music, ☯2432-ss7EJ-PW2Uk.webm'
[ffmpeg] Destination: 3 Hour Relaxing Guitar Music - Meditation Music, Instrumental Music, Calming Music, Soft Music, ☯2432-ss7EJ-PW2Uk.m4a
[debug] ffmpeg command line: avconv -y -i 'file:3 Hour Relaxing Guitar Music - Meditation Music, Instrumental Music, Calming Music, Soft Music, ☯2432-ss7EJ-PW2Uk.webm' -vn -acodec aac -q:a 5 -bsf:a aac_adtstoasc 'file:3 Hour Relaxing Guitar Music - Meditation Music, Instrumental Music, Calming Music, Soft Music, ☯2432-ss7EJ-PW2Uk.m4a'`
ERROR: audio conversion failed: Add '-strict experimental' if you want to use it.
Traceback (most recent call last):
  File "/tmp/aa/venv/local/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 1837, in post_process
    files_to_delete, info = pp.run(info)
  File "/tmp/aa/venv/local/lib/python2.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 296, in run
    'audio conversion failed: ' + e.msg)
PostProcessingError
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Oct 28, 2016

@WojtekReu Don't use avconv. Install ffmpeg > 3.0 instead.

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