0

I'm trying to use JMF to make a video using multiple jpg images. These images are also saved using ImageIO of Java itself. Unfortunately, I cannot find a code sample or a working code/class to accomplish make the video using JMF.

There was a JpegImagesToMovie.java class here: http://www.oracle.com/technetwork/java/javase/documentation/jpegimagestomovie-176885.html but that link seems broken.

Can someone please post a working code, or tell me some other way of making videos with java and a different class?

I think a working code on this page might help others like me in future.

BTW, I also tried to use ffmpeg to compile the video, but that says similar to:

image2 codec not found 

When we use java ImageIO to make jpg images, are they not compatible with ffmpeg codecs?

java command:

ImageIO.write(capture, "jpg", new File( uploadPath, filename));

This is the ffmpeg error:

ffmpeg.exe -f image2 -i pic\s%d.jpeg -vcodec mpeg2video vid\video.mpg
FFmpeg version SVN-r7760, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-memalign-hack --enable-gpl --cpu=i686 --enable-swscaler --enable-pthreads --enable-avisynth --enable-mp3lame --enable-xvid --enable-x264 --enable-libnut --enable-libogg --enable-vorbis --enable-libtheora --enable-faad --enable-faac --enable-libgsm --enable-dts --enable-a52 --enable-amr_nb --enable-amr_wb 
  libavutil version: 49.2.0
  libavcodec version: 51.29.0
  libavformat version: 51.8.0
  built on Jan 29 2007 19:58:47, gcc: 3.4.6
[image2 @ 00931554]Could not find codec parameters (Video: mjpeg)
pic\sd.jpeg: could not find codec parameters
Community
  • 1
  • 1
jeet
  • 745
  • 3
  • 10
  • 15
  • 1
    Can you post the ffmpeg command with response? – d33pika Jan 29 '13 at 09:41
  • 1
    *"that link seems broken"* Try [this one](http://stackoverflow.com/a/2173398/418556). – Andrew Thompson Jan 29 '13 at 09:54
  • Hello, I've posted the ffmpeg error I get. I get this error with any image2 command I use. Thanks for the JpegImagesToMovie.java code. It's too advanced for my level of java. If somehow I can get the ffmpeg to get working, that'd be best. Thanks – jeet Jan 29 '13 at 14:27

1 Answers1

1

Looks like this command works using ffmpeg:

ffmpeg -f image2 -i img%d.jpg a.avi

Just 1 more question. I added the command to my java program like:

Runtime.getRuntime().exec("ffmpegp.exe -f image2 -i pic\\s%d.jpg vid\\video.avi");

Which is creating the video! Is there a way to "track" when video creation is complete, so that a message on java GUI can be shown, like, "video made" etc.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
jeet
  • 745
  • 3
  • 10
  • 15