Generating a video from an image with FFMPEG

My project involves developing a video editing application using JavaScript, ffmpeg, and Java. I have managed to extract frames from a video using FFMPEG and replace them with new images through canvas.toDataURL. However, I am facing an issue where these newly created PNG images are not being included in the final video created by FFMPEG.

Below is the code snippet for saving PNG images from an HTML5 canvas:


Base64 decoder = new Base64();
byte[] pic = decoder.decodeBase64(request.getParameter("pic"));
String frameCount = request.getParameter("frame");
InputStream in = new ByteArrayInputStream(pic);
BufferedImage bImageFromConvert = ImageIO.read(in);
String outdir = "output\\" + frameCount;
File file = new File(outdir);
if(file.isFile()) {
    if(file.delete()) {
        File writefile = new File(outdir);             
        ImageIO.write(bImageFromConvert, "png", file);
    }
}

Here's the code snippet for creating images from a video:


String filePath = "D:\\temp\\some.mpg";
String outdir = "output";
File file = new File(outdir);
file.mkdirs();
Map<String, String> m = System.getenv();

String commands = "D:\\ffmpeg-win32-static\\bin\\ffmpeg -i " + filePath + " -r 30  -f image2 " + outdir + "\\image%05d.png";
Process p = Runtime.getRuntime().exec(commands);

And finally, here's the code snippet for creating a video from images:


String filePath = "output";
File fileP = new File(filePath);
String commands = "D:\\ffmpeg-win32-static\\bin\\ffmpeg -f image2 -i " + fileP + "\\image%5d.png " + fileP + "\\video.mp4";
System.out.println(commands);
Runtime.getRuntime().exec(commands);
System.out.println(fileP.getAbsolutePath());

Answer №1

The creation was labeled as image%05d.png, but it should have been image%5d.png instead. The only difference is one less zero in the name. That's all there is to it!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Switch out the specific content within the p tag

Looking to update the highlighted text within a p tag. The code below addresses handling new line characters, but for some reason the replacement is not working as expected. Check out the HTML snippet: <p id="1-pagedata"> (d) 3 sdsdsd random: Subj ...

Returning data to be displayed in Jade templates, leveraging Express and Node.js

Yesterday, I had a question. Instead of using next() and passing an Error object, I decided to figure out what it was doing and replicate it. So now, when someone logs in and it fails, I handle it like this: res.render("pages/home", { ...

Do JavaScript functions in separate <script> tags exist in the global scope?

Here's a scenario I'm dealing with in an HTML file: <script> var my_function = function(param) { alert(param); } </script> <div> <!-- snip --> <script> $(function() { my_function("Hello wor ...

Using SOAP in a JavaScript-exclusive setting

I'm looking into utilizing SOAP as the backend services to supply data for my application. My query pertains to the feasibility of implementing this with just a JavaScript framework like Ember or Angular, without utilizing server-side languages such ...

Tips for organizing an array with index and key within a request's key

let task = { template_id: 3213123, username: "test", password: "test", boxes[0][text]:"ddasd", }; Is there a way to place the value of boxes[0][text ...

Move tables by dragging and dropping them into place

Currently, I am on the lookout for a drag and drop plugin that works with jQuery, Angular, or JavaScript to help me create dynamic tables. Specifically, I need a plugin that allows me to add new tables through drag and drop functionality. While I have com ...

Modal window closed - back to the top of the page

I am struggling with a simple modal popup window that does not maintain the scroll position when closed, instead returning you to the top of the page. I am looking for a way to keep it at the same scroll position without much knowledge of Javascript. You ...

What is the best way to utilize a color picker to apply CSS color to a parent element?

When the pencil glyphicon is clicked, a color picker appears. I only want to apply the selected color from the color picker to the list elements that are the grand parent of the pencil glyphicon. Here's a snippet of my Ruby front-end code: <% cat ...

Why does a java.lang.NullPointerException occur upon object instantiation?

It seems like this code should be working fine, but for some reason, it's giving an unexpected output. The issue is at: return planetArray[arr[0].viewPosition()].testCost(); Looking at my code below, I've checked thoroughly but can't figu ...

The image filter plugin is functioning properly in one project, however, it is not working in

After successfully using a plugin from w3schools to filter elements in one project, I encountered an issue when attempting to implement it in another project. Here is the link to the problematic code pen: https://codepen.io/zakero/pen/mZYBPz If anyone ca ...

The architecture of a Java web application can involve either multiple WAR files within an EAR container or a single WAR file with multiple JAR

I am in the process of developing a web application which is estimated to take about 1-2 months to complete. While I have a clear vision for the server-side, I am facing some uncertainties regarding the front-end aspect. This application will be composed ...

Real-time data update with Socket io: instantly refresh data on another page upon form submission without having to manually

What is the best way to utilize socket io in a situation where I have two pages open, one displaying a table of existing data and the other featuring a form for users to input new data? I want the table page to automatically update whenever a user submits ...

Start by retrieving information and then sending properties to a different component

I have been struggling with this issue for more than a week now. Despite thorough reading of the Next.js documentation and extensive online research, I still can't figure out what's wrong. It seems like I must be overlooking something important, ...

Performing string operations using an array of strings

I have an array of strings as shown below ["i.was.wen.the.coding", "i.am.wen.to", "i.am.new", "i.am", "i"] Each sentence in the array can be split by a period (.). I am looking to create a logical algorithm pattern to reconstruct a meaningful sentence by ...

How to ensure a div within an anchor tag occupies the full width in HTML and CSS?

In my code, I am working on creating multiple small boxes with images and centered text inside. The goal is to have these boxes clickable, where clicking the image will take you to a specific link. On desktop, I want a hover effect that darkens the image b ...

Struggling to delete elements from observable array within Knockoutjs framework

I am attempting to use knockoutjs to remove a user from an observable array called users. It seems like my viewModel may not be working correctly because it is within a document.ready function. Here is some context about the code below: My application fet ...

Angular Search Panel

I'm having trouble with the Angular Search box not working when I try to run it locally on my computer. The same code works perfectly fine on platforms like codepen, plunker, and jsfiddle. Can someone help me figure out what's going wrong? .ex ...

Aliasing Android layout resource IDs

Recently, I developed an application that utilizes two different fragments to display various video sources. Each fragment has its own layout file, both of which share a similar structure with minor differences such as the video surfaces and buttons. Des ...

How can I enable ongoing user input within Applab?

Currently, I am developing an app on code.org that allows users to input their subject scores and receive their corresponding grades. The final output includes the average score across all subjects. However, I have encountered a limitation where I can on ...

Is it possible to extract the value from the JSON response using this.responseText?

Having trouble extracting data from a json response This is the HTML code I am using. index.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head ...