FFMPEG. Transfer video to mobile phone format. Respect for proportions. PAD operand

    It is necessary to overtake a movie from MKV with dimensions of 1280 x 536 to the size of a mobile phone with dimensions of 320 x 240 and keep the proportions. To mp4 format with audio in ac3
    I have this way of calculating the proportions (the most standard one is mathematical):


    If you get 320 from 1280 , then you need to calculate the coefficient for calculating the short side, for this we divide 1280 by 320 , we get 4 . So, to calculate the short side, we must divide 536 by 4 . We get 134 .
    So, if we set the resulting size, then we will succeed. It’s not so!
    The phone has a screen of 320 x 240 , and if we run our video 320 x 134 on the phone, it will stretch the short side of 134 pixels to 240 , that is, the characters in our cinema will have elongated faces, etc. So you need to bring the final file to a size of 320 x 240 , filling in the missing pixels with black color above and below. A special PAD video filter has been made for this .
    Let's estimate how much you need to add to 134 to get 240 ? Very simple: subtract 134 from 240, it turned out 106 . These 106 pixels need to be added to our video to get it right. But we do not want this strip of 106 pixels high to be only above or below, for this we will divide these 106 pixels into two bands of 53 pixels and arrange them at the top and bottom.

    ffmpeg -i kino.mkv -vcodec mpeg4 -vb 500K -acodec libfaac -ar 44100 -ab 256K -ac 2 -vf «scale=320:135,pad=320:240:0:53:black,unsharp» -vol 700 -y kino.mp4

    I decrypt -vf "scale = 320: 135, pad = 320: 240: 0: 53: black, unsharp"

    scale = 320: 135 - specify PROPORTIONAL sizes of the output file to the original movie sizes.
    pad = 320: 240: 0: 53: black - 320: 240 - the actual screen size of the phone,: 0: 53 - on the X scale - shift 0 , on the Y scale- a shift of 53 pixels.
    : black, unsharp - The stripes will be black. You can add clarity to unsharp . And you can not add. This filter also has settings. Need to read.

    Also popular now: