Resizing method used
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Resizing method used
Hello!
I need to know what algorithm is used for resizing in Handbrake, it's not written in the docs. Also I want to know whether I can hand the resizing over to corresponding option of x264, thus leaving the frame size in handbrake the same as source. Won't it cause an error?
I'm using version 1.1.1 on Windows 7 and I need a precise answer, not some guesses. So answer only if you know for sure.
I need to know what algorithm is used for resizing in Handbrake, it's not written in the docs. Also I want to know whether I can hand the resizing over to corresponding option of x264, thus leaving the frame size in handbrake the same as source. Won't it cause an error?
I'm using version 1.1.1 on Windows 7 and I need a precise answer, not some guesses. So answer only if you know for sure.
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
lanczos
If you don't want scaling, just use a preset that doesn't scale or set the "storage dimensions" to match the source. "Production Max" and "Production Standard" presets won't scale.
You may also need to disable cropping.
libx264 doesn't do scaling. HandBrake doesn't use the x264 exe, so if you were thinking you could use the exe for scaling, you can't.
If you don't want scaling, just use a preset that doesn't scale or set the "storage dimensions" to match the source. "Production Max" and "Production Standard" presets won't scale.
You may also need to disable cropping.
libx264 doesn't do scaling. HandBrake doesn't use the x264 exe, so if you were thinking you could use the exe for scaling, you can't.
Re: Resizing method used
Lanczos algorithm has the amount of taps as a parameter. How many does Handbrake use? And does it depend on frame size or it is fixed?
So libx264 doesn't do scaling? I didn't know there was a different version of x264 with limited capabilities. I looked up that it's part of ffmpeg, but couldn't find its full description in the docs. Could you give me a link to it, I want to know what other limitations it has?
So libx264 doesn't do scaling? I didn't know there was a different version of x264 with limited capabilities. I looked up that it's part of ffmpeg, but couldn't find its full description in the docs. Could you give me a link to it, I want to know what other limitations it has?
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
HandBrake uses libswscale for filtering. Looking at the code, it's not clear to me which parameter is the number of taps or if it even allows direct setting of the number of taps. The parameter that affects what swscale calls the "filterSize" is called "sizeFactor" and is set to it's default value of 6. The filterSize is then computed like this when downscaling
Code: Select all
filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
x264 is not part of ffmpeg. It is it's own project. They provide a command line exe called x264 that *uses* ffmpeg libraries for decoding source files, scaling, muxing, etc. They also provide libx264 that *only* does h.264 encoding. HandBrake uses both libx264 and all the various ffmpeg libraries to do what HandBrake does.
Re: Resizing method used
I know that x264 is it's own project, but I thought that libx264 was a part of ffmpeg that forked from the original.
So this only encoding means all options listed in x264's help except the filtering section? Or are there more options excluded?
So this only encoding means all options listed in x264's help except the filtering section? Or are there more options excluded?
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
libx264 is the library that does the actual work of generating an h.264 bitstream from a series of input frames. Anything not directly related to generation of the h.264 bitstream comes from the x264 exe. The only definitive reference I know of is the code. If it's not an option handled in x264/common/base.c then it's not an option handled by libx264.
Re: Resizing method used
I see. This look strange to me. As for the exe build, I can go to the developers' binaries folder on their site and download it, but there's no trace there of this dll you are talking about. If they provide this thing, it must exist somewhere on their server, doesn't it?
Re: Resizing method used
What dll?
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
A dll is a dynamic library. libx264 can be built either statically or dynamically. The exe that they distribute is linked against the static version of the library, so there is no need to build or distribute the dynamic version.
I've never looked to see if the x264 project distributes a pre-built dynamic library as it's not relevant to me or HandBrake. HandBrake builds a static version of libx264 from source. There are x264 build-time configure options you can set to force it to only build the library, which HandBrake uses.
I've never looked to see if the x264 project distributes a pre-built dynamic library as it's not relevant to me or HandBrake. HandBrake builds a static version of libx264 from source. There are x264 build-time configure options you can set to force it to only build the library, which HandBrake uses.
Re: Resizing method used
HandBrake uses Lanczos 3-tap aka Lanczos3.
Re: Resizing method used
Thanks, that's what I wanted to know in first place.
So I guess compiling either as a library or as an exe is a universal option available for any software, not just x264? This would explain why there's no special mention of this library on their site. Is this correct?JohnAStebbins wrote: ↑Thu Oct 18, 2018 8:45 pm HandBrake builds a static version of libx264 from source. There are x264 build-time configure options you can set to force it to only build the library, which HandBrake uses.
Re: Resizing method used
No, that's nowhere near correct.
While they have developers in common, libx264 and x264cli are separate things. x264cli uses libx264 plus other software, much like HB uses libx264 and other software.
While they have developers in common, libx264 and x264cli are separate things. x264cli uses libx264 plus other software, much like HB uses libx264 and other software.
- JohnAStebbins
- HandBrake Team
- Posts: 5726
- Joined: Sat Feb 09, 2008 7:21 pm
Re: Resizing method used
It's completely up to the developers how they structure their code. But it's a common development practice to have a core library or set of libraries for a project that one or more tools are built around. A project will often, but not always, have a core library or libraries that they build things around.
For x264, libx264 is the core library and x264.exe is the tool. For ffmpeg, libavcodec, libavformat, libavutil, libavfilter, libswscale, etc (there are several more) are the core libraries. ffmpeg, ffprobe, and ffplay are the tools built around these libraries. For HandBrake, the core library is libhandbrake and the tools are HandBrakeCLI and the 3 different GUIs for windows, osx, and linux.
Projects also use external libraries (i.e. libraries of code not developed or maintained by that project). x264 uses libavcodec, libavformat, libavutil, libswscale, etc from the ffmpeg project as external libraries when building x264.exe, but these libraries are not included as part of the functionality that is provided by libx264. ffmpeg project uses libx264 as an external library when building libavcodec. So libavcodec (when configured to do so at build time) includes support for h.264 encoding through the use of libx264 external library.
As you can see there is a lot sharing of libraries that goes every which way.
For x264, libx264 is the core library and x264.exe is the tool. For ffmpeg, libavcodec, libavformat, libavutil, libavfilter, libswscale, etc (there are several more) are the core libraries. ffmpeg, ffprobe, and ffplay are the tools built around these libraries. For HandBrake, the core library is libhandbrake and the tools are HandBrakeCLI and the 3 different GUIs for windows, osx, and linux.
Projects also use external libraries (i.e. libraries of code not developed or maintained by that project). x264 uses libavcodec, libavformat, libavutil, libswscale, etc from the ffmpeg project as external libraries when building x264.exe, but these libraries are not included as part of the functionality that is provided by libx264. ffmpeg project uses libx264 as an external library when building libavcodec. So libavcodec (when configured to do so at build time) includes support for h.264 encoding through the use of libx264 external library.
As you can see there is a lot sharing of libraries that goes every which way.
Re: Resizing method used
That's a good comprehensive explanation, thank you. These peculiarities are often mentioned, but almost never explained, thus making an impression that developers are deliberately confusing the users.