Can I interact with ffmpeg using java in a simple way
5 hours ago, taurasnewx said:can you clarify
Absolutely not...I refuse to clarify.
Anyways, to the non-sarcastic response. Which bit would you like clarification on? [I've also done a slight overview below, but I am typing this quickly as I don't have a bunch of time now...I might come back to this later and fix it up]
An example of what I am running with my ffmpeg [explaining this in c# terms, there must be Java equivalents of Process but I can't bother looking into it right now]
Process ffmpeg = new Process(); ffmpeg.StartInfo.UseShellExecute = false; ffmpeg.StartInfo.FileName = APP_LOCATION + "ffmpeg.exe"; ffmpeg.StartInfo.Arguments = String.Format( "-v quiet -i \"{0}\" -vf \"select = not(mod(n\\, 300)), scale=480:270\" -vsync vfr -an -frames:v 100 -c:v bmp -f image2pipe pipe:", _fileLocation ); ffmpeg.StartInfo.RedirectStandardOutput = true; ffmpeg.StartInfo.CreateNoWindow = true; ffmpeg.Start();
There is actually an amazingly lack of examples on the internet I find in regards to the image2pipe and pipe: parts...but effectively what the above command does is pipe the all of the images (every 300 frames...so in my case every 10 seconds, and only the first 100 results that match that) into standard out (as a bmp format). [In my case, I essentially fit the entire cut segment into memory because it fits my usecase and I can't be bothered to spend more time writing correct buffers for just a quick one off project I was doing]
From there, I can just chop up the bytes from the standard output and make it into bitmaps...i.e. since it's bitmaps I know that it will be a fixed size, so I can chop up the memory into the bytes corresponding to each image and just process that (in my case I think it was 388854 bytes per image)...but it's easy to calculate as I could just change it to -frames:v 1 and then see how many bytes the standard out is.
And presto, you have the image from the video file
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now