@@ -52,36 +52,35 @@ function M:preload(job)
5252 return false
5353 end
5454
55- -- stylua: ignore
56- local cmd = Command (" ffmpeg" ):arg ({
57- " -v" , " quiet" , " -threads" , 1 , " -hwaccel" , " auto" ,
58- " -skip_frame" , " nokey" ,
59- " -an" , " -sn" , " -dn" ,
60- })
55+ local cmd = Command (" ffmpeg" )
56+ :stderr (Command .PIPED )
57+ :arg { " -v" , " warning" , " -hwaccel" , " auto" , " -threads" , 1 , " -an" , " -sn" , " -dn" }
6158
6259 if percent ~= 0 then
6360 cmd :arg { " -ss" , math.floor (meta .format .duration * percent / 100 ) }
6461 end
65- cmd :arg { " -i" , tostring (job .file .url ) }
62+ cmd :arg { " -skip_frame " , " nokey " , " - i" , tostring (job .file .url ) }
6663 if percent == 0 then
6764 cmd :arg { " -map" , " disp:attached_pic" }
6865 end
6966
7067 -- stylua: ignore
71- local status , err = cmd :arg ({
68+ local output , err = cmd :arg ({
7269 " -vframes" , 1 ,
7370 " -q:v" , 31 - math.floor (rt .preview .image_quality * 0.3 ),
7471 " -vf" , string.format (" scale='min(%d,iw)':'min(%d,ih)':force_original_aspect_ratio=decrease:flags=fast_bilinear" , rt .preview .max_width , rt .preview .max_height ),
7572 " -f" , " image2" ,
7673 " -y" , tostring (cache ),
77- }):status ()
74+ }):output ()
7875
79- if not status then
76+ if not output then
8077 return true , Err (" Failed to start `ffmpeg`, error: %s" , err )
81- elseif not status .success then
82- return false , Err (" `ffmpeg` exited with error code: %s" , status .code )
83- else
78+ elseif output .status .success then
8479 return true
80+ elseif output .stderr :find (" No filtered frames for output stream" , 1 , true ) then
81+ return true , Err (" No more keyframes available" )
82+ else
83+ return false , Err (" `ffmpeg` exited with error code %s: %s" , output .status .code , output .stderr )
8584 end
8685end
8786
0 commit comments