mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
Catch possible exceptions when running ffprobe
This commit is contained in:
parent
1bd9258272
commit
da273188f3
1 changed files with 8 additions and 5 deletions
|
@ -2619,11 +2619,14 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_audio_codec(path):
|
def get_audio_codec(path):
|
||||||
|
try:
|
||||||
handle = subprocess.Popen(['ffprobe', '-show_streams', path],
|
handle = subprocess.Popen(['ffprobe', '-show_streams', path],
|
||||||
stderr=file(os.path.devnull, 'w'), stdout=subprocess.PIPE)
|
stderr=file(os.path.devnull, 'w'), stdout=subprocess.PIPE)
|
||||||
output = handle.communicate()[0]
|
output = handle.communicate()[0]
|
||||||
if handle.wait() != 0:
|
if handle.wait() != 0:
|
||||||
return None
|
return None
|
||||||
|
except (IOError, OSError):
|
||||||
|
return None
|
||||||
audio_codec = None
|
audio_codec = None
|
||||||
for line in output.split('\n'):
|
for line in output.split('\n'):
|
||||||
if line.startswith('codec_name='):
|
if line.startswith('codec_name='):
|
||||||
|
@ -2646,7 +2649,7 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||||
|
|
||||||
filecodec = self.get_audio_codec(path)
|
filecodec = self.get_audio_codec(path)
|
||||||
if filecodec is None:
|
if filecodec is None:
|
||||||
self._downloader.to_stderr(u'WARNING: no audio codec found in file')
|
self._downloader.to_stderr(u'WARNING: unable to obtain file audio codec with ffprobe')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
more_opts = []
|
more_opts = []
|
||||||
|
|
Loading…
Reference in a new issue