ruby - FFmpeg extracts different number of frames when using -filter_complex together with the split filter -


i fiddling ffmpeg, extracting jpg pictures videos. splitting input stream 2 output stream -filter_complex, because process videos direct http link (scarce free space on vps), , don't want read through whole video twice (traffic quota scarce). furthermore need 2 series of pitcures, 1 applying filters (fps changing, scale, unsharp, crop, scale) , selecting them naked eye, , other series being untouched (expect fps changing, , cropping black borders), using them furter processing after selecting first series. call ffmpeg command ruby script, contains string interpolation / substitution in form #{}. working command line looked like:

ffmpeg -y -fflags +genpts -loglevel verbose -i #{url} -filter_complex "[0:v]fps=fps=#{new_fps.round(5).to_s},split=2[in1][in2];[in1]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0]}:#{crop[1]},scale=#{thumb_width}:-1:flags=lanczos,unsharp,lutyuv=y=gammaval(#{gammaval})[out1];[in2]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0]}:#{crop[1]}[out2]" -f #{format} -c copy #{options} -map_chapters -1 - -map '[out1]' -f image2 -q 1 %06d.jpg -map '[out2]' -f image2 -q 1 big_%06d.jpg 

#{options} set when output mp4, value "-movflags frag_keyframe+empty_moov" can send standard output without seeking capability , uploading stream somewhere without making huge temporary video files. 2 series of pictures, 1 of them filtered, sharpened, other in fact untouched. , output stream of video on standard output handled open3.popen3 library connecting output stream of input of 2 other commands.

problem arise when seek in video given point , omitting streamed video output on stdout. try apply combined seeking, fast seek before given time code , slow seek exact time code, given in floating seconds:

ffmpeg -report -y -fflags +genpts -loglevel verbose -ss #{(seek_to-seek_before).to_s} -i #{url} -ss #{seek_before.to_s} -t #{t_duration.to_s} -filter_complex "[0:v]fps=fps=#{pics_per_sec},split=2[in1][in2];[in1]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0]}:#{crop[1]},scale=#{thumb_width}:-1:flags=lanczos,unsharp,lutyuv=y=gammaval(#{gammaval})[out1];[in2]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0]}:#{crop[1]}[out2]" -map '[out1]' -f image2 -q 1  %06d.jpg -map '[out2]' -f image2 -q 1  big_%06d.jpg 

running command needed 2 series of pictures, contains different number of images, 233 vs. 484.

actual values can read interpolated / substituted command line:

ffmpeg -report -y -fflags +genpts -loglevel verbose -ss 1619.0443599999999 -i fabf.avi -ss 50.0 -t 46.505879999999934 -filter_complex "[0:v]fps=fps=5,split=2[in1][in2];[in1]crop=iw-0:ih-0:0:0,scale=280:-1:flags=lanczos,unsharp,lutyuv=y=gammaval(0.526316)[out1];[in2]crop=iw-0:ih-0:0:0[out2]" -map '[out1]' -f image2 -q 1  %06d.jpg -map '[out2]' -f image2 -q 1  big_%06d.jpg 

detailed log can found here: http://www.filefactory.com/file/1yih17k2hrmp/ffmpeg-20160610-223820.txt before last line shows 188 duplicated frames.

i tried passing "-vsync 0" option, didn't help. when generate 2 series of images in 2 consecutive steps, 2 different command lines, no problem arises, same amount of pictures in both series of course. question be, how can use later command line, generating 2 series of images 1 reading / parsing of remote video file?

you have replicate -ss -t options 2nd output i.e.

...-f image2 -q 1 %06d.jpg -map '[out2]' -ss 50 -t 46.5 -f image2 -q 1 big_%06d.jpg 

each output option (those not before -i) apply output follows.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -