0

I am creating video editing application using JavaScript, ffmpeg and java. Using FFMPEG i have created extract n frame of video, than using canvas.toDataUrl I am replacing new image with existing image frame rate and everything has taken care, but when I use these image to create video, FFMPEG never include newly created PNG image.

code to save png image from 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; //Random rand = new Random(); File file = new File(outdir); if(file.isFile()){ if(file.delete()){ File writefile = new File(outdir); ImageIO.write(bImageFromConvert, "png", file); } } 

Code for creating image from video

String filePath = "D:\\temp\\some.mpg"; String outdir = "output"; File file = new File(outdir); file.mkdirs(); Map<String, String> m = System.getenv(); /* * String command[] = * {"D:\\ffmpeg-win32-static\\bin\\ffmpeg","-i",filePath * ,"-r 30","-f","image2",outdir,"\\user%03d.jpg"}; * * ProcessBuilder pb = new ProcessBuilder(command); pb.start(); */ String commands = "D:\\ffmpeg-win32-static\\bin\\ffmpeg -i " + filePath + " -r 30 -f image2 " + outdir + "\\image%05d.png"; Process p = Runtime.getRuntime().exec(commands); 

code for creating video from image

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()); 
4
  • 1
    Does changing image%5d.png to image%05d.png in your code for creating video from image make any difference? Commented Aug 27, 2012 at 11:29
  • uer1559108 It worked, can you explain me how you come to know this. I have not noticed that. Well thank you very much i was struggle from couple of hours Commented Aug 27, 2012 at 11:53
  • @AndrewThompson thanks i got answer Commented Aug 27, 2012 at 11:54
  • @yashprit see my answer below. Commented Aug 27, 2012 at 13:28

1 Answer 1

3

You have declared the creation to be image%05d.png and using it ias image%5d.png. So there is one zero less in the name. That's it!

Sign up to request clarification or add additional context in comments.

2 Comments

but when i saw image name was very 00000i.png without extra bit anyways solution is working fine
The name is correct in the file created. It was wrong in the program part where you were using it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.