I have downloaded ffmpeg static build.
Failed to get code to work.
FOURCC code 'HEVC'
FFMPEG / x265 lossless
YUV420P16
+ Reply to Thread
Results 1 to 17 of 17
-
-
How to use lossless encoding with ffmpeg and x265:
https://trac.ffmpeg.org/wiki/Encode/H.265#Losslessencoding
If you query ffmpeg x265 pixel format capabilities:
Code:ffmpeg -h encoder=libx265 >libx265.txt
Then you get:
Code:Encoder libx265 [libx265 H.265 / HEVC]: Supported pixel formats: yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p gbrp yuv420p10le yuv422p10le yuv444p10le gbrp10le yuv420p12le yuv422p12le yuv444p12le gbrp12le gray gray10le gray12le
-
Normally HEVC support up to 12 bit per component - to encode 16 bit per component you need to use profile 'Main 4:4:4 16 Intra' - AFAIK x265 doesn't support this profile also i'm not aware of any open HEVC implementation supporting such profile.
Perhaps your 16 bit per component source was converted silently into 12 bit or less.
Btw - after decode 12 bit may be inserted to 16 bit (for example to speedup operation as CPU generally deal poorly with non aligned data).
Verify if your source is truly 16 bit or just carried by 16 bit pixel format. -
It had me very confused because vdub2 had it under ffmpeg.
Thanks Pandy and poisondeathray, its making sense now.
As best I can tell this is the highest quality mp4 save format for vdub2?
Please let me know if their is a better vdub2 option!
PHP Code:SELECT VIDEO COMPRESSION
Video Compression: FFMPEG / x265 lossless
Video codec information.
About.
Delta frames - Yes
FOURCC code - 'HEVC'
Driver name - avlib-1.vdplugin
Comment: Works with VD formats.
x265 Configuration.
YUV 4:2:0
Bit depth: 12
Quality: lossless
Output format to compressor.
Actual output: YUV420P16
4:2:0 planar YCbCr 16-bit
Saved Video
Video
ID : 0
Format : HEVC
Format/Info : High Efficiency Video Coding
Codec ID : HEVC
The idea is to force the highest quality mp4 output, which might differ from the meaning of lossless because the input quality is irrelevant.
This is only for editing experiments, so size is not an issue.
As mentioned, I have the ffmpeg static build.Last edited by Tom4; 16th Jan 2024 at 18:26.
-
Highest quality would be your source pixel format (or output pixel format from a filter chain if using filters)
There is a chance that you actually get lower quality - despite lossless encoding - if you don't perform the pixel type conversion(s) correctly
Describe your initial source, any steps or filters in between
For example, if you actually had YUV420P16 content - and wanted to keep 16bit - you would use FFV1 . You can configure the FFV1 settings and pixel type in the encoder configuration
Editing with "what" ? There are types of pixel formats and compression types will not be compatible with some editors . You couldn't import a 16bit 4:2:0 FFV1 into Premiere Pro for example -
Sorry, I must have been typing when you replied.
adding: The idea is to force the highest quality mp4 output, which might differ from the meaning of lossless because the input quality is irrelevant. Even if this process ended up reducing quality through pixel type conversion.
Just curious how to write the code to start?
I did not have any editing software in mind.
As mentioned, I saved HEVC YUV420P16 through configuration in vdub2.
Loaded the HEVC mp4 in Hitpaw out of curiosity, it can load, process and save.
Not that I like or use Hitpaw, just used for example.
Getting back to the highest quality 265 mp4 format available from ffmpeg cmd.
Which might differ from the meaning of lossless because the input quality is irrelevant.
I will test what software accepts it and worry about compatibility after!
Could you offer me an example code how it might be written for ffmpeg cmd?Last edited by Tom4; 16th Jan 2024 at 19:02.
-
The highest quality is lossless encoding in the same pixel format .
Lossless encoding is irrelevant of input "quality". If your input video is "garbage quality", the output video is lossless and preserves the exact same "garbage quality" .
Lossless is the highest "quality", because there is no additional quality loss. Everything else not lossless is "lossy" encoding, which means data loss and therefore quality loss.
Something can only be lossless , and the highest quality, if it's the same pixel type. If your input was 16 bit data , it's not supported by x265 - so you lose quality. So the pixel format matters. (Theoretically you could increase the bit depth, and upsample chroma, but if it's not done correctly for the up and down step, you lose quality)
This is for video only
Code:ffmpeg -i input.ext -c:v libx265 -an -x265-params lossless=1 output.mp4
-
I understand pretty much exactly what you are saying poisondeathray, garbage in equals garbage out.
If you process a video 10 times to improve quality, you need to save and retain your edit details and quality with each proceeding save.
So by the 10th process you are no longer saving the same file and detail in the original but the file that has been processed to contain perhaps 10x as much detail and data.
This subject can lead to arguments because of the different needs, wants and opinion of so many forum members.
Thanks for your understanding poisondeathray, really helpful
ffmpeg -i input.mp4 -c:a copy -c:v libx265 -preset placebo -crf 0 -pix_fmt yuv444p12le out.mp4
(Note: I have not tested the code above for errors, internet access and offline processing PC are in different locations!)
Or
ffmpeg -i input.mp4 -c:a copy -c:v libx265 -an -x265-params lossless=1 out.mp4
I normally save audio wave file to be added back after.
Just out of curiosity, can we just copy audio as above with this code?Last edited by Tom4; 16th Jan 2024 at 20:03.
-
-
-
-
Like this?
PHP Code:ffmpeg -i input.mp4 -c:a copy -c:v libx265 -an -x265-params lossless=1 -pix_fmt yuv444p12le out.mp4
-
-
And that is the desired result , because it's exactly the same garbage ; not different garbage
If you process a video 10 times to improve quality, you need to save and retain your edit details and quality with each proceeding save.
So by the 10th process you are no longer saving the same file and detail in the original but the file that has been processed to contain perhaps 10x as much detail and data.
This subject can lead to arguments because of the different needs, wants and opinion of so many forum members.
Thanks for your understanding poisondeathray, really helpful
Also some editors do not handle all "lossless" formats correctly - you lose quality each time because they are not handled properly in the editor. A common example are most lossless YUV codecs in "pro" NLE's . They often clip YUV data and convert to RGB
=> Lossless means you can get back the original uncompressed data, exactly. Bit for bit. There is no data change, rounding errors, artifacts or any type loss. If you were to measure the quality with PSNR, "lossless" would yield "infinity" dB . Anything else would indicate some quality loss
Even if you use lossless compression - you can lose quality with other processing steps, such as improper handling of pixel types, improper handling of lossless compression (E.g. some editors)
For example if input was 4:2:0 , and you force usage the default ffmpeg chroma upscaler to 4:4:4, that is non reversible operation and technically additional quality loss compared to the input . If you were to measure PSNR of the output file against the input file, the PSNR would decrease. If you upscale the chroma with lossless encoding, you also increase the filesize for no benefit. (But if you chroma upsampled it properly with "nearest neighbor", then the upsample can be lossless, if the downsample uses nearest neighbor as well.)
Same with bit depth increases - if they are not handled properly (e.g. often dithering is applied on the down conversion step) - you can get quality loss. If you increase the original bit depth with lossless encoding, you also increase the filesize for no benefit.
The more things you do for no good reason (think of it as "more moving parts" to break down) - the more things can go wrong if not done properly
Similar Threads
-
Bitrate Viewer ... but for H265 / HEVC
By kalemvar1 in forum Video ConversionReplies: 5Last Post: 17th Jan 2024, 18:21 -
Best/Fastest converter for HEVC H265 using hardware
By gooroomp in forum Video ConversionReplies: 6Last Post: 7th Jun 2021, 10:10 -
H265/HEVC to H264/AVC
By Daringbaaz in forum Newbie / General discussionsReplies: 5Last Post: 22nd Sep 2019, 11:34 -
HEVC / H265 video conversion on Android
By Steve75 in forum Video ConversionReplies: 14Last Post: 21st Jul 2019, 02:42 -
Nvidia h.265 hevc lossless
By qo4on in forum Video ConversionReplies: 30Last Post: 11th Apr 2019, 07:45