Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use FFMPEG library vs CLI

In terms of performance, what is better to use, an FFMPEG library(like https://github.com/kokorin/Jaffree) or the FFMPEG command line interface?

like image 448
Lauren Avatar asked Dec 20 '25 19:12

Lauren


1 Answers

My initial thought was: this is an "opinionated" question, thus off topic. But then, I think there is a clear technical answer for this

Basically you want to programmatically use FFMPEG to solve some problem for you, from within your Java application. Therefore the answer is pretty much straight forward: when you want to things programmatically, then use that interface, that is intended for programmatic usage.

Meaning: you definitely prefer the API over using "raw" system command calls to invoke the client manually.

Why:

  • A library/API gives you compile time safety. You have method calls with types, and whatnot
  • The CLI ... only allows you to pull together a string "manually", and to fire that. If it works: great, but if not ... you only find out at runtime.

Beyond that: if you are talking about a "serious" project, then sooner or later, your code might want to do different things. And then the points from above just "multiply". Instead of one single command line string you can prepare for, you know build that string dynamically.

Long story short: for a simple problem, maybe the CLI is a good solution. But then: why wrap that in java, then you could as well write a small shell or python script as a small wrapper around the call you need.

like image 150
GhostCat Avatar answered Dec 23 '25 09:12

GhostCat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!