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

Misleading error message on Ctrl+C while downloading with ffmpeg #8300

Closed
dstftw opened this issue Jan 22, 2016 · 5 comments
Closed

Misleading error message on Ctrl+C while downloading with ffmpeg #8300

dstftw opened this issue Jan 22, 2016 · 5 comments

Comments

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 22, 2016

#8256 introduced a misleading error message on Ctrl+C, now it's ERROR: unable to download video instead of expected ERROR: Interrupted by user. Reproducible on Windows python 2.6 and python 3, not reproducible on python 2.7.

Python 2.6

[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'http://www.twitch.tv/riotgames/v/6528877', u'-v']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2016.01.15
[debug] Git HEAD: 032f232
[debug] Python version 2.6.6 - Windows-2003Server-5.2.3790-SP2
[debug] exe versions: ffmpeg N-77953-gcc83177, ffprobe N-77953-gcc83177, rtmpdump 2.4
[debug] Proxy map: {}
[twitch:vod] 6528877: Downloading vod info JSON
[twitch:vod] 6528877: Downloading vod access token
[twitch:vod] 6528877: Downloading m3u8 information
[debug] Invoking downloader on u'http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8'

[download] Destination: LCK Summer Split - Week 6 Day 1-v6528877.mp4
[debug] ffmpeg command line: ffmpeg -y -headers 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/20.0 (Chrome)
' -i http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8 -f mp4 -c copy -bsf:a aac_ad
tstoasc 'file:LCK Summer Split - Week 6 Day 1-v6528877.mp4.part'
ffmpeg version N-77953-gcc83177 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
 --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --
enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 14.100 / 55. 14.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 25.100 /  6. 25.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, hls,applehttp, from 'http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8':
  Duration: 04:46:48.79, start: 61.509000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 123 kb/s
    Stream #0:1: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709/bt709/iec61966-2-1), 1280x720, 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
[mp4 @ 00000000004f0240] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 00000000004f0240] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'file:LCK Summer Split - Week 6 Day 1-v6528877.mp4.part':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=2-31, 30 fps, 30 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 123 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   80 fps= 46 q=-1.0 Lsize=    1071kB time=00:00:03.45 bitrate=2536.8kbits/s speed=1.98x
video:1014kB audio:52kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.450022%
Exiting normally, received signal 2.
ERROR: unable to download video
Traceback (most recent call last):
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 1691, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 677, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 723, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 1361, in process_video_result
    self.process_info(new_info)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 1628, in process_info
    raise UnavailableVideoError(err)
UnavailableVideoError: [Errno 22] Invalid argument

Python 3

[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['http://www.twitch.tv/riotgames/v/6528877', '-v']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2016.01.15
[debug] Git HEAD: 032f232
[debug] Python version 3.4.3 - Windows-2003Server-5.2.3790-SP2
[debug] exe versions: ffmpeg N-77953-gcc83177, ffprobe N-77953-gcc83177, rtmpdump 2.4
[debug] Proxy map: {}
[twitch:vod] 6528877: Downloading vod info JSON
[twitch:vod] 6528877: Downloading vod access token
[twitch:vod] 6528877: Downloading m3u8 information
[debug] Invoking downloader on 'http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8'
[download] Destination: LCK Summer Split - Week 6 Day 1-v6528877.mp4
[debug] ffmpeg command line: ffmpeg -y -headers 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/20.0 (Chrome)
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
' -i http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8 -f mp4 -c copy -bsf:a aac_ad
tstoasc 'file:LCK Summer Split - Week 6 Day 1-v6528877.mp4.part'
ffmpeg version N-77953-gcc83177 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
 --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --
enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 14.100 / 55. 14.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 25.100 /  6. 25.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, hls,applehttp, from 'http://vod.edgecast.hls.twitch.tv/v1/AUTH_system/vods_75a0/riotgames_15001215120_261543898/chunked/index-muted-HM49I092CC.m3u8':
  Duration: 04:46:48.79, start: 61.509000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 123 kb/s
    Stream #0:1: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709/bt709/iec61966-2-1), 1280x720, 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
[mp4 @ 00000000004f0240] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 00000000004f0240] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'file:LCK Summer Split - Week 6 Day 1-v6528877.mp4.part':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=2-31, 30 fps, 30 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 123 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   53 fps= 42 q=-1.0 Lsize=     690kB time=00:00:02.55 bitrate=2211.4kbits/s speed=2.04x
video:647kB audio:39kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534105%
Exiting normally, received signal 2.
ERROR: unable to download video data: [Errno 22] Invalid argument
Traceback (most recent call last):
  File "C:\Dev\git\youtube-dl\master\youtube_dl\downloader\hls.py", line 51, in real_download
    retval = proc.wait()
  File "C:\python\python343\lib\subprocess.py", line 1163, in wait
    timeout_millis)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 1623, in process_info
    success = dl(filename, info_dict)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\YoutubeDL.py", line 1565, in dl
    return fd.download(name, info)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\downloader\common.py", line 342, in download
    return self.real_download(filename, info_dict)
  File "C:\Dev\git\youtube-dl\master\youtube_dl\downloader\hls.py", line 57, in real_download
    proc.communicate(b'q')
  File "C:\python\python343\lib\subprocess.py", line 945, in communicate
    self.stdin.close()
OSError: [Errno 22] Invalid argument
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jan 22, 2016

Seems related to http://bugs.python.org/issue19612, see http://stackoverflow.com/questions/23688492/oserror-errno-22-invalid-argument-in-subprocess. Maybe we can catch and ignore EINVAL from proc.communite()?

@dstftw
Copy link
Collaborator Author

@dstftw dstftw commented Jan 22, 2016

Side note: pre-#8256 approach on Windows produces perfectly playable mp4 files when interrupted with Ctrl+C.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jan 22, 2016

So previously on windows did you get the message Exiting normally, received signal 2. from ffmeg?

Does it mean that it also catches the Ctrl-C?

When it errors with UnavailableVideoError: [Errno 22] Invalid argument, is the video playable? (I guess yes, since ffmpeg exits with Exiting normally, received signal 2.)

@dstftw
Copy link
Collaborator Author

@dstftw dstftw commented Jan 22, 2016

So previously on windows did you get the message Exiting normally, received signal 2. from ffmeg?

Yes.

When it errors with UnavailableVideoError: [Errno 22] Invalid argument, is the video playable? (I guess yes, since ffmpeg exits with Exiting normally, received signal 2.)

Yes, it's playable.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jan 23, 2016

If in windows subprocesses always receive the Ctrl-C, we could do:

if is_windows:
    proc.wait()
else:
    proc.communicate(b'q')

I would need to reboot the computer to load the Windows partition and make sure everything is working, so if someone could try it I would appreciate it.

@dstftw dstftw closed this in 56401e1 Feb 6, 2016
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.