On Wed, 20 Apr 2005, Nicolas wrote:

> Damn, y4mscaler and mpeg2enc are driving me crazy... =(

        Just takes a little practice :)

> Thanks for pointing me to yuvdeinterlace, Steven! I now use:

        Welcome.

> nice -19 lav2yuv record_01.avi | y4mshift -n -2 | y4mscaler
> -I active=744x560+12+8TL -O size=744x560 -S option=sinc:6 |
> yuvmedianfilter -T 3 | yuvdeinterlace -f | mpeg2enc -f 0 -V 500 -c -D 10
> -E -10 -q 2 -K tmpgenc -o record_01_cvs.m2v

> However, as you see, I had to use the -f 0 flag for mpeg2enc. If I use
> the -f 8 flag as I did before, I have that error:
> **ERROR: [mpeg2enc] Horizontal size is greater than permitted in

        Correct - you can't put 744x560 on a DVD.  For 625line ("PAL") the
        valid frame sizes for a DVD are: 720x576, 704x576, 352x576 and 
        MPEG-1 352x288.  No other sizes are valid.  And 560 lines is not a
        valid number of lines for PAL.

http://www.dvddemystified.com/dvdfaq.html#3.4

> And then it stops.

        As it should ;)  If you tell mpeg2enc it's producing output for a DVD
        then it will enforce the DVD limits on the frame size.

> I need:
> - a good quality

        Then don't deinterlace :)  Or rather, if the DVD will be played
        on TV sets then leave it interlaced since almost all TV sets are
        interlaced.    OH, and as I mention again later on TVs overscan so
        you will not see the edges that you're trying to crop.

        So you will degrade the image slightly by upscaling 560 lines to 576.
        Upscaling introduces no new information, it has to fabricate the new 
        number of lines by (basically) interpolation.  You'll loose some detail,
        the image will be a little blurrier/softer.

> - a cropped video, with no black borders

        Be careful to take into account the fact that video pixels aren't 
        square.  For PAL the pixels have an aspect of 59:54 (they are slightly
        wider than they are tall).  MJPEG cards product square pixels  - that
        is why you have a 768x576 frame - 768x576 with 59:54 pixels is the
        same as 704x576 using 59:54 pixels!

        Refer to: http://www.mir.com/DMG/aspect.html

        In particular the first section with the formula:

         width      DAR
         -------- = -----
         height     SAR

        DAR (Display Aspect Ratio) is probably the usual 4:3, SAR for PAL is
        59:54 and height must be 576.  Solve for 'width' (and round up to
        the next multiple of 16).

        Or you just leave the math to y4mscaler ;)  See below.

> there're some very large green blocks on the right border of the
> picture. Moreover, there're some parts of the image (with a lot of
> details) which are "blocky"

        Probably because you 1) didn't specify a bitrate and the default is
        very low (~1152Kb/s) and 2) -f 0 is generic MPEG-1 (not MPEG-2).

        Then too 744 is not a multiple of 16 and encoders really prefer having
        the dimensions be a multiple of 16 (which 720, 704, 352 are - so is
        576).

> How can I crop my pictures using y4mscaler? I tried, as given by Steven:
> y4mscaler -O sar=src size=704x480
> 
> But that does not produced the expected result...

        That's because that was only an example. You were expected to put
        in appropriate numbers for your needs (PAL, input framesize, etc) :)
        I use that step as a final crop before going into the encoder.

        Something like this will be a LOT closer to what you need (but I have
        not tested it):

  y4mscaler -I active=744x560+12+8TL -I sar=1:1 -O sar=59:54 -O size=704x576

        But you really don't want to do that...

        That will degrade the image because you're cropping the top
        and bottom 8 lines (total of 16) and then scaling up 560 to 576 lines.

        But y4mscaler will do The Right Thing to preserve the aspect ratio.

        On a TV set (which others may view the DVD on) the top and bottom
        black bars will NOT be seen due to overscan.  TVs lose between 5 and 10%
        of the edges.

        A better way to handle the noise in the borders is to turn them to
        pure black but leave them present.  

        Far better to do something like this using the original full 768x576
        frame that you captured, blacken the top 8 and bottom 8 lines BUT
        LEAVE THEM PRESENT - you must have 576 lines for PAL, not 560!

        Use the '-b' option of y4mshift to put black on the borders.  Something
        like "-b 12,8,754,560".  That is what I do for analog captures - it
        blackens the VCR noise/junk in the borders and allows the encoder
        to use fewer bits to encode the border areas.

        The end commands would be something like

        lav2yuv ... |y4mshift -n 2 -b 12,8,744,560 | \
           y4mscaler -I sar=1:1 -O sar=59:54 -O size=704x576 -S option=sinc:6 |
           ...

        What you can NOT do is arbitrarily pick your size and then scale
        the two dimensions to fit the frame both horizontally and vertically.
        You'll mangle the aspect ratio that way (people will be too skinny or
        too fat and circles will not be round).  The number of lines is fixed 
        at either 576 or 288, the two aspect ratios are fixed (you can not 
        change them as desired) at 4:3 and 59:54 (or 16:9 and 118:81).

        If you're making DVDs then there are a lot of restrictions that have 
        to be observed.  For computer only playback the restrictions are fewer,
        you can set your frame sizes as desired - but for DVDs the choices
        are few and specific and govern how you have to crop and scale the
        image data.

        Cheers,
        Steven Schultz



-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to