How to decrease a video size

UriF

Member
Aug 25, 2021
50
4
Do you mean that old wmv, avi, asf not necessary convert to mp4/mkv?

By the way all of these old wmv files were ~60 mb. Joined asf - 613mb. joined mp4 - 430 mb. But it is not everything. Disappeared background screeching (like old vinyl disk) and picture became a little cleaner. If you interested I can upload it for your info to mega.
 
Last edited:

UriF

Member
Aug 25, 2021
50
4
Do you mean that not necessary to convert old avi, wmv, asf and so on into mp4/miv?

By the way the original wmv files ~ 60 Mb. asf combined (10 files) ~ 600 Mb. mp4 combined - 433 Mb. In additional I hjust compated asf and mp4. Disappered background screeching (like old vinyl disk) and video became clearer a little.
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Yes, that is what I'm saying.

The file size went down because you re-encoded it with a newer compression algorithm that's better and the settings are completely different since it's a different compression.

If you get glitches like that, it means the joining had issues. Depending on the wmv files, some are poorly created and it can cause those kind of issues. You can likely fix that by using SolveigMM ASF Multiplexer to reindex it but it's a little complicated since you need to use something like graphStudioNext, add the video to the graph, add the filter, connect the video and audio of the movie to it on the graph and then save it by pressing play and waiting for the whole duration of the video.
Or you can pay for one of their app but I like free stuff and very few can handle wmv files(because of patents issues, which is why they always use ASF instead, the predecessor of wmv).

The video becoming clearer is either you doing some processing during the encode or a result of the encoder compression(h264 will add noise to the video and it'll change your perception of the picture), but either way, you lose a little bit(or a lot depending on your settings) of detail so I personally prefer to avoid doing that.
 
  • Like
Reactions: CoolKevin

UriF

Member
Aug 25, 2021
50
4
Guys recommended this parameters. It radically improved situation and if not look at very careful sounds satisfactory

-x264opts colormatrix=bt709:colorprim=bt709:transfer=bt709:fullrange=off
By they did you try AV1? I searched on internet and people say that it decrease file size for approx. 30% but you have to wait for 10 times more comparable to H264
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Like I said in another post, if your source is hd, you may need to set the color space stuff for it to look right which is what that does(not sure about the transfer one though, don't remember that one but it's set to hd colors value so must be related). If the source is SD, it'll look wrong though.

And no, I didn't try VP1. It's the successor to VP9 so it similar to the difference between h264 vs h265.
 
  • Like
Reactions: CoolKevin

UriF

Member
Aug 25, 2021
50
4
H264
ffmpeg -i input.mp4 -filter:v "scale=858:482:in_color_matrix=auto:in_range=auto: out_color_matrix=bt709:eek:ut_range=tv" -pix_fmt:v "yuv420p" -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" -c:a copy output.mp4

H265
ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -filter:v "scale=858:482:in_color_matrix=auto:in_range=auto: out_color_matrix=bt709:eek:ut_range=tv" -pix_fmt:v "yuv420p" -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" -c:a copy output.mp4

If you understand this script it means that ffmpeg get BT.709 by force

auto : in_range=auto : out_color_matrix=bt709 : out_range=tv (please remove spaces)
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
Yeah.

BTW, if you don't want emojis to happen, put your text inside code tags which you can find in the more options and looks like </> or just type [ code] text here [\ code] without the space before code.

You can also use mediainfo to see what the options you don't explicitly specify are set to. It gives you a ton of information and you get all the settings used by libx264/libx265.


Also, if you want to not have to type or copy paste commands all the time, you can create a bat file like this(replace ffmpeg with the full path to it and put it inside " if it has spaces in the path):
Code:
@echo off
ffmpeg -i "%~f1" -c:v libx265 -vtag hvc1 -filter:v "scale=858:482:in_color_matrix=auto:in_range=auto: out_color_matrix=bt709:out_range=tv" -pix_fmt:v "yuv420p" -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" -c:a copy output.mp4
And simply drag and drop the video you want to encode on the bat file. The "%~f1" takes the first parameter passed to the bat file, which is the full path and name of the file you dragged onto it and uses that in the command.
Just edit it with a text editor to change the parameters until you're satisfied and you can add PAUSE on a new line at the end if you don't want the window to auto-close when the encoding if done or fails.
You can also replace output.mp4 with "%~n1sometext.mp4". %~n1 will use the name of the input file without the extension and sometext can be whatever you want to identify it as the encode and to make sure it doesn't delete the input file if that's also an mp4.

And if you use audio copy, you won't be able to use mp4 for the output if your source is a wmv because wma audio isn't supported inside mp4s, ffmepg gives the error
Code:
Could not find tag for codec wmapro in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
 
Last edited:

UriF

Member
Aug 25, 2021
50
4
I wrote you that I used this script to convert wmv into mp4
Code:
 ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a aac -q:a 100 output.mp4

Sorry, I am stupid a little. I don't understand how to use a variable "%~f1". Use bat file with parameter? This way?

Code:
mybatch "filename1.mp4" "filename2.mp4"

in bat file write following

Code:
@echo off
ffmpeg -i "%~f1" -c:v libx265 -vtag hvc1 -filter:v "scale=858:482:in_color_matrix=auto:in_range=auto: out_color_matrix=bt709:out_range=tv" -pix_fmt:v "yuv420p" -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" -c:a copy "%~f2"
 

SamKook

Grand Wizard
Staff member
Super Moderator
Uploader
May 10, 2009
3,755
5,154
If you want to know in detail how it works: https://ss64.com/nt/syntax-args.html

My suggestion was for dragging filename1.mp4 onto the bat file and adding a suffix to it for the output, which could be filename1_480p.mp4 for example and by default it outputs in the same folder as the input.

But to do what you want, you almost got it except that you need to provide the full path for both and unless the bat file is in the same folder as ffmpeg or that you added it to your environmental variables, you need to specify the full path to ffmpeg.exe.
To just provide the filename like your example, remove the f so: "%~1" and "%~2"