I have been making a few experiments with GStreamer by using the gst-launch utility. However, ultimately, the aim is to implement this same functionality on my own application using GStreamer libraries.
我用gst-launch实用工具做了一些GStreamer的实验。但是,最终的目标是在我自己的应用程序中使用GStreamer库实现相同的功能。
The problem is that it's ultimately difficult (at least for someone that is not used to the GStreamer API) to "port" what I test on the command line to C/C++ code.
问题是,最终很难(至少对于那些不习惯GStreamer API的人来说)将我在命令行上测试的内容“移植”到C/ c++代码中。
An example of a command that I may need to port is:
我可能需要移植的一个命令的示例是:
gst-launch filesrc location="CLIP8.mp4" ! decodebin2 ! jpegenc ! multifilesink location="test%d.jpg"
What's the most "straight forward" way/approach to take such command and write it in C on my own app.
什么是最“直接”的方式/方法来获取这样的命令,并在我自己的应用程序中编写它。
Also, as a side question, how could I replace the multifilesink with the possibility of doing this work on memory (I'm using OpenCV to perform a few calculation on a given image that should be extracted from the video). Is it possible to decode directly to memory and use it right away without first saving to the filesystem? It could (and should) be sequential, I mean that would only move on to the next frame after I'm done with processing the current one so that I wouldn't have to keep thousands of frames in memory.
另外,作为一个次要的问题,我如何能够替换多文件的内容,以便在内存中进行这项工作(我正在使用OpenCV对从视频中提取的给定图像执行一些计算)。是否可以直接解码到内存,并在不首先保存到文件系统的情况下直接使用它?它可以(也应该)是连续的,我的意思是,在我处理了当前的帧之后,它只会移动到下一个帧,这样我就不必在内存中保留数千帧了。
What do you say?
你说什么?
3 个解决方案
#1
10
I found the solution. There's a function built in on GStreamer that parses gst-launch arguments and returns a pipeline. The function is called gst_parse_launch and is documented here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html
我找到了解决方案。在GStreamer上构建了一个函数来解析gst-launch参数并返回一个管道。该函数被称为gst_parse_launch,并在这里记录:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-gstreamer-gstparse.html。
I haven't tested it but it's possible the fastest solution to convert what have been testing on the command line to C/C++ code.
我还没有测试它,但它可能是最快的解决方案,可以将命令行上的测试转换成C/ c++代码。
#2
3
You could always pop open the source of gst-launch
and grab the bits that parse out the command-line and turn it into a GStreamer pipeline.
您可以随时打开gst-launch的源代码,获取解析命令行并将其转换为GStreamer管道的位。
That way you can just pass in the "command line" as a string, and the function will return a complete pipeline for you.
这样,您就可以将“命令行”作为字符串传递,函数将返回一个完整的管道。
#3
1
By the way, there is an interesting GStreamer element that provides a good way to integrate a processing pipeline into your (C/C++) application: appsink
顺便说一下,有一个有趣的GStreamer元素,它提供了将处理管道集成到您的(C/ c++)应用程序中的好方法:appsink。
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsink.html
With this one you can basically retrieve the frames from the pipeline in a big C array and do whatever you want with them. You setup a callback function, which will be activated every time a new frame is available from the pipeline thread...
有了这个,你基本上可以从一个大的C数组中从管道中获取帧,然后用它们做任何你想做的事情。您设置一个回调函数,每当从管道线程中获得新帧时,该函数将被激活。
#1
10
I found the solution. There's a function built in on GStreamer that parses gst-launch arguments and returns a pipeline. The function is called gst_parse_launch and is documented here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html
我找到了解决方案。在GStreamer上构建了一个函数来解析gst-launch参数并返回一个管道。该函数被称为gst_parse_launch,并在这里记录:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-gstreamer-gstparse.html。
I haven't tested it but it's possible the fastest solution to convert what have been testing on the command line to C/C++ code.
我还没有测试它,但它可能是最快的解决方案,可以将命令行上的测试转换成C/ c++代码。
#2
3
You could always pop open the source of gst-launch
and grab the bits that parse out the command-line and turn it into a GStreamer pipeline.
您可以随时打开gst-launch的源代码,获取解析命令行并将其转换为GStreamer管道的位。
That way you can just pass in the "command line" as a string, and the function will return a complete pipeline for you.
这样,您就可以将“命令行”作为字符串传递,函数将返回一个完整的管道。
#3
1
By the way, there is an interesting GStreamer element that provides a good way to integrate a processing pipeline into your (C/C++) application: appsink
顺便说一下,有一个有趣的GStreamer元素,它提供了将处理管道集成到您的(C/ c++)应用程序中的好方法:appsink。
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsink.html
With this one you can basically retrieve the frames from the pipeline in a big C array and do whatever you want with them. You setup a callback function, which will be activated every time a new frame is available from the pipeline thread...
有了这个,你基本上可以从一个大的C数组中从管道中获取帧,然后用它们做任何你想做的事情。您设置一个回调函数,每当从管道线程中获得新帧时,该函数将被激活。