Skip to content

Commit

Permalink
Raise proper errors if file not found in 'parse_ffmpeg_infos'
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jan 20, 2021
1 parent 68d04fd commit 8aeed0c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ffmpeg. It is quite ugly, as there are many pitfalls to avoid
"""

import os
import re
import subprocess as sp
import warnings
Expand Down Expand Up @@ -752,10 +753,17 @@ def ffmpeg_parse_infos(
# print the whole info text returned by FFMPEG
print(infos)

return FFmpegInfosParser(
infos,
filename,
fps_source=fps_source,
check_duration=check_duration,
decode_file=decode_file,
).parse()
try:
return FFmpegInfosParser(
infos,
filename,
fps_source=fps_source,
check_duration=check_duration,
decode_file=decode_file,
).parse()
except Exception as exc:
if os.path.isdir(filename):
raise IsADirectoryError(f"'{filename}' is a directory")
elif not os.path.exists(filename):
raise FileNotFoundError(f"'{filename}' not found")
raise exc

0 comments on commit 8aeed0c

Please sign in to comment.