I'm trying to use ffmpeg for generating a video file from timelapse images. Somehow I didn't find out which codec resp. which parameters I have to use in ffmpeg, that the video file is playable with JavaFX's MediaPlayer
. I tried these codecs:
- libx264 (
ffmpeg -f image2 -i %05d.jpg -r 30 -filter:v crop=4000:2250:0:0 -s 1920x1080 -vcodec libx264 -preset ultrafast -qp 0 Timelapse3.mp4
) - mpeg4 (
ffmpeg -f image2 -i %05d.jpg -r 30 -filter:v crop=4000:2250:0:0 -s 1920x1080 -vcodec mpeg4 -qscale 1 ../Timelapse.avi
)
But they didn't work with JavaFX. What codec and parameter do I have to use for a high quality output?
Try this
Replace the file name in the quotes with your file name. The file name numbering should start with 0 then go to 1, 2, 3, 4 and so on
This is how my file names look
Mandibular hollow 1 micron.gizmofill0.gizmoslice.jpg
Mandibular hollow 1 micron.gizmofill17.gizmoslice.jpg
Mandibular hollow 1 micron.gizmofill16994.gizmoslice.jpg
My files range between 198kb and 47kb in size. I have about 18500 files. All the files combined are about 2.9GB. This will generate a movie file at 50 frames per second that is around 25MB
ffmpeg -framerate 50 -i "Mandibular hollow 1 micron.gizmofill%d.gizmoslice.jpg" -s 1638x1004 -c:v libx264 -pix_fmt yuv420p output.mp4
This controller code works for me
This is the .fxml file
Here is the application file
The following worked for me if I have an input as mp4 (but it should work accordingly with other input formats, as in your case the image timelapse):
ffmpeg -i input.mp4 -vcodec h264 -vf scale=1920x1080 -an -pix_fmt yuv420p output.mp4
So the important parts are:
-an
or replace with working audio codec conversion)The
avi
container format isn't supported by JavaFX so won't work - your first example should however play ball ok - I've tried it and it works for me.You could also try forcing the mp4 container with the same
f
switch but just before the output file:(Also try the above with libx264.)