Dump last frame of video file using ffmpeg/mencoder/transcode et. al

后端 未结 5 1640
执笔经年
执笔经年 2021-01-01 18:21

I\'d like to grab the last frame in a video (.mpg, .avi, whatever) and dump it into an image file (.jpg, .png, w

5条回答
  •  温柔的废话
    2021-01-01 18:46

    I couldn't get Nelson's solution to work. This worked for me. https://gist.github.com/samelie/32ecbdd99e07b9d8806f

    EDIT (just in case the link disappears, here is the shellscript—bobbogo):

    #!/bin/bash
    
    fn="$1"
    of=`echo $1 | sed s/mp4/jpg/`
    
    lf=`ffprobe -show_streams "$fn" 2> /dev/null | grep nb_frames | head -1 | cut -d \= -f 2`
    rm -f "$of"
    let "lf = $lf - 1"
    ffmpeg -i $fn -vf select=\'eq\(n,$lf\) -vframes 1 $of
    

提交回复
热议问题