ffmpeg get value from cropdetect

后端 未结 1 922
渐次进展
渐次进展 2020-12-05 19:49

Its possible to run cropdetect and crop in one line and get thumbs from video?

something like this

ffmpeg -ss 1 -i 0.flv -vf cropdetect=24:1         


        
相关标签:
1条回答
  • 2020-12-05 20:20

    cropdetect outputs to the console, so you can parse the output and then use it as a variable:

    ffmpeg -i input -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1
    

    This will result in something like:

    crop=640:480:0:50
    

    Then run your actual crop command:

    ffmpeg -i input -vf $cropvalue,scale=240:-1 -vframes 1 -qscale:v 2 output.jpg
    
    • -vcodec mjpeg, -an, and -f rawvideo are superfluous

    • Use -qscale:v to control jpg output quality. A sane range is 2-5 (a lower value is a higher quality).

    • Use the scale filter instead of -s; especially if you're already using filters. Also the scale filter will allow you to set a specific width or height and with -1 it will automatically provide the correct value to preserve aspect. Otherwise if you try to force a specific size you can risk a squished or stretched output.

    Obviously I'm not a PHP coder, but this should give you an idea at least.

    0 讨论(0)
提交回复
热议问题