View Full Version : Encoding sequential JPGS or PNGs to MPEG1 or MPEG2 HELP?
TechieUK
24th January 2007, 22:59
My company has a piece of animation software which outputs a sequential series of PNG files, where you can specify the frames per second. The size of the output PNG file is 1005 wide by 685 high.
At present the PNG files are imported as a .lst file into a program called Blink, and converted to a Microsoft Video 1 type AVI under the belief that this is the most compatible way of getting the clip out to corporate clients to use, without special codecs etc being needed.
The typical 5 second clip can be over 10 mb and is fairly poor quality, and is emailed to clients which takes a while to do. Some animations may have 100 - 200 images - which are not used in view of the resultant file size - but ideally they need to be.
I thought encoding to MPEG 1 or MPEG 2 would be more efficient for emailing and retain quality more.
Can anyone suggest a reasonably priced MPEG encoder which will accept a series of sequentially named PNG images (or JPGS), and output a 620 width by 420 high media file - this is the size the Blink program outputs. Also can you give a brief idea on how it works if it isn't totally obvious.
As you may gather I am fairly new at this and would appreciate any help.
Many Thanks.
TDUK.
foxyshadis
25th January 2007, 04:12
Microsoft Video 1 is the most compatible... if it's still 1993. :p MPEG1 or WMV7 are good compatibility choices for legacy systems, any Windows 98 can play those.
To encode, all you need is avisynth (use ImageReader(), see avisynth.org for more info) and tmpegenc (http://www.tmpgenc.net/en/e_main.html) for MPEG, or avisynth and virtualdub for WMV-in-avi.
Pookie
26th January 2007, 03:57
I think Mpeg1 might be the lowest common denominator/most universal codec out there. I agree with foxyshadis that Avisynth is the way to go on this one. Combine it with ffmpeg or tmpgenc, and you have a free and high quality solution.
CoronaSequence("location_of_your_images\*.png", sort=1)
assumefps(25.0) #for our friends across the pond
bicubicresize(624,416)#use multiples of 16 - probably better to round down
converttoyv12()
ffmpeg -i inputscript.avs -bufsize 416 -vcodec mpeg1video -an -minrate 7000 -b 7000 -maxrate 7000 -y output.m1v
Use this specific version of ffmpeg http://tirnanog.fate.jp/mirror/ffmpeg/ffmpeg.rev6199.7z
You'll probably also need pthreadGC2.dll if you don't have it already.
pandy
26th January 2007, 13:18
QuEnc (eg latest 072) is very good as a MPEG encoder, also mpeg1 can be in native source size ie 1005x685 (in avisynth only AddBorders(2,1,2,1) should be added) - quality for 5000kbs is very good - such mpg should be played without any problems on normal PC (normal mean without any additional codec - only MS mpg1 decoder). Instead of quenc mentioned earlier TMPGENC can be used - for MPEG1 it is without any restriction.
Instead CoronaSequence (), ImageReader () can be used, and for TMPGENC converttoyv12() should be removed.
BTW TMPGENC can "tweak" frame rate so framerates lower than 23,976fps can be used.
TechieUK
27th January 2007, 00:06
Ok - I have a few problems.... I was hoping that it would be a program with a GUI and a simple point and click job, rather than editing text script files etc.
I seem to have installed AVIsynth, but can't get my head around what is needed, I have tried to look at the online help, but it baffles me.
I think I will use TMPGenc 3.0 Express which I already have to encode an .avs file I assume have to create, via notepad.
The thing is exactly what should be in the script??
For example: All my 300 png files are in my K hard drive in a test folder called K:\AVI_SYNTH
The animation program has a default folder which is used, and outputs the same name each time, sequencing the numbers. The only unknown is exactly how many frames it will make until each job is exported. It would be rare to be over 250 though.
Ideally I would like to have a default test.avs file which I can encode via TMPenc without having to re-edit it each time for frame numbers. i.e if the script refers to start frame 0 end frame 300 , will it matter if there are perhaps only 247 frames??? I would then like to simply use the same stored test.avs file for every single output animation, as the pngs will always be in the same folder.
I hope that makes a little sense - but can someone tell me EXACTLY what I have to type into notepad and then save as an avs file, based upon:
Location of files K:\AVI_SYNTH
File names ani2d_0000.png to ani2d_0300.png
Many thanks for the help so far -I think I have learned a little so far but not nearly enough!
setarip_old
27th January 2007, 00:22
Hi!
If scripting is daunting, you can accomplish your purpose easily with the DIRECT use of two freeware programs - "VirtualDubMod" and "TMPGEnc".
VirtualDubMod will automatically accept and concatenate sequentially named .JPGs into one .AVI file.
Then just load the .AVI into TMPGEnc and save as MPEG-1
(You can set the desired resolution in either of the programs)...
foxyshadis
27th January 2007, 03:48
If you do want to use a script with that formula, it would need to be:
ImageReader("K:\AVI_SYNTH\ani2d_%04d.png",fps=30)
If you want a 30fps file. It'll pick them up in order first to last. setarip's method works as well, you just have to have yet another lossless temp file that way.
Pookie
27th January 2007, 21:24
TechieUK - Yes, Avisynth can appear to be a bit much if you're just getting started with it. However, you can learn by example, as in this case. We'll help you. Go through the pain. Make yourself uniquely qualified in your job position. Having the talented foxyshadis helping you out is like getting free tennis lessons from MacInroe.
setarip_old does offer a perfectly fine alternative with Virtualdub . You can load the first PNG in the sequence and Virtualdub will automatically load the others. Save as an uncompressed AVI, then feed that AVI to your mpeg1 encoder.
foxyshadis - take a look at the newer imagesequence.dll docs
http://avisynth.org/warpenterprises/files/imagesequence_25_dll_20060414.zip
Had to set this exact scenario up for a client, although I don't recall why Coronasequence was needed - perhaps because the files were PNGs ?
foxyshadis
28th January 2007, 00:38
Yes, being able to use * is really nice if you don't have a well-defined format. (I was wondering at the disconnect between the plugin names, no wonder I was confused.)
I'm not that talented. >.> Don't you dare call me multi-talented! :p
smok3
28th January 2007, 01:03
if avisynth is a problem, you may be able to frameserve png sequence to your mpeg1 encoder also by using virtualdub 1.7 (experimental) - that is gui purely.
TechieUK
28th January 2007, 20:12
Ok,
Thanks for the pointers so far.
I have used the script:
ImageReader("K:\AVI_SYNTH\ani2d_%04d.png",fps=30)
where I have 200 png images in the AVI_Synth folder.
However when I feed the Test.avs file which contains the above script into TMPG, the output seems to have 1000 frames. Frames 0 - 200 are the ones showing what I want, the rest are black...... Why is this??? Where did the 1000 frame amount come from?? I got the result I wanted by cutting the frames out within TMPG (setting frame 200 as the end frame) - but this seems to correct an error which shouldn't be there in the first place I suspect.
Hope I am nearly there with some more help!!!
PS setarip_old - thanks for suggesting a uncompressed avi - the animation program can output an uncompressed avi, (which I now realise I could feed into TMPG), but I thought I might save time and disk space by avoiding this.
Pookie
29th January 2007, 06:51
Well done, man! You figured out the basics quickly. Once this little project is complete, you'll have to check out some of the
noise reduction and image enhancement plugins in Avisynth. They're so good in fact, you'll want to improve your skills just so you can use them :D
Please try the script below. It'll work, I just tested it - Proper number of frames, etc
1) Download the following plugin, unzip, and place the .dll into your C:\Program Files\AviSynth 2.5\plugins\ folder
http://avisynth.org/warpenterprises/files/imagesequence_25_dll_20060414.zip
Place a # in front of your imagereader line- let's try another method for the time being.
CoronaSequence("K:\AVI_SYNTH\*.png", sort=1) #This will automatically count and sort the list of png files
Assumefps(30.0) #Or Change to whatever your desired framerate might be
Spline36resize(624,416) #Multiples of 16 for better quality mpegs. Spline36resize is a sharp resizer.
Converttoyv12() #Delete if you're using Tmpgenc
If you'd like to try a scripted method using the above settings and with automatic mpeg1 encoding, download the following:
http://www.bestsharing.com/files/OQfGM214593/TechieUK.zip.html Unzip and check the TechieUK.avs file for correct paths (looks just like the code above). Doubleclick on
Process.bat to begin the encode. It took my P.O.S machine around 5 minutes to process 300 frames at 624x416 on a 2pass encode. It will audibly alert you when the encode has completed.
I prefer Coronasequence over Imagereader because it allows wildcards (*.png, in this case). As either way will work, Coronasequence is a bit easier in my opinion.
Let's get the configuration working and we can fine-tune later.
TechieUK
29th January 2007, 20:14
Pookie, many thanks- I will try this out and let you know how I get on in a couple of days.
Pookie
29th January 2007, 20:57
Updated the script, replacing the encoder. I'd use this one instead, techieUK
http://www.bestsharing.com/files/OQfGM214593/TechieUK.zip.html
pandy
30th January 2007, 09:44
Pookie but why resizing source? Seems that mpg1 with 5000kbps bitrate give quite nice quality for pictures in native size ie "PNG file is 1005 wide by 685 high."
Pookie
30th January 2007, 22:49
Makes no difference to me - I thought 620x420 was the dimensions he was interested in.:confused:
Aha, just read the first post. I recall that the input dimensions can't be odd numbers, so I wonder if the script will reject 1005x685...
EDIT - Confirmed. It fails if the dimensions aren't even/divisible. 1008x688 are the closest even numbers
setarip_old
30th January 2007, 23:18
PS setarip_old - thanks for suggesting a uncompressed avi - the animation program can output an uncompressed avi, (which I now realise I could feed into TMPG), but I thought I might save time and disk space by avoiding this.There would be -0- difference in FINAL disk space because you'd delete the .AVI file after you'd completed the conversion with TMPGEnc...
pandy
31st January 2007, 14:49
Makes no difference to me - I thought 620x420 was the dimensions he was interested in.:confused:
Aha, just read the first post. I recall that the input dimensions can't be odd numbers, so I wonder if the script will reject 1005x685...
EDIT - Confirmed. It fails if the dimensions aren't even/divisible. 1008x688 are the closest even numbers
For MPEG both (H&V) sizes should be dividable without fraction by at least 8 (16 for interlace video)
so picture must be aligned by at least 8
620x420 seems to be limitations of software (Bink?), if results can be in native resolution then better is no resizing them. But this irrelevant for TechieUK (probably).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.