Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    FFMPEG to convert mkv to avi file


    I have some MKV files in big resolution. Example a sample.mvi with 720x304 (looks like 16:9 ratio)

    I want to convert it to AVI file but using XVID codec and also 640x480 screen size (4:3 ratio).

    So the final video will be with black borders at top/bottom to keep the original video ratio.

    I am trying this command:
    ffmpeg -i sample.mkv -vcodec libxvid -r 25 -b 1200 -aspect 4:3 -s 640x480 -vf pad=0:0 -sameq -y out.avi
    but this command is stretching the original video and I want to keep the original ratio.

    Please provide me command like help for how to do this

  2. #2
    Also if I add pad value bigger than zero, than it gives me error so I am little confused about how to use it the PAD filter.

  3. #3
    Hi. I don't know the exact command with FFMPEG, but I did that a long time ago with mencoder. You must use a video filter chain, to rescale the pixels and build a 640x480 final resolution.
    First, this process will destroy the image sharpness, and also will bring new problems because compression does not like the black bars on top and bottom of the screen. Anyway, let's talk algebra.
    initial movie is 720:304 in 16:9, that is 1024x304 in scare pixels.
    If you want 640 in width, the height will be 304x640/1024 = 190 pixels. So the video filter chain will be, mencoder syntax,
    mencoder -vf scale=640:190,expand=640:480
    The first video filter scales your movie to 640x190 with scare pixels, the second video filter expand each picture of the movie to 640x480 by adding black bars on top and bottom of the screen.
    Last edited by CaptainDangeax; 09-25-2012 at 06:47 AM.

  4. $spacer_open
  5. #4
    Thanks CaptainDangeax,
    the command works with some tweaks. Here is the final comamnd;

    mencoder input.mkv -vf scale=640:270,expand=640:480 -oac mp3lame -ovc xvid -xvidencopts bitrate=1200 -o out.avi

  6. #5
    You're welcome.

Posting Permissions

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