mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-15 09:33:44 -07:00
frame extraction: fixed pixel format for PNG. Added PNG/JPG option.
This commit is contained in:
parent
cbe2ebca7f
commit
668a3e23a1
1 changed files with 7 additions and 4 deletions
|
@ -23,21 +23,24 @@ def extract_video(input_file, output_dir, output_ext=None, fps=None):
|
||||||
io.log_err("input_file not found.")
|
io.log_err("input_file not found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if output_ext is None:
|
|
||||||
output_ext = io.input_str ("Output image format (extension)? ( default:png ) : ", "png")
|
|
||||||
|
|
||||||
if fps is None:
|
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.")
|
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]):
|
for filename in Path_utils.get_image_paths (output_path, ['.'+output_ext]):
|
||||||
Path(filename).unlink()
|
Path(filename).unlink()
|
||||||
|
|
||||||
job = ffmpeg.input(str(input_file_path))
|
job = ffmpeg.input(str(input_file_path))
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {'pix_fmt': 'rgb24'}
|
||||||
if fps != 0:
|
if fps != 0:
|
||||||
kwargs.update ({'r':str(fps)})
|
kwargs.update ({'r':str(fps)})
|
||||||
|
|
||||||
|
if output_ext == 'jpg':
|
||||||
|
kwargs.update ({'q:v':'2'})
|
||||||
|
|
||||||
job = job.output( str (output_path / ('%5d.'+output_ext)), **kwargs )
|
job = job.output( str (output_path / ('%5d.'+output_ext)), **kwargs )
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue