Michael Pravilov
Michael Pravilov

Reputation: 55

Is it okay to execute ffmpeg and do not use their library?

I need to extract audio from video and save it. FFmpeg has command for this purpose. I wonder if it is a right way to execute ffmpeg from my code and not to write code with their API functions.

The lack of this approach is that I use Qt Framework and need cross-platform application. Sometimes (especially in windows, because PATH variable doesn't set up automatically so call ffmpeg won't work) a user will need to indicate path to executable file to run in command line.

So both variants are possible to realize, but which is the best and correct one?

I don't really want to use their API because it is not so easy to understand and will take time to write my own code.

Thanks for any advice!

Upvotes: 1

Views: 882

Answers (2)

user7860670
user7860670

Reputation: 37578

Using standalone ffmpeg seems to be preferred in your case. You will have to bundle ffmpeg and it's dependencies along with your application. However there is no need to set or use PATH or other environment variables to launch ffmpeg. You should do it by supplying full path to ffmpeg executable.

Using libav API is indeed rather tricky. And I would like to mention that in general (depending on codec) ffmpeg and libav should not be considered stable and you should spawn a separate process to protect main executable from potential crash in this case as well. So complexity of this approach is much higher compared to first one.

Upvotes: 3

Adrian Maire
Adrian Maire

Reputation: 14865

Disclaim: I never used Qt with ffmpeg together myself, but have much experience with Qt especially.

Qt tends to try having everything in their library, wrapping many other content for convenience. Most of the time (All those I tested), it is still possible quite easily to use the original library without troubles, but the Qt facilitate integration.

As an example: QOpenGLWidget is a wrapper for OpenGL with their widget system, adding signals and slots, etc. I made some test using normal OpenGL and it worked fine.

In another project, we(my team, not me particularly) used ffmpeg to display video on a QtWidget. It works with limited problems (due to other architectural requirements).

Considering your use case, and especially that you are using ffmpeg for background processing and not for displaying video, you may IMO go ahead with high probability of success.

Upvotes: 0

Related Questions