golang中的FFmpeg IP帧命令
我一直在使用下面的命令从视频中获取特定的帧并将其放入缓冲区。
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 {
fmt.Println(err)
panic(err)
}
在根据Framenum获得特定的框架时,我还想检查它是哪种类型的框架。喜欢使用“ pict_type”获取这些信息。我尝试使用过滤器以获取下面的帧类型,但显示出“解析参数的错误”。它应该为输出提供“ pict_type = p”或“ pict_type = i”
Filter("select", ffmpeg.Args{fmt.Sprintf("eq(n,%d),showinfo", frameNum)}).
我正在尝试实现以下命令
$ ffmpeg -hide_banner -i INPUT.mp4 -filter:v "select=eq('n,3344'),showinfo" -frames:v 1 -map 0:v:0 -f null -
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 {
fmt.Println(err)
panic(err)
}
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 -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是指定
showinfo
作为选择
过滤选项的一部分,而不是定义2个不同的过滤器。假设您正在使用这个库,您需要做这样的事情:我不做这样的事情:我没有熟悉GO语言,因此可能需要解决语法问题。
编辑:
是的,它应该是一个不同的过滤器。
对于Golang,它可以使用,
You are specifying
showinfo
as a part ofselect
filter options, instead of defining 2 different filters. Assuming that you are using this library, you need to do something like this:I'm not familiar with go language so there maybe a syntax issue that you may need to sort out.
Edit:
Yes it is right it should be a different filter.
For golang it works using,