LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 05-30-2009, 12:20 PM   #1
archie1983
LQ Newbie
 
Registered: May 2009
Posts: 4

Rep: Reputation: 1
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?
 
Old 05-30-2009, 01:11 PM   #2
archie1983
LQ Newbie
 
Registered: May 2009
Posts: 4

Original Poster
Rep: Reputation: 1
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.
 
Old 05-30-2009, 02:18 PM   #3
archie1983
LQ Newbie
 
Registered: May 2009
Posts: 4

Original Poster
Rep: Reputation: 1
almost there

Ok, I just launched this:

ffmpeg -r 6 -i test.avi -vcodec libx264 -y -f h264 test1.mp4

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.

Any ideas?
 
Old 05-30-2009, 02:29 PM   #4
archie1983
LQ Newbie
 
Registered: May 2009
Posts: 4

Original Poster
Rep: Reputation: 1
got it

Ok, this command does it:

ffmpeg -i test.avi -vcodec libx264 test3.mp4

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.
 
Old 06-17-2009, 04:33 PM   #5
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
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.

Any other, better ways?
 
Old 06-18-2009, 03:56 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The usual way is listed here:
http://ffmpeg.org/faq.html#SEC14
 
Old 09-18-2009, 02:29 PM   #7
darkone66669
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 85

Rep: Reputation: 15
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.
 
Old 09-18-2009, 06:13 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
If the file already exists (previous failure) you need to include -y which lets you overwrite the output file.

ffmpeg is not infallable, but you can pipe it's output to other programs.

ffmpeg -f image2 -loop_input -r 30000/1001 -i picture%03d.png -sameq -aspect 16:9 -t 00:00:10.000 -pix_fmt yuv420p -f yuv4mpegpipe - | yuvscaler -v 0 -n n -M BICUBIC -O SIZE_720x480 | mpeg2enc -f 8 -a 3 -F 4 -b 7000 -o dvd_movie.m2v

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.

HTH
 
Old 09-20-2009, 01:21 PM   #9
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by darkone66669 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to download and install video codec h.264 rock3_nat Linux - Newbie 7 08-10-2011 01:41 AM
Converting h.264 avi video to mpg btbx Linux - Software 1 06-12-2008 07:48 PM
h.264 Matroska video choppy under ffmpeg? mrchaos Linux - Software 0 12-28-2005 02:27 AM
Is there a possible way to play H.264 encoded file(s) in linux? hkl8324 Linux - Software 0 07-29-2005 03:43 PM
Encoding to H.264 video codec? ixus_123 Linux - Software 1 02-21-2005 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration