Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Aug 2012
Posts: 11
|
FFmpeg lossless rgb input/output command
I have successfully used x264.exe and avisynth to encode/decode RGB bmp images losslessly, using the following command:
x264 --crf 16 --bframes 0 --colormatrix GBR --qp 0 --preset placebo --range pc --input-range pc --input-csp rgb --output-csp rgb -o "%2" "%1" However I want to switch to using FFmpeg.exe to do the encoding (because avisynth does not support unicode). How can I do this? What is ffmpeg's equivalent of the command above? I have tried this but it does not work: ffmpeg -i "%1" -c:v libx264 -pix_fmt yuv444p -preset veryslow -qp 0 "%2" thanks. |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Aug 2012
Posts: 11
|
Sorry I just tried your solution, but it still shows a difference.
I am wondering if you can take a look. I have packed my test. Running test.bat will do the encoding/decoding/compare and the diff image will be save at o2/diff.bmp https://mega.co.nz/#!qchAxLBQ!cLt4TE1ggGD6OLilCkkBRgGcTXANIIif7fGkwBIInRc Thanks a lot |
![]() |
![]() |
![]() |
#4 | Link |
Yes, I'm weird.
Join Date: May 2010
Location: Southeast Asia
Posts: 271
|
[DEL]IIRC, FFmpeg currently doesn't support RGB H.264 output with libx264 yet (correct me if I'm wrong). It'll convert RGB24/BGR24 to YUV444P before feed to libx264, maybe that's why there's a difference.[/DEL]
EDIT: I'm wrong. You can output RGB H.264 with this command line: Code:
ffmpeg.exe -i %RGB_Source% -c:v libx264rgb -qp 0 -pix_fmt rgb24 %Output%
__________________
“Never argue with stupid people, they will drag you down to their level and then beat you with experience.” — Mark Twain Last edited by the_weirdo; 13th October 2013 at 16:10. |
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,258
|
I don't think ffmpeg libx264 can encode RGB (and you will have lossess during the RGB=>YUV conversion).
You can use use some other lossless RGB codec in ffmpeg eg.. FFV1 or UTvideo which also supports RGB I was going to suggest piping ffmpeg to x264, but yuv4mpegpipe doesn't support RGB either (not aware of any rgb4mpegpipe) |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Nov 2005
Posts: 687
|
Exactly, the_weirdo:
Code:
ffmpeg.exe -i <rgb-source> -pix_fmt bgr24 -c:v libx264rgb -preset veryslow -qp 0 <output> Another thing I'm really puzzled about is how to specify input- and output range as PC with FFMpeg. Code:
ffmpeg.exe -i <YCgCo-source> -pix_fmt yuv444p -c:v libx264 -preset veryslow -qp 0 -color_range 2 -colorspace 8 <output> ... Output #0, matroska, to 'D:\rgb_test(ffmpeg,q0,YCgCo).mkv': Metadata: encoder : Lavf55.19.100 Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(pc, YCgCo), 640x480, q=-1--1, 1k tbn, 25 tbc Sorry for being off-topic, but am I doing something wrong, or is FFMpeg limited or something?
__________________
My hobby website |
![]() |
![]() |
![]() |
#8 | Link |
Yes, I'm weird.
Join Date: May 2010
Location: Southeast Asia
Posts: 271
|
@CoRoNe
It seems that FFmpeg doesn't pass those VUI-options to libx264. You still need to use -x264-params for that (it doesn't recognize "range" option, but you can use "fullrange=on").
__________________
“Never argue with stupid people, they will drag you down to their level and then beat you with experience.” — Mark Twain Last edited by the_weirdo; 13th October 2013 at 18:50. Reason: for some reason, fullrange=on doesn't work with x264opts |
![]() |
![]() |
![]() |
#9 | Link |
Registered User
Join Date: Nov 2005
Posts: 687
|
I know, with -x264opts fullrange=on:colormatrix=YCgCo FFMpeg at least doesn't throw in an error, but fullrange=on doesn't do anything.
__________________
My hobby website |
![]() |
![]() |
![]() |
#10 | Link |
Yes, I'm weird.
Join Date: May 2010
Location: Southeast Asia
Posts: 271
|
Yes. I've also noticed that. However, it works with -x264-params for some reason.
__________________
“Never argue with stupid people, they will drag you down to their level and then beat you with experience.” — Mark Twain |
![]() |
![]() |
![]() |
#11 | Link |
Registered User
Join Date: Nov 2005
Posts: 687
|
Haha, you're right! Great find!
That's some strange behaviour. Especially since fullrange isn't a valid x264.exe-command anymore. And I didn't expect there to be any differences between -x264opts and x264-params.
__________________
My hobby website |
![]() |
![]() |
![]() |
#12 | Link |
Registered User
Join Date: Aug 2012
Posts: 11
|
Sorry for the late reply. Thank you! Both
Code:
ffmpeg.exe -i <rgb-source> -pix_fmt bgr24 -c:v libx264rgb -preset veryslow -qp 0 <output> Code:
ffmpeg.exe -i %RGB_Source% -c:v libx264rgb -qp 0 -pix_fmt rgb24 %Output% Just want to ask, is -pix_fmt rgb24 the same as -pix_fmt bgr24 ? |
![]() |
![]() |
![]() |
#13 | Link |
Registered User
Join Date: Nov 2005
Posts: 687
|
BGR24 is the default format. Afaik the difference is only a byte order, but maybe someone more knowledgeable could comment on this.
__________________
My hobby website |
![]() |
![]() |
![]() |
Tags |
ffmpeg, lossless, rgb, x264 |
Thread Tools | Search this Thread |
Display Modes | |
|
|