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());