Hi -
On Tue, 15 Feb 2005, Eric Jorgensen wrote:
> I am currently creating some mpeg video from stills
> (png and jpeg) but am having some trouble with aspect
I would avoid JPEG as much as possible - the lossy nature of jpeg
causes the mpeg2 encoding (which is of course lossy ;)) to produce
less than stellar results. PNG is MUCH preferable!
> ratios and the rectangular pixel problem. I am
> working in NTSC and creating in 720x480.
> However, my understanding is that I should be creating it in
> 720x"something else" and letting the conversion
> utility (jpeg2yuv/png2yuv?) worry about sizing?
Close but not quite. The conversion utilities do not do any
resampling/resizing. To perform the resampling step you need to
use a scaling program such as 'y4mscaler'. It's not part of
mjpegtools but does require mjpegtools can be obtained from:
http://www.mir.com/DMG
If you're using the last release version of mjpegtools (1.6.2) you'll
want the 0.6.2 version of y4mscaler, if you're using the cvs version
of mjpegtools you'll want the 0.8.1 version of y4mscaler
Once you have that then pay particular attention to:
http://www.mir.com/DMG/aspect.html
Especially the first three sections: Definitions, Quick Facts and
DV Frame Sizes
and one of the references at the bottom of that page:
http://www.uwasa.fi/~f76998/video/conversion/
specifically paragraph 4.5.3.
> My command line right now looks like:
>
> png2yuv -f 24 -I p -b 1 -j k%04d.png | \
> yuvfps -r 30000:1001 | mpeg2enc -f 8 -o video.m2v
guaranteed to not do the Right Thing :(
> I am about to start a big project and want to make
> sure that I don't shoot myself in the foot later.
Ready to dive in (simple algegra and arithmetic only ;))?
In the past the advice was to create a 4/3 image using 1:1 (square)
pixels on the computer at 720x540 and then scale to 720x480. This
is not exactly correct because a 720x480 does NOT represent a
4/3 image - it's slightly wider (extra 8 pixels on each side). It will
be "close" (~1% error in aspect) though.
Go thru the references and you'll find that NTSC full frame is 704x480
NOT 720x480. If you really want 720x480 I'll get to that in a minute
or two...
Given that we want a 704x480 10:11 frame what size frame needs to be
generated using 1:1 pixels?
Two ways to do this.
1) You can generate the frames slightly narrower and scan UP to the
desired width - if you have artwork with thin lines then this is
the approach you want to take:
a) 1:1 pixels
b) Frame height (H) of 480
c) Display Aspect Ratio (DAR) of 4:3
d) The equation (from "Definitions") above
W DAR
- = ---
H SAR
or
W (4/3)
- = -----
480 (1/1)
I get W = 640. So you should generate 640x480 PNG images and then
AFTER conversion (png2yuv) scale the data with something like:
... y4mscaler -I sar=1:1 -O sar=10:11 -O size=704x480 ...
The OTHER way is to create the images slightly taller and scale
vertically (this tends to cause flickering if you have thin lines
in the generated images). You specify the desired width and solve
for the height.
a) 1:1 pixels
b) Frame width (W) of 704
c) DAR of 4:3
d) same equation as above:
704 (4/3)
--- = -----
W (1/1)
I get W = 528, so you'd create the images at 704x528 and use the
same 'y4mscaler' command as above.
IF you really want (or need) 720x480 you have a couple choices:
1) Pad (as per the references above) the 704x480 scaled image with
8 pixels on each side (don't worry - they will NOT be seen unless
you have a monitor with 'underscan' capability). y4mscaler will
do this for you: y4mscaler -I sar=1:1 -O preset=DVD
2) Pretend (as I have seen in several books) that the SAR is really
9:10 instead of 10:11. I have seen the distinction drawn between
D1 and NTSC DV/DVD SAR - basically it amounts to treating the DV/DVD
frame as having a 9:10 SAR instead of 10:11 (as for broadcast TV).
Then run thru the calculations above and you'll find that you need
to create the images at 720x534 and scale to 720x480. The proof
is left as an exercise to the reader (HINT: (9/10)*534 = 480.6 :-))
Now that I've probably made a few goofs and managed to confuse things
even more it's time to let someone else help answer the question(s) :)
Cheers,
Steven Schultz
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Mjpeg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-users