VideoHelp Forum




+ Reply to Thread
Results 1 to 12 of 12
  1. Hello everyone,

    I have a square screen amv format video player which is 1 inch by 1 inch.
    I would like to rescale videos that have different aspect ratios to fit the screen. I am using ffmpeg.

    My goal is to have the best quality video possible. I need to downscale all videos to a square screen about 256x256 resolution. Right now, widescreen videos are so squished that the quality is bad and I can't read any text.

    I don't mind cropping some of the sides of the video so that the quality is better.

    Please give me some ideas on how to use the ffmpeg scale filter to downscale videos to fit a square screen with the best possible quality.

    Here is my current command:

    -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p -vf "scale=296:256:force_original_aspect_ratio=decreas e,crop=256:in_h:20:0" -vstrict -1 -r 25 -ac 1 -ar 22050 -block_size 882

    This works well and it crops some of the side of the widescreen videos, but I think it can be better.

    Thanks!!
    Last edited by Bmcaps; 26th Dec 2023 at 16:46.
    Quote Quote  
  2. Banned
    Join Date
    Nov 2023
    Location
    Europe
    Search Comp PM
    maybe it get better with aspect ratio 4:3 if the aspect ratio is 16:9, but if the aspect ratio is allready 4:3 maybe it is better to use original aspect? or could try crop and not use any aspect ratio and try setup an full screen mode to get full picture of the video without boxes or aspect ratios! since it is 1" screen maybe full screen video is better without aspects (ie 4:3 boxes)! maybe rescale the videos to full screen no boxes!

    If cant see very much can try to downscale them below the dimensions you want and then upscale them with progessive+really low crf values, maybe can see better then! Just make sure to not add any aspect ratio boxes and such things, full screen mode with stretch, will be like putting and small magnifier over that tiny video!

    Edit: Maybe wont help much if they get squished since theyre widescreen allready! maybe can squish them (downscale) several times with different dimensions to get to keep the good parts of the video before upscaling them sightly to get an minor magnification on the video!
    Last edited by Swedaniel; 27th Dec 2023 at 01:40.
    Quote Quote  
  3. You only have two options for widescreen sources. Either you downsize them and keep the original AR, (then you only get 256x108 pixels for a 2.35:1 film) or you crop so much on the left and right that a square frame remains, which you can then downsize to 256x256.
    Quote Quote  
  4. Try this scaling:

    Code:
    -vf "scale=w=256:h=256:force_original_aspect_ratio=decrease,pad=256:256:(ow-iw)/2:(oh-ih)/2"
    or crop to fit:
    Code:
    -vf "scale=w=256:h=256:force_original_aspect_ratio=increase,crop=256:256"
    more examples see here:
    https://superuser.com/questions/547296/resizing-videos-with-ffmpeg-avconv-to-fit-into-...136305#1136305
    Last edited by Sharc; 27th Dec 2023 at 11:48.
    Quote Quote  
  5. Thanks all for the responses.

    I will try all the advice later today.

    Basically when I use the force-original-aspect-ratio command, it works and fits the video in the square box, but the resulting video is so squeezed together that it is pixelated (if this is the right word), and text is just blurs.

    Ideally I would like to crop some of the sides off and maybe make the height larger to fit the very small screen better. Quality is key.

    I am new to ffmpeg commands so if you could please give examples in script that is ready to copy and paste in ffmpeg that would be awesome.

    Thanks so much everyone
    Quote Quote  
  6. Originally Posted by Bmcaps View Post

    Ideally I would like to crop some of the sides off and maybe make the height larger to fit the very small screen better. Quality is key.

    I am new to ffmpeg commands so if you could please give examples in script that is ready to copy and paste in ffmpeg that would be awesome.
    So try the 'Crop to fit' variant in post#4, like
    Code:
    ffmpeg -y -i "your source" -c:a aac -c:v libx264 -preset slow -crf 18 -vf "scale=w=256:h=256:force_original_aspect_ratio=increase,crop=256:256" "out_crop2fit.mp4"
    Quote Quote  
  7. Swedaniel Sharc and ProWo, thanks a lot.

    Sharc and swedaniel, the crop to fit script works GREAT!

    The quality of the video is much better.

    However, it crops a little too much off the sides.

    How can I keep the quality but crop less of the width?
    I don't mind some padding on the top and bottom if needed.

    Also, is your script up-converting anything?
    I can only use a phone, so less processing is ideal for faster conversion. Plus doesn't up-converting affect the quality?

    Thank you all
    Quote Quote  
  8. I would measure display size and calculate based on this real display aspect ratio - fact that display provide 256x256 pixels resolution doesn't mean that pixels are square. You can also try to use nonlinear scaling or perhaps even feature preserved scaling (seam carving, liquid rescale).
    Last edited by pandy; 29th Dec 2023 at 16:27.
    Quote Quote  
  9. Originally Posted by Bmcaps View Post

    However, it crops a little too much off the sides.

    How can I keep the quality but crop less of the width?
    I don't mind some padding on the top and bottom if needed.
    Try this:
    Code:
    ffmpeg -y -i "your source" -c:a aac -c:v libx264 -preset slow -crf 18 -vf "scale=w=380:h=380:force_original_aspect_ratio=decrease,pad=380:380:(ow-iw)/2:(oh-ih)/2,crop=256:256" "new_resized.mp4"
    Adjust the red 380 to fit your needs. Should be all the same number equal or larger than 256.

    Edit:
    If you feel that the objects in the picture are squeezed or stretched, your source or display is not square pixels (e.g. DVD sources or VHS captures are not square pixels, Blu-Ray are square pixels). One would then have to set the correct PAR in the script.
    Last edited by Sharc; 30th Dec 2023 at 04:37.
    Quote Quote  
  10. Thanks again everyone.

    Unfortunately I don't know much about video conversion.

    The player I am using is a cheap mp3 player modified for video playback in a low quality, low compression format called amv.

    It is a SanDisk sansa clip sport mp3 player with modified firmware.

    I don't know the exact screen resolution or pixel type.

    Is there a way I can experiment with different ffmpeg scripts to see which works best for this player, e.g. different pixel types, different downscaling methods, etc?

    Again I am new to ffmpeg so ideas of scripts that are ready to copy and paste into ffmpeg are awesome.

    Sharc, you have been so helpful with this and the quality is much better now. I will try your newest script tomorrow.

    Pandy, thanks for the advice. I am too new to understand how to measure the screen or apply other scaling methods.

    By the way, so you all know, your advice is helping not just me, but many people where I am with the same mp3 device!! We are all thankful.
    Quote Quote  
  11. One major detail I left out, so sorry.

    The firmware is made for a different MP3 player with a screen that is 1.25 inches by 1 inch. So the left side of the video is cut off of the screen since the actual screen is only 1 inch by 1 inch.

    I know this is confusing.

    Basically we have been padding the output video to make a black square on the left side of the output video that is exactly 20% of the video width.

    Like this:

    Pad=320:256:64:-1

    This makes a 64 pixel black square on the left of the output video while displaying the 256 x 256 video on the screen.
    Quote Quote  
  12. Originally Posted by Sharc View Post
    Originally Posted by Bmcaps View Post

    However, it crops a little too much off the sides.

    How can I keep the quality but crop less of the width?
    I don't mind some padding on the top and bottom if needed.
    Try this:
    Code:
    ffmpeg -y -i "your source" -c:a aac -c:v libx264 -preset slow -crf 18 -vf "scale=w=380:h=380:force_original_aspect_ratio=decrease,pad=380:380:(ow-iw)/2:(oh-ih)/2,crop=256:256" "new_resized.mp4"
    Adjust the red 380 to fit your needs. Should be all the same number equal or larger than 256.

    Edit:
    If you feel that the objects in the picture are squeezed or stretched, your source or display is not square pixels (e.g. DVD sources or VHS captures are not square pixels, Blu-Ray are square pixels). One would then have to set the correct PAR in the script.

    Sharc, this script is GREAT. You are a genius. The quality is much better.

    I don't understand the different pixel types or how to change them in ffmpeg, but your script has improved the video quality.

    Thanks

    I also tried the 4:3 ratio suggested by Swedaniel. The quality is great. Much better than I thought it would be by converting 16:9 to 4:3.

    Thank you so much sharc and swedaniel.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!