go – FFmpeg I-P frame command in golang

I have been using the command below to get a specific frame from the video and get it into a buffer.

func ReadFrameAsJpeg(inFileName string, frameNum int) []byte {
    // Returns specified frame as []byte
    buf := bytes.NewBuffer(nil)
    err := ffmpeg.Input(inFileName).
        Filter("select", ffmpeg.Args{fmt.Sprintf("gte(n,%d)", frameNum)}).
        Output("pipe:", ffmpeg.KwArgs{"vframes": 1, "format": "image2", "vcodec": "mjpeg"}).
        WithOutput(buf, os.Stdout).Run()
    if err != nil {

While getting a specific frame according to a FrameNum, I want to also check which type of frame it is. Like using “pict_type” to get that information. I tried using a filter to get the frame type below, but it showed “error parsing the argument”. It should give the output with the “pict_type = P” or “pict_type = I”

Filter("select", ffmpeg.Args{fmt.Sprintf("eq(n,%d),showinfo", frameNum)}).

I am trying to implement the following command

$ ffmpeg -hide_banner -i INPUT.mp4 -filter:v "select=eq('n,3344'),showinfo" -frames:v 1 -map 0:v:0 -f null -

Read more here: Source link