8

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.

teamblast
  • 81
  • 1
  • 1
  • 4

1 Answers1

5

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

mwfearnley
  • 3,303
  • 2
  • 34
  • 35
  • 2
    The command formatted like this works fine for me, thank you! Note however that `qp=0` and `crf=0` can be omitted, since according to [x265 docs](https://x265.readthedocs.io/en/default/lossless.html), `lossless` implies `qp=4` (*"In HEVC, only QP=4 is truly lossless quantization, and thus when encoding losslesly x265 uses QP=4 internally in its RDO decisions."*), and rate control is disabled as well. – Daniel Saner Feb 04 '19 at 11:15
  • This is not the same qp. Also for libx264 wrapper of ffmpeg -qp 0 is really lossless not crf 0. – Валерий Заподовников Dec 31 '21 at 01:42
  • Why are all of those extra parameters needed? Here's how I typically do a lossless-encode to H265: ``` ffmpeg -i Nexigo-Iris-Mode-Change.mp4 -c:v libx265 -x265-params lossless=1 Nexigo-Iris-Mode-Change-H265.mp4 ``` The only parameter I pass is lossless=1. This is exactly what the documentation says to do: https://trac.ffmpeg.org/wiki/Encode/H.265 – Raleigh L. Oct 07 '22 at 02:50