How to decrease a video size

UriF

Member
Aug 25, 2021
50
4
I am not sure if anybody asked this question before at this fiorum. I got some video from internet with 1080p and 720p resolution and I want to decrease them to 480p (I have 24" display + 2 MB video card and it is for me more than enough). I tried HandBrake and Shortcut but I got a video more "wider" than for a typical 480p resolution. I believe that some people performed this task. If you use "freeware" which application you a recommend and which settings would recommend. Or could recommend a script?
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Handbrake is good, you just have to know how to set it up properly for what you want to do.

You want to make sure the pixel aspect is set to a 1:1 ratio to not have it wider than the source. The shortcut for 480p is for encoding DVD sources which are a bit tricky since they have a different aspect ratio. It's better to use custom and specify what you want since that doesn't apply to your use case.

Just check the source Aspect ratio at the top and make sure the Final dimensions aspect ratio is as close as possible at the bottom. What you likely want is 854x480 since most stuff nowadays is widescreen(16:9) and that translates to 853.3333333x480 but you have to use even values so the closest is 854.
 

UriF

Member
Aug 25, 2021
50
4
The standard sextb.net resolution - 858x482 (some of their uploads don't have 480p that's why I want to experiment). I tried Handbrake and I got a strange effect. Now I experiment with following parameters

ffmpeg -i input.mp4 -vf scale=858:482 output.mp4

ffmpeg -i input.mp4 -vf scale=640:480 output.mp4

ffmpeg -i input.mp4 -vcodec libx265 -vf scale=858:482 output.mp4

ffmpeg -i input.mp4 -vcodec libx265 -vf scale=858:482 -preset slow -crf 18 output.mp4


The first 2 options gave me an expected result. I just experiment with libx265 to get a file with lesser size


It is interesting that options 1 and 3 don't create a "wide" video like Shortcut and Handbrake did.

Option 3 significantly lesser size than option 2 but colors are "faded". After Icarus has been activated everything is fine. I don't see any difference.
 
Last edited:

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
That's a weird resolution but since you start from a bigger resolution, it doesn't matter, you can set it to whatever you like(as long as it's even numbers).
The term 480p refers to the vertical resolution so since that's what you said, that's what I used.
That means exactly 480 pixels high and the width changes depending on the aspect ratio of the video. If it's 16:9, which it likely is, you do 480*16 and then divide by 9 which gives 853.333. If you do the same with 482, you get 856.88888 so using 858 makes it less accurate than what I suggested. The difference is still small enough that you won't notice though.

You got a strange effect with handbrake because it assumes things that doesn't apply to you with the settings you chose. Select the right settings and it'll be fine.
ffmpeg will also do a great job if you don't mind using the command line and gives you better control over things.

It's expected that option 1 and 3 don't give you a wide video because by default ffmpeg uses the aspect ratio you give it, which is calculated from the resolution you specify. You didn't set the resolution manually in handbrake like you did in ffmpeg so that's why it gave you a different result.

What you need to watch out for with x265/hevc is that it's very easy to blur details in the video so make sure to compare it to the original to make sure you didn't destroy a ton of detail. It might not be obvious just looking at it on its own but when compared, you might realize it doesn't look as good.
Instead of blurring things out, x264(the default for option 1 and 2) uses noise(random dots everywhere) to compress instead of blur so pick whichever you prefer/find acceptable for the file size you get.

Also, the slower the preset you use(except maybe placebo, which often just max things out and shouldn't be used as is), the smaller the file size will be for the same quality, but it takes longer to encode.

It's possible you have to specify the color space since HD and SD stuff is different so I don't know if ffmpeg is going to assume wrong things for it which might explain the color issue you had. No clue what you mean by activating icarus since I don't know what that is or what it does.
 
  • Like
Reactions: CoolKevin

UriF

Member
Aug 25, 2021
50
4
Option 4 worked TOO slow (approx 6 hrs for a4 hr video) and I got a version GREATER than original video.

About Icarus

As you know not all of file types are not visible in a preview panel of file explorer. Icarus solve this problem for video files. Instead of "white space" you will see a default video preview in preview panel.

Now I try to get a video 480p video using H264 and this option -preset slow -crf 18
ffmpeg -i input.mp4 -vf scale=858:482 -preset slow -crf 18 output.mp4. A lot of people recommend this option for video quality improve.

By the way I got a method to join mp4 file where Avidemux failed like other standard joiners

ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input2.ts
ffmpeg -i input3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input3.ts
ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.mp4
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
6 hours for a 4 hour video is not long at all, used to take me around 15 hours on my old pc to encode a 2h SD video with good deinterlacing and using x265 it would be 2-3 days.

For HD stuff, I used those settings usually but that's for x264, not ffmpeg so not sure if it's the same:
Code:
--preset veryslow --crf 18 --keyint 240 --min-keyint 30 --ref 12 --rc-lookahead 150 --merange 24 --deblock -1:-1 --psy-rd 1.0:0.10 --no-fast-pskip --slow-firstpass --colorprim bt709 --colormatrix bt709 --input-depth 8

Don't expect quality to improve when you're reencoding something, that's not going to happen unless the source has issues and you're using filters to fix those. The best you can expect is to not notice the quality loss from the process.

Joining files can work or fail in some apps depending on the codec used or corruption, stuff like that. For mp4, I usually use mp4box since it's made to handle mp4.

Thanks for the icaros link, I'll look that up.

I never tried vp9, haven't messed around with encoding in quite a few years and it was pretty new back when I did. I'd give AV1 a shot nowadays since it's its successor.
 
  • Like
Reactions: CoolKevin

UriF

Member
Aug 25, 2021
50
4
Thank you anyway. I decided to keep with this script (using H264)
ffmpeg -i input.mp4 -vf scale=858:482 -preset slow -crf 18 output.mp4. I believe that 720p takes to much space on my hard drive. There are not important files just for entertainment. I still keep very old avi files from vintage erotica forum (you understand which quality they are - amateurs copied them from old VHS and there were not such good encoders in the beginning 2000th as we have have now) and I am more than satisfied.

P.S. You also understand that all of these files has been downloaded from internet and are too far from HD DVD quality.
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Yeah, I've had to seriously ask myself if I should bother getting the 1080p rips that get posted on the forum vs my own encodes from 480p DVDs since the 1080p ones look so bad since they're not-so-good webrip and not from bluray sources.

Luckily I have over 110TB of storage on my servers so space is no issue for me nowadays.

If you can't stomach the time it takes to use veryslow as a preset(which would just lower the file size even more at the cost of encoding time), what you're using is pretty good.
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
640:480 is for when the aspect ratio is 4:3(fullscreen) and 854:480 is for 16:9(widescreen). Most HD JAV content is going to be 16:9, pretty much only old stuff will be 4:3 since it's not really used anymore.

858:482 isn't standard and doesn't have any advantages I can think of, it's just random but also fits for 16:9. Not a resolution you wanna use if your source is SD since you'd need to upscale it but when the source is HD and you have to shrink it either way it doesn't matter.
 

UriF

Member
Aug 25, 2021
50
4
What do you think about this preset?
ffmpeg -i input.mp4 -vf scale=858:482 -c:v libx264 -preset slow -crf 22 -c:a copy output.mp4

i.e. audio - copy and crf = 22 (I saw that when video has been decoded it was never crf < 24. I try to decode with default settings - q= 29.0, fps =134

I repeat. I use 24" monitor and I don't like when video would take > 2/3 of screen

P.S.. I tried default settings for H264 with decoding using -preset slow -crf 18 and I don't see any difference.
 
Last edited:

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
The audio copy being good or bad is going to depend on your source. If the source is a wmv, it's not very good to use wma audio in a container other than wmv, the support is not great for it.
If the source has ac3 audio, it'll take a lot of space for not much benefit.
But if the source has aac or mp3 audio, then using copy is perfectly fine and won't take too much space.

The crf number is the perceived quality of the video. The lower the number, the higher the quality but also the bigger the size.
When quality matter, I go for 18(even for 480p stuff, all my dvd rip use that) and when I want a small file and don't care about quality, I go for 24(wouldn't go much higher than that personally). So just experiment and use the number you're happy with for the quality/size ratio.

The size of your monitor doesn't matter, it's the resolution for it that does for the space a video is going to use on it. I personally want to keep the quality as high as I can regardless of the resolution, but that's just a personal preference, go for what you want.
 

Porni

Well-Known Member
Feb 29, 2012
349
324
Any audio can be converted to:
Code:
-c:a libopus -b:a 64k

Using wma into mkv should be perfectly valid and not cause any problems
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
wma in mkv or mp4 will work but you're opening yourself to potential issues, depending on the player you're using, since it's not the most well supported codec when not using the microsoft decoder which I'm not sure works outside of a wmv file.

Edit: Just checked and LAVfilters which supports over a hundred codec and most of them are enable by default but not wma audio, for a reason.

Edit2: Some parts of asf/wmv are patented by microsoft which is why it makes things complicated.
 
Last edited:

UriF

Member
Aug 25, 2021
50
4
My display resolution - 1920x1080. To watch video I am using Daum Pot or VLC sometimes (if video distorted or corrupted). I have my Win 10 x 64 with i7 processor, 16 MB RAM and 2 MB video card. I believe for such characteristics 480p is more than enough. I tried other players but I don't see any advantages comparable with these 2.
 

UriF

Member
Aug 25, 2021
50
4
I downloaded a wmv video with 10 parts more than 10 yrs ago (not many people had a fast internet and therefore they uploaded parts no more than 100 Mb). I converted these segments into mp4 recently

ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a aac -q:a 100 output.mp4

and joined them using above mentioned method (convert every segment into ts streams and concatenate into mp4)
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Or you can just join them with asfbinwin inside 1 wmv file directly. I prefer to avoid re-encoding when possible and just remux since it saves time and keeps the quality identical.

Technically 720p takes less than half of your screen and exactly 2/3rd of its height but that's entirely up to you. As long as you're happy with 480p, that's what matter. You can also use anything in between like 1066x600 if you want, nothing stopping you.
 

UriF

Member
Aug 25, 2021
50
4
Yes, I tried asfbinwin to create a asf file. It created it almost instaneously BUT when I wanted to convert this file into mp4 I the log file gave me a lot of errors. Therefore during conversion/recoding wmv into mp4 ffmpeg fixed these problems. That's why I prefer this method.
 
Last edited:

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
But you don't need to convert it to mp4, it doesn't give you anything more since I assume that's an SD file if it's that old.