[SOLVED] how to create an h.264 encoded video from a series of still JPEGs?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to create an h.264 encoded video from a series of still JPEGs?
Hello,
I would like to encode a series of still JPEGs into an h.264 video clip. I looked at ffmpeg with x.264 installed but that gave me weird errors:
first when I tried this: ffmpeg -f image2 -i %12d.jpg test.mpg
I got:
Quote:
%12d.jpg: I/O error occurred
Usually that means that input file is truncated and/or corrupted.
then when I tried this: ffmpeg -f image2 -i * ../a.mpg
I got:
Quote:
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 640x480, 25 tbr, 25 tbn, 25 tbc
Could not open 'test.mpg'
My images are definitely not trucnated or corrupted and I have no idea why it wouldn't open test.mpg. I'm running both commands from command line logged in as a root in a directory that has all permissions necessary.
Has anyone achieved this with other tools? Any suggestions?
Just managed to convert those stills into an AVI video clip by using jpegtoavi:
jpegtoavi -f 6 640 480 * > test.avi
Did the job nicely but unfortunately there's no compression and 208 pictures that normally take up 11 MB are now converted into an AVI clip that takes up 9.8 MB. Anyone knows how to add any compression to it now? Preferably H.264 but anything will do at the moment.
onto my AVI clip that I got from the series of those stills. That produced some output-- seemingly a compressed video but unfortunately VideoLan player doesn't play it-- just displays a black box for some time and that's it.
test3.mp4 comes out as a neat, compressed playable video clip. Seems like I've been ranting here on my own, huh? Anyway, I got my series of still images compressed to h.264. Hope this helps to someone else too.
Did you make any more progress on this? I'm running down this path just now, but don't want to use jpeg2avi (my source is not always jpg & I'd rather not go through two level of lossy conversions).
I was just experimenting with Handbrake for Linux. Seems promising, but there's still the intermediate step of creating some sort of avi that it can understand, then convert *that* to the h264 mp4.
Ok I did a cut and paste of every command I could find to use ffmpeg to turn my jpegs into video and got the same error as at the top. I do not want to use another program and then turn around and do another encode afterwards. Could I be missing a codec or something. Is there a package I need to have before I compiled ffmpeg in order to work with jpegs? If so please any help would be greatly appreciated.
You can also pipe it back into ffmpeg, these extra steps/apps sometimes help to overcome issues with quirky inputs/outputs. You might also try the -intra option. And a lot of the above can be ommited or done with ffmpeg. And probably not the most efficient method.
A good long while ago, ffmpeg (or mencoder) was little picky about the input picture format. I used imagemagick to reconvert them to "-depth 8" and it then liked the input. The originals were generated in povray. I haven't had to repeat that extra step for a long time now. But it might be related to some of the issues you're having. Some formats have set output frame rates, you seemed to be missing any change to the input frame rate for the output format, which might be one cause of your issue(s). x264 also has a number of presets available, check out the -vpre option and the stuff in /usr/share/ffmpeg/*. They should be put after -vcodec as ffmpeg is a bit order picky. Also the defaults as they were are 25fps and 200kbps. Without a -r or -b or -sameq or -qscale option, you might not get desireable results.
Ok I did a cut and paste of every command I could find to use ffmpeg to turn my jpegs into video and got the same error as at the top. I do not want to use another program and then turn around and do another encode afterwards. Could I be missing a codec or something. Is there a package I need to have before I compiled ffmpeg in order to work with jpegs? If so please any help would be greatly appreciated.
One gotcha (and I've not done *any* research on how to get around it) is that it appears ffmpeg wants frame 1 to be labeled frame 1, so the sequence:
frame.0256.jpg
frame.0257.jpg
frame.0258.jpg
would not work. They would need to be renumbered to frames 0001,0002,and 0003. You will get the above error message if they are not renumbered.
Also, I've found that with less than 20 or so frames, you want to force single threaded or the video will be truncated.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.