Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: [SOLVED] avi widescreen to mpg (w/ffmpeg) = squished screen

  1. #11
    Join Date
    Mar 2007
    Location
    Outer Milky Way
    Beans
    Hidden!
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: avi widescreen to mpg (w/ffmpeg) = squished screen

    Quote Originally Posted by eye208 View Post
    If your DVD player has MPEG4 + MP3 playback capability (most recent players do), you need not convert anything at all. Just burn the AVI to DVD or CD.

    However, if you want to create a "true" DVD, there are a lot more things to consider besides aspect ratio. Your video must be scaled to 720x480, telecined to 29.97fps and encoded to MPEG-2 (.vob), not MPEG-1 (.mpg). You also have to set up the proper file/folder structure expected by DVD players. This is complex stuff, so I recommend using a DVD authoring tool.
    That's what the parameter -target ntsc-dvd (or -target pal-dvd or -target film-dvd) does. It sets all those miscellaneous parameters for you.

    -target ntsc-dvd outputs to 720x480, with a a framerate of 24 fps

    -target film-dvd outputs to 720x480, but with a framerate of 30 fps

    -target pal-dvd outputs to 720x576, with a framerate of 25 fps

    All three use MPEG-2 for video and ac3 for audio.

    Also, I noted these useful settings that can be used to trim a video:

    -ss 00:00:01 will start recording at the time selected (hh:mm:ss) for the input file; and

    -t 00:15:04 determines how long of a clip to record, in hh:mm:ss
    Last edited by perspectoff; April 24th, 2009 at 07:30 AM.

    UbuntuGuide/KubuntuGuide

    Right now the killer is being surrounded by a web of deduction, forensic science,
    and the latest in technology such as two-way radios and e-mail.

  2. #12
    Join Date
    Mar 2007
    Location
    Outer Milky Way
    Beans
    Hidden!
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: avi widescreen to mpg (w/ffmpeg) = squished screen

    Quote Originally Posted by ClarkePeters View Post
    thanks FakeOutdoorsman.

    I settled on padding top and bottom at 36. I don't mind losing the outside edges of the movie. It plays just fine.

    Code:
    ffmpeg -y -i ScroogeFinney.avi -target ntsc-dvd -s 720x410 -padbottom 36 -padtop 34 out.mpg

    thanks again.
    Wouldn't a 16:9 ratio would be 720x405? (For FFMPEG the frame size must be an even integer, so 720x404 would be the closest.) 480 - 404 = 76, so that top and bottom padding of 38 would be required to make up the difference to 720x480.

    I tried the convert commands:

    Code:
    ffmpeg -i samplevideo.flv -target ntsc-dvd -s 720x404 -padtop 38 -padbottom 38 samplevideo.mpg
    All the faces and characters looked almost normal.

    I then tried

    Code:
    ffmpeg -i samplevideo.flv -target ntsc-dvd -s 720x360 -padtop 60 -padbottom 60 samplevideo.mpg
    and the faces and characters looked completely normal.

    [I found -padcolor 000000 (which specifies the pad color to be the default black) was not necessary, and that -sameq is only necessary if using VBR (not common). -y just means to overwrite any output file of the same name.]

    But with both, about 10-15% of the widescreen picture on each side was cutoff when viewing it on my TV (but not on my computer). I have read that this is due to the TV overscan, but surely there must be some way around it?

    Quote Originally Posted by FakeOutdoorsman View Post
    Try this:
    Code:
    ffmpeg -y -i ScroogeFinney.avi -target ntsc-dvd -s 684x256 -padbottom 112 -padtop 112 -padleft 18 -padright 18 out.mpg
    The video doesn't stretch to 720 because then the vertical resolution would be a fractional value. I suppose you could add the croptop (cropleft, etc) options to get it to properly stretch to 720, but my arithmatic skills suck. You could also just round to the nearest number and hope it looks good:
    Code:
    ffmpeg -y -i ScroogeFinney.avi -target ntsc-dvd -s 720x269 -padbottom 106 -padtop 105 out.mpg
    If I assume that the horizontal overscan is 10%, then I would need to pad 10% horizontally, or 5% on each side. For a 720 pixel wide screen, this would mean the picture would need to be 720 - 72 = 648 pixels wide, with 36 pixel padding both left and right.

    So my target for my video would be 648 pixels wide.

    Let's say my original video is 424x234. To upsize this original video so that the final horizontal width is 648, I would have to multiply by a factor of 648/424. To keep the aspect ratio intact, I would have to multiply the vertical size by the same factor. In other words, the vertical resolution would have to be 234 x (648/424), or 358.

    So my final size of the video would be 648x358. To pad the image to a final size of 720x480 (required for NTSC), I would have to use left and right padding of 36 (always), and 480-358/2 for top and bottom padding, or 61.

    Because FFMPEG requires even integers for frame and padding sizes, I would have to tweak this to 648x356 with top and bottom padding of 62.

    Then my convert command would become

    Code:
    ffmpeg -i samplevideo.flv -target ntsc-dvd -s 648x356 -padleft 36 -padright 36 -padtop 62 -padbottom 62 samplevideo.mpg
    In general, a true 16:9 widescreen picture would almost always be upsized to 648x364, requiring top and bottom padding of 58 each. In general, then, a safe command (for 10% horizontal overscan) would be

    Code:
    ffmpeg -i samplevideo.flv -target ntsc-dvd -s 648x364 -padleft 36 -padright 36 -padtop 58 -padbottom 58 samplevideo.mpg
    If overscan is 15% (uncommon), then the horizontal would be 612. which a 16:9 image would be 612x344. This would require left and right padding of 54 and top and bottom padding of 68. The general command would be, therefore

    Code:
    ffmpeg -i samplevideo.flv -target ntsc-dvd -s 612x344 -padleft 54 -padright 54 -padtop 68 -padbottom 68 samplevideo.mpg
    I end up doing a lot of these conversions. I like the GUI WinFF (as a front end for FFMPEG), which is now available in the Jaunty Repositories (or alternatively as a .deb file from the project website):

    sudo apt-get install winff

    I added a preset in WinFF for this routine conversion of 16:9 Widescreen to 4:3 Letterbox:

    Video converter (WinFF) -> Edit -> Presets ->
    Preset Name: Letterbox
    Preset Label: 16:9 Widescreen to 4:3 Letterbox
    Preset command: -target ntsc-dvd -s 648x364 -padleft 36 -padright 36 -padtop 58 -padbottom 58
    Ouput file extension: mpg
    Category: DVD
    -> Add/Update -> Save


    ================================================== ======================
    I was born with 2 arms and 3 legs. As a schoolboy, Maths for me was always hard. The only thing I knew for sure was three feet made a yard. To count to ten I used my fingers -- and if I needed more, by getting my shoes and socks off I could count to twenty four!
    Last edited by perspectoff; April 24th, 2009 at 05:57 PM.

    UbuntuGuide/KubuntuGuide

    Right now the killer is being surrounded by a web of deduction, forensic science,
    and the latest in technology such as two-way radios and e-mail.

  3. #13
    Join Date
    Jul 2008
    Location
    Seattle WA
    Beans
    105
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [SOLVED] avi widescreen to mpg (w/ffmpeg) = squished screen

    The new ffmpeg is missing critical info in its docs.
    late versions of ffmpeg changed command line options from padright/padleft, etc to -vf "pad=w:x:y:z,crop=...".
    I did this:

    Code:
    ffmpeg -i my-vid.ogv -target ntsc-dvd -s 648x364 -vf pad=648:364:black ntsc-648x364-with-padding.avi
    .....and it seemed to work (i.e. no more vertically stretched video).

    To be honest though, I'm not 100% convinced that I know what "pad=w:x:y:z,crop=." means even though "-vf pad=648:364:black" seems to do the trick.

    What have I just told it?

    The man page says:

    All the pad options have been removed. Use -vf
    pad=width:height:x:y:color instead.
    I'm not sure I"m grokking why the man page has 4 values: width, height, x, y ???

    I would've thought this would work
    Code:
    ffmpeg -i input.ogv -target ntsc-dvd -s 648x364 -vf pad=648:364:36:58:black  ntsc-648x364-with-padding.avi
    ....since I wanted 36 units of x padding and 58 of y.

    It's late, I'm getting cloudy.

    Thanks for any input.

  4. #14
    Join Date
    Jul 2008
    Location
    Seattle WA
    Beans
    105
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [SOLVED] avi widescreen to mpg (w/ffmpeg) = squished screen

    Hmmm....seems like my audio is a bit late now. Probably only a couple of samples.

    Anyone know of a "delay audio by x samples" flag?

    Thanks again.

  5. #15
    Join Date
    Sep 2006
    Beans
    3,589

    Re: [SOLVED] avi widescreen to mpg (w/ffmpeg) = squished screen

    You could try the -itsoffset option. (S)MPlayer lets you change audio delay in playback so you can get a better idea of how much of an offset you need.

  6. #16
    Join Date
    Jul 2008
    Location
    Seattle WA
    Beans
    105
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [SOLVED] avi widescreen to mpg (w/ffmpeg) = squished screen

    You could try the -itsoffset option. (S)MPlayer lets you change audio delay in playback so you can get a better idea of how much of an offset you need.
    Thanks for the reply, fakeoutdoorsman. Haven't tried that yet.

    Simply because I'm really curious about what's causing this?

    It would almost seem like the sample rate and/or frame rate is not being set correctly on the newly created file.

    Like this.....

    Code:
    ffmpeg -ss 00:04:00 -t 60 -i myvid.ogv -target ntsc-dvd -s 648x364 -vf pad=648:364:black myoutputvid.avi
    ....isn't "good enough". My avi gets output at a sample rate of 48000. And if I'm experiencing an odd audio/video synch issue. Therefore, I would think that this......

    Code:
    ffmpeg -ss 00:04:00 -t 60 -i myvid.ogv -target ntsc-dvd -s 648x364 -vf pad=648:364:black -ar 44100 myoutputvid.avi
    ....(notice the newly added "-ar 44100") would fix it. But even though the properties of this newly created file report a sample rate of 44100 the audio is still significantly delayed.

    Even more bizarre is the fact that looking at the frame rate of both of the above says '30 fps' which is the same setting as on the original ogv file.

    Is the fact that I'm doing this....

    -target ntsc-dvd
    ...overriding the sample rate? As in, 'even though I'm seeing 44100 in the properties, it's not?'

    Driving me crazy!

    Thanks for any input.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •