View Full Version : Make MPG1 from non-standard sized AVI
TWagner
24th January 2008, 16:46
Hello,
I use the StackHorizontal/StackVertical filter to combine several video clips into a single clip. First I usually crop the original video clips to get rid of "uninteresting" areas. Quite often the resulting clip's size deviates quite much from the standard sizes like 720 x 576. I did not succeed yet to make MPEG1 files out of such clips. I give my videos away to other people which is the reason why I prefer MPEG1: these videos will play on all (windows) computers.
Why is it that I can't make MPEG1 clips from my avi files? Do I probably have an incomplete understanding of the MPEG1 format?
The videos I prepare show laboratory tests of a transparent vessel with a throughflow of water which has been marked with dye. Stacking the videos from single experiments is a very nice means to compare the flows. As the vessels are typically long and not very high the clips exhibit a lot of "empty" space. I crop the clips to get rid of these areas. The resulting clips unfortunately deviate quite much from a 720 x 576 size. I tried to squeeze my videos into a 720 x 576 size but this again gives me a lot of ugly empty space.
Any comment regarding my question is very much welcome.
Thanks in advance,
Thomas
Guest
25th January 2008, 03:17
All you've told us is that you did not succeed. That is not enough information.
What MPEG1 encoder are you using?
What is the frame size of the input stream? Post your Avisynth script.
What is the exact error/problem that you encounter?
I successfully make MPEG1 videos using TMPGEnc in a variety of frame sizes.
2Bdecided
28th January 2008, 11:00
You can have any size, but the width and height must be multiples of 16, otherwise the encoder will pad, crash, or add garbage.
The colour space can also limit the width and height. For YV12, both must be multiples of 2; for YUY2 only width has this restriction.
Hope this helps. If not, post more details!
Cheers,
David.
TWagner
30th January 2008, 16:23
First of all thank you very much for your answers.
Sorry for my incomplete first mail. Here the missing information:
The source clips I used are avi-files with 720x576 frame size, 25fps and 24 Bits. The following script crops the two original clips, stacks them and adds some border and some title:
a0 = AVISource( "Clip 1.avi" )
b0 = AVISource( "Clip 2.avi" )
a0 = Crop( a0, 32, 392, -16, -16 )
b0 = Crop( b0, 32, 392, -16, -16 )
bordercolor = RGB(0,0,0)
a0 = AddBorders( a0, 5, 30, 5, 5, bordercolor )
b0 = AddBorders( b0, 5, 30, 5, 5, bordercolor )
tc = RGB(255,255,255)
hc = RGB(0,0,0)
tf = "Microsoft Sans Serif"
a0 = Subtitle( a0, "Test 01", x=5, y=5, font=tf, size=24, text_color=tc, halo_color=hc )
b0 = Subtitle( b0, "Test 02", x=5, y=5, font=tf, size=24, text_color=tc, halo_color=hc )
finalclip = StackVertical( a0, b0 )
return finalclip
#----------------------------------------------------------
# function
#----------------------------------------------------------function RGB( Int r, Int g, Int b )
{
return r * 65536 + g * 256 + b
}
I ran this script with VirtualDubMod 1.5.10.2 (on Windows XP, AVISynth 2.5.7) and saved the resulting clip as an uncompressed avi-file.
According to 2Bdecided's advice the resulting clip now has a size of multiples of 16 in height and width (672x416). This avi-file plays without problem with the windows media player 9.
I used mencoder (MPlayer-1.0rc2) with different parameters to create an mpg1-file:
1. mencoder.exe -ovc lavc -lavcopts vcodec=mpeg1video "Clip.avi" -o "Clip.mpg"
2. mencoder.exe -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video "Clip.avi" -o "Clip.mpg"
3. mencoder.exe -of mpeg -mpegopts format=mpeg1:tsaf:vwidth=672:vheight=416 -ovc lavc -lavcopts vcodec=mpeg1video "Clip.avi" -o "Clip.mpg"
None of these settings gave an mpg-file that WMP could play. WMP played the file created with settings 1 but totally distorted. Settings 2 made WMP crash and settings 3 caused WMP to display an error message (Windows Media Player encountered an unknown error).
Then I followed neuron2's advice and used TMPGenc 2.5 and without changing the settings it created an mv1-file that WMP played without complaining. Further tests with different frame sizes showed that TMGenc needs frame sizes of multiples of 8.
I understand that the problem is not with AVISynth. I only have to take care of the frame size. On the other hand I wonder what settings I would have to use with mencoder to get an mpg1-file playable by WMP.
Thanks to both of you for your help,
Thomas
P.S.: Until recently I have been using Ulead MediaStudio Pro only and always used a frame size of 720x576. I am amazed by the possibilities AVISynth offers (also together with avslib). But all that stuff that is behind video (containers, muxing, decoders etc.) is very new to me.
2Bdecided
31st January 2008, 11:07
According to 2Bdecided's advice the resulting clip now has a size of multiples of 16 in height and width (672x416).
It doesn't - it's 682x408.
If you drop it onto VirtualDub it'll tell you that YV12 images for output must have a width divisible by 4, and you won't get any video. That's probably why your MPEG-1 encoder is having problems!
Cheers,
David.
TWagner
4th February 2008, 13:23
Hi David,
you're right: according to the code snippet I have posted the resulting clip has the size that you calculated. To do tests with TMPGenc I deleted the lines with the "AddBorders" command so that the final clip had a frame size of 672 x 416.
Having found a solution for my problem - that is using TMPGenc for encoding to mpg1 - I am still wondering what settings I would have to use with mencoder to get an mpg1 clip that WMP could play.
Greetings,
Thomas
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.