frame extraction: fixed pixel format for PNG. Added PNG/JPG option.

This commit is contained in:
iperov 2019-03-23 18:27:38 +04:00
parent cbe2ebca7f
commit 668a3e23a1

View file

@ -23,21 +23,24 @@ def extract_video(input_file, output_dir, output_ext=None, fps=None):
io.log_err("input_file not found.")
return
if output_ext is None:
output_ext = io.input_str ("Output image format (extension)? ( default:png ) : ", "png")
if fps is None:
fps = io.input_int ("Enter FPS ( ?:help skip:fullfps ) : ", 0, help_message="How many frames of every second of the video will be extracted.")
if output_ext is None:
output_ext = io.input_str ("Output image format? ( jpg png ?:help skip:png ) : ", "png", ["png","jpg"], help_message="png is lossless, but extraction is x10 slower for HDD, requires x10 more disk space than jpg.")
for filename in Path_utils.get_image_paths (output_path, ['.'+output_ext]):
Path(filename).unlink()
job = ffmpeg.input(str(input_file_path))
kwargs = {}
kwargs = {'pix_fmt': 'rgb24'}
if fps != 0:
kwargs.update ({'r':str(fps)})
if output_ext == 'jpg':
kwargs.update ({'q:v':'2'})
job = job.output( str (output_path / ('%5d.'+output_ext)), **kwargs )
try: