Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

FFmpeg Encoding Help Needed..

The bash script says:

for /R %%A in (*.mp4, *.avi, *.mov, *.wmv, *.ts, *.m2ts, *.mkv, *.mts) do (

Since this contains "*.mkv", I would assume it already handles MKV files as well. You can create a "paths.txt" file that contains the paths you video files are in, from the looks of it.

 

It basically goes over all files with one of those file endings and then does the same type of encoding on it. You'd have to look up the ffmpeg parameters to see what exactly it is doing (what type of encoding etc.).

Remember to quote or @mention others, so they are notified of your reply

Link to post
Share on other sites
13 minutes ago, Eigenvektor said:

The bash script says:


for /R %%A in (*.mp4, *.avi, *.mov, *.wmv, *.ts, *.m2ts, *.mkv, *.mts) do (

Since this contains "*.mkv", I would assume it already handles MKV files as well. You can create a "paths.txt" file that contains the paths you video files are in, from the looks of it.

 

It basically goes over all files with one of those file endings and then does the same type of encoding on it. You'd have to look up the ffmpeg parameters to see what exactly it is doing (what type of encoding etc.).

So basically, I need to create a bat file with the script within it, then I need to make a "paths.txt" that contains the path to the video I needed for it to be encoded? I still have no idea what to do, like my first steps and stuff..

Link to post
Share on other sites
12 hours ago, Lordivan said:

So basically, I need to create a bat file with the script within it, then I need to make a "paths.txt" that contains the path to the video I needed for it to be encoded? I still have no idea what to do, like my first steps and stuff..

Yes, simply copy the contents into a file and save it as "crf24_hevc.bat" (the name doesn't matter, as long as you use .bat as the file ending). From what I can see, there are two "modes":

 

1. Without "paths.txt"

 

Simply copy the script into a directory containing video files. When you execute it, it should loop over all video files and re-encode them. It will do this for any file with an extension of .mp4, .avi, .mov, .wmv, .ts, .m2ts, .mkv, or .mts

 

2. With "paths.txt"

 

Create a "paths.txt" file in the same directory as the script. The file should contain directory names (e.g. "C:\MyVideos"). When you execute the script, it should loop over all the directories specified in "paths.txt". For every directory it should then loop over all video files in that directory and re-encode them. So this is mainly to simplify the process if you have lots of different directories containing video files.

Remember to quote or @mention others, so they are notified of your reply

Link to post
Share on other sites
14 hours ago, Lordivan said:

Ok, so I saw this video


Because I have some storage problem I wonder if I can save 20 TBs myself, but I'm no tech savvy.

That is why I'm asking how to actually do it? How to apply the code to my mkv files?

The code: https://github.com/EposVox/WindowsMods/blob/master/crf24_hevc.bat

Careful with those ffmpeg parameters, look into them before you convert your library.

Link to post
Share on other sites
1 hour ago, zhnu said:

Careful with those ffmpeg parameters, look into them before you convert your library.

Those aren't even particularly good settings. Also, I am annoyed by the claim the constant-quantizer is the same thing as constant-rate-factor. Constqp and CRF do seem similar on the surface, but they aren't equivalent; VBR in constant-quality mode is more akin to CRF.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
Just now, WereCatf said:

Those aren't even particularly good settings. Also, I am annoyed by the claim the constant-quantizer is the same thing as constant-rate-factor. Constqp and CRF do seem similar on the surface, but they aren't equivalent; VBR in constant-quality mode is more akin to CRF.

Also everything is 10bit for some reason and using nvenc plus it discards multiple audio and video tracks when they exist.

Link to post
Share on other sites
5 minutes ago, zhnu said:

Also everything is 10bit for some reason

Converting from 8bit to 10bit would make sense, if one was scaling the video up or down, since you are introducing content that wasn't originally there and can thus retain higher quality by going with 10bit encoding. Alas, there's no scaling happening with the script, so..

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
1 minute ago, WereCatf said:

Converting from 8bit to 10bit would make sense, if one was scaling the video up or down, since you are introducing content that wasn't originally there and can thus retain higher quality by going with 10bit encoding. Alas, there's no scaling happening with the script, so..

Well I have to disagree if the colour isn't there originally why increase the bit-depth to me it feels like a waste of space.

Link to post
Share on other sites
2 minutes ago, zhnu said:

Well I have to disagree if the colour isn't there originally why increase the bit-depth to me it feels like a waste of space.

Like I said, when you are rescaling, you are introducing colours that weren't there before.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
Just now, WereCatf said:

Like I said, when you are rescaling, you are introducing colours that weren't there before.

Well yes and no, he creates new colours from interpolation of the pixels but those derive from the existing pixels which are 8bit values so new values should only affect the interpolated ones and what do you gain from that?

Link to post
Share on other sites
7 minutes ago, zhnu said:

Well yes and no, he creates new colours from interpolation of the pixels but those derive from the existing pixels which are 8bit values so new values should only affect the interpolated ones and what do you gain from that?

Even plain, old bilinear filtering uses more than two pixels for the process. Also, each pixel consists of several channels, ergo there's no way of neatly fitting the output into 8 bits without losing information. Even just plain average of, say, 128, 75, 15 and 9 results in 56,75 -- not an 8bit value, even though the original values would fit in a 8 bits just fine.

 

Take a more complex rescaling-algorithm like e.g. lanczos and you'll get far, far more colours than can natively fit in an 8bit colourspace, ergo. going with 10bit colour-depth will retain more information and thus be of higher quality.

 

https://en.wikipedia.org/wiki/Lanczos_resampling

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
6 minutes ago, WereCatf said:

Even plain, old bilinear filtering uses more than two pixels for the process. Also, each pixel consists of several channels, ergo there's no way of neatly fitting the output into 8 bits without losing information. Even just plain average of, say, 128, 75, 15 and 9 results in 56,75 -- not an 8bit value, even though the original values would fit in a 8 bits just fine.

 

Take a more complex rescaling-algorithm like e.g. lanczos and you'll get far, far more colours than can natively fit in an 8bit colourspace, ergo. going with 10bit colour-depth will retain more information and thus be of higher quality.

 

https://en.wikipedia.org/wiki/Lanczos_resampling

Yes but wont that just generate a more pronounced dithering on the final video.

Link to post
Share on other sites
1 minute ago, zhnu said:

Yes but wont that just generate a more pronounced dithering on the final video.

No, the actual opposite: it will reduce banding and visible dithering. That's the whole point: banding happens when you don't have enough available colours to use to get a smooth gradient and using a higher bit-depth gives you more colours to use, ergo.... less banding!

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
10 hours ago, zhnu said:

Careful with those ffmpeg parameters, look into them before you convert your library.

The good thing is that the script doesn't delete the original files, so you can compare before/after. But yeah, I'd definitely look into the parameters of ffmpeg and do some tests before converting my whole library with a one-size-fits-all approach to see if the result is what I want.

Remember to quote or @mention others, so they are notified of your reply

Link to post
Share on other sites

Well, actually I made it to work and yes it increased in size almost immediately, unlike what he said in the video. In the video he showed a 99.2 gigabyte video reduced to little as 22 megabyte, which is mindblowing, but mine increased like 400%..

Anyone know how to fix this?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×