Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a lossless encoding with ffmpeg - libx265

I would like to convert 16 bits grayscale images in an HEVC/mkv video with the x265 encoder without loss, using ffmpeg. I use the monochrome12 profile. My first step is to convert images into yuv format:

ffmpeg -f image2 -i "C:\DATA FOLDER\images%d.png" video.yuv

And I try to convert it as a .mkv file, losslessly:

ffmpeg video.yuv video.mkv -c:v libx265 -x265-params "profile=monochrome12:crf=0:lossless=1:preset=veryslow:qp=0" 

But I get

Unrecognized option '-lossless' 
Error splitting the argument list : Option not found

When I don't write lossless=1 everything's right, but I don't manage to have a lossless video by this way.

thank you for your help.

like image 297
teamblast Avatar asked May 20 '16 11:05

teamblast


People also ask

Is FFmpeg lossless?

ffmpeg - Lossless universal video format - Super User. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Is CRF 0 lossless?

The range of the CRF scale is 0–51, where 0 is lossless (for 8 bit only, for 10 bit use -qp 0), 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28.


1 Answers

It works for me if I make a few changes:

ffmpeg -i video.avi -c:v libx265 \
    -x265-params "profile=monochrome12:crf=0:lossless=1:preset=veryslow:qp=0" \
    video.mkv

This is like the command you've provided, except I'm using a different input format, and prepend -i to mark it as an input file.

I also put the output filename at the end, after the output options, otherwise they are not applied, and I get this warning among the output:

Trailing options were found on the commandline.

I don't think the command you gave would cause the error you get though.

libx265 will not give an error on params it doesn't recognise, but show a warning like:

[libx265 @ 0x563e4520e740] Unknown option: lessloss.

I can reproduce your exact error by trying to add --lossless as a parameter to ffmpeg:

ffmpeg --lossless -i video.avi video.mkv

Unrecognized option '-lossless'.

Error splitting the argument list: Option not found

like image 120
mwfearnley Avatar answered Nov 24 '22 07:11

mwfearnley