func (f FFMpeg) CalculateFrameRate(ctx context.Context, v *VideoFile) (*FrameInfo, error) {
	var args Args
	args = append(args, "-nostats")
	args = args.Input(v.Path).
		VideoCodec(VideoCodecCopy).
		Format(FormatRawVideo).
		Overwrite().
		NullOutput()

	command := f.Command(ctx, args)
	var stdErrBuffer bytes.Buffer
	command.Stderr = &stdErrBuffer // Frames go to stderr rather than stdout
	err := command.Run()
	if err == nil {
		var ret FrameInfo
		stdErrString := stdErrBuffer.String()
		ret.NumberOfFrames = getFrameFromRegex(stdErrString)

		time := getTimeFromRegex(stdErrString)
		ret.FrameRate = math.Round((float64(ret.NumberOfFrames)/time)*100) / 100

		return &ret, nil
	}

	return nil, err
}
// CalculateFrameRate calculates the frame rate and number of frames of the video file.
// Used where the frame rate or NbFrames is missing or invalid in the ffprobe output.
CalculateFrameRate calculates the frame rate and number of frames of the video file.
Used where the frame rate or NbFrames is missing or invalid in the ffprobe output.
// CalculateFrameRate calculates the frame rate and number of frames of the video file . // Used where the frame rate or NbFrames is missing or invalid in the ffprobe output .
func (f FFMpeg) CalculateFrameRate(ctx context.Context, v *VideoFile) (*FrameInfo, error) {
	var args Args
	args = append(args, "-nostats")
	args = args.Input(v.Path).
		VideoCodec(VideoCodecCopy).
		Format(FormatRawVideo).
		Overwrite().
		NullOutput()
	command := f.Command(ctx, args)
	var stdErrBuffer bytes.Buffer
	command.Stderr = &stdErrBuffer 
	err := command.Run()
	if err == nil {
		var ret FrameInfo
		stdErrString := stdErrBuffer.String()
		ret.NumberOfFrames = getFrameFromRegex(stdErrString)
		time := getTimeFromRegex(stdErrString)
		ret.FrameRate = math.Round((float64(ret.NumberOfFrames)/time)*100) / 100
		return &ret, nil
	}
	return nil, err
}
func ( f FFMpeg ) CalculateFrameRate ( ctx context . Context , v * VideoFile ) ( * FrameInfo , error ) { var args Args args = append ( args , " " ) args = args . Input ( v . Path ) . VideoCodec ( VideoCodecCopy ) . Format ( FormatRawVideo ) . Overwrite ( ) . NullOutput ( ) command := f . Command ( ctx , args ) var stdErrBuffer bytes . Buffer command . Stderr = & stdErrBuffer err := command . Run ( ) if err == nil { var ret FrameInfo stdErrString := stdErrBuffer . String ( ) ret . NumberOfFrames = getFrameFromRegex ( stdErrString ) time := getTimeFromRegex ( stdErrString ) ret . FrameRate = math . Round ( ( float64 ( ret . NumberOfFrames ) / time ) * 100 ) / 100 return & ret , nil } return nil , err }
CalculateFrameRate calculates the frame rate and number of frames of the video file.
CalculateFrameRate calculates the frame rate and number of frames of the video file .
// Frames go to stderr rather than stdout