Take the 2-minute tour ×
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It's 100% free, no registration required.

I loaded CHDK firmware on my old Canon IXUS 980IS and took 796 images, each weighing in at:

JPEG 4416x3312 4416x3312+0+0 8-bit sRGB 9.182MB 0.050u 0:00.049

So I want to convert 796 images into a movie. Each still could be a frame in a 24fps movie, so:

796 / 24 = 30 sec = half a minute video

FFMPEG fails with Killed

x264 [error]: malloc of size 83759040 failedime=00:00:00.-4 bitrate=N/A
Video encoding failed
Killed

Complete log

I guess the 4GB of RAM isn't enough memory. But why can't FFMPEG simply build the movie in a memory efficient manner?

Gstreamer fails

ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Your GStreamer installation is missing a plug-in.

Complete log

share|improve this question
    
Did you want the output movie to be 4416x3312 like the source frames? As you can tell from the log, the encoder wants a great deal of free memory to make a clip that size. What's the final use of the clip? –  Jim Mack May 18 at 12:57
    
Would be nice to be able to make a "4k movie" but 1080p size is probably more sensible. Still not sure why it needs so much memory. Can't it append frames? –  hendry May 18 at 13:07
2  
1080p is a 16x9 format, where your source frames are 4x3, so you'd have a pillar-box result. And '4K' can mean several things, but is also a widescreen format. So you'd need to crop to fit, or accept black bars. –  Jim Mack May 18 at 15:49
    
I'm not sure what is best without seeing the result. Don't have the experience. I do hate black bars though. –  hendry May 18 at 16:40
    
That's a x264 error, not ffmpeg. Does it work as expected if you use a native ffmpeg encoder? Just to test add -vcodec mpeg4 before the output name. Are you using a 32 or 64-bit build? –  LordNeckbeard May 20 at 16:57

2 Answers 2

The problem is that a sequence of images is not a video file. In order to convert it to a video format such as h.264, it has to load an entire group of pictures (probably somewhere around 15 of them) and then perform a whole bunch of calculations to determine how the images are related to each other. It then uses that information to determine what to actually store.

It doesn't store actual pictures, but rather it stores a couple of pictures (I frames) but then stores information about what changed from those frames to the next frames and what will change from those frames to the frames after (known as P and B frames). This is a big part of why h.264 compression (and most other modern video formats) are able to fit so much video in to such small amounts of space compared to how much space the images take on their own.

If you were to save it as something like an MJPEG where each image is actually stored on its own, then it would just be a matter of appending them together, but then the file size of the video would probably be unplayably huge.

share|improve this answer
1  
"...a sequence of images is not a video file". FWIW, that's just what ffmpeg treats it as: a stream in MJPEG format. Not that it helps the OP, just clarifying. What you say about compression is of course correct. But in a single-pass encoding there's no reason an encoder couldn't output / append each GOP as it's completed. I don't know of one that does, but it's not impossible. –  Jim Mack May 18 at 23:23
    
@JimMack - yeah, I was oversimplifying a bit and you are correct about the mjpeg bit. And yes, each GOP could be output separately, but just holding an entire GOP and the necessary analysis is going to take a fair bit of space for images that large. I don't know exactly how much, but it is a non-trivial task even for 1 GOP. –  AJ Henderson May 18 at 23:40

I followed Henderson's advice and wrote a little script to resize the images:

$ cat jpg2mp4.sh
test -d "$1" || exit
tmpdir=$(mktemp -d -p .)
counter=0
find $1 -iname '*.jpg' | while read jpg
do
        convert -resize 1440x1080 $jpg $tmpdir/IMG_$(printf "%04d" $counter).JPG
        counter=$((counter + 1))
done
echo ffmpeg -i $tmpdir/IMG_%4d.JPG test.mp4

It does work! I still wish ffmpeg could handle the original images and I also wish gstreamer would work! For further tips to enlarge a photo or adjust time, see this tip.

share|improve this answer
1  
I don't think you need to resize the images before giving them to ffmpeg, just tell ffmpeg what size you want the movie, these are the settings I tend to use: ffmpeg -r 15 -i img%04d.JPG -b 15M -s 1440x1080 out.avi. 15 frames per second, 15M bit rate, HD. –  Jamie Kitson May 19 at 9:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.