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. |
![]() |
#21 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
I gave it a go this morning and the simplest way is:
Code:
ffmpeg -colorspace bt709 -i "sample tagless video.mkv" -frames:v 24 -sws_flags accurate_rnd "%%d.png" ffmpeg -colorspace bt709 -i "sample tagless video.mkv" -frames:v 24 -sws_flags accurate_rnd "out.apng" ![]() ![]() GIF with error-diffusion dithering Code:
ffmpeg -colorspace bt709 -i "sample tagless video.mkv" -frames:v 1 -sws_flags accurate_rnd -sws_dither ed "out.gif" ![]() Last edited by GeoffreyA; 10th December 2024 at 09:38. |
![]() |
![]() |
![]() |
#22 | Link | |
Registered User
Join Date: Aug 2024
Posts: 378
|
Quote:
Please use full_chroma_int flag as well And this way the GIF is not using palette Please use palettegen and paletteuse Last edited by Z2697; 10th December 2024 at 10:40. |
|
![]() |
![]() |
![]() |
#23 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
Thanks, Z2697. Here's the updated script that should solve the problem, Jay:
Code:
:: Create PNG and APNG ffmpeg -colorspace bt709 -i "src.mkv" -frames:v 1 -sws_flags accurate_rnd+full_chroma_int "%%d.png" ffmpeg -colorspace bt709 -i "src.mkv" -frames:v 1 -sws_flags accurate_rnd+full_chroma_int "out.apng" :: Create palette and then GIF ffmpeg -colorspace bt709 -i "src.mkv" -vf palettegen -sws_flags accurate_rnd+full_chroma_int "palette.png" ffmpeg -colorspace bt709 -i "src.mkv" -i "palette.png" -lavfi paletteuse -frames:v 1 -sws_flags accurate_rnd+full_chroma_int "out.gif" ![]() GIF made with palette and Sierra-24A dithering: ![]() Here's a reusable way of doing it. Place this in a BAT file. Change the variables src, start, and frames and run the file. Code:
setlocal set src=sample tagless video.mkv set start=2 set frames=24 :: Create PNG and APNG ffmpeg -ss %start% -colorspace bt709 -i "%src%" -frames:v %frames% -sws_flags accurate_rnd+full_chroma_int "%%d.png" ffmpeg -ss %start% -colorspace bt709 -i "%src%" -frames:v %frames% -sws_flags accurate_rnd+full_chroma_int "out.apng" :: Create palette and then GIF ffmpeg -colorspace bt709 -i "%src%" -vf palettegen -sws_flags accurate_rnd+full_chroma_int "palette.png" ffmpeg -ss %start% -colorspace bt709 -i "%src%" -i "palette.png" -lavfi paletteuse -frames:v %frames% -sws_flags accurate_rnd+full_chroma_int "out.gif" endlocal pause Last edited by GeoffreyA; 10th December 2024 at 12:46. |
![]() |
![]() |
![]() |
#24 | Link |
Registered User
Join Date: Aug 2024
Posts: 378
|
Did you notice that the new GIF image is now having "jagged chroma" (well, not actual chroma 'cause it's RGB, but you get the point).
And the old GIF image is somehow not having "jagged chroma"... WTF? swscale and auto-inserted scale filter is a huge mess. |
![]() |
![]() |
![]() |
#26 | Link | ||
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
Quote:
EDIT: The problem is, for some reason in the GIF example, the sws flags aren't being set: Code:
[auto_scale_1 @ 0000021bcef58300] w:1920 h:1080 fmt:yuv420p csp:bt709 range:unknown sar:1/1 -> w:1920 h:1080 fmt:bgra csp:gbr range:pc sar:1/1 flags:0x00000004 Code:
[auto_scale_0 @ 000001ef02b73200] w:1920 h:1080 fmt:yuv420p csp:bt709 range:unknown sar:1/1 -> w:1920 h:1080 fmt:rgb24 csp:gbr range:pc sar:1/1 flags:0x00042000 Quote:
![]() ![]() Last edited by GeoffreyA; 10th December 2024 at 14:55. |
||
![]() |
![]() |
![]() |
#27 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,607
|
Quote:
The results are still off slightly using -colorspace bt709 as an input option with -sws_flags accurate_rnd only - you can verify this on colorbars or patterns with known and expected values, there is a brightness shift and even greyscale values are off . Adding full_chroma_int as mentioned in the other thread gets it to the expected values -sws_flags full_chroma_int+accurate_rnd . This gives similar results to zscale The other way to do it with swscale, instead of -colorspace is with scale Code:
-vf scale=in_color_matrix=bt709 -sws_flags full_chroma_int+accurate_rnd Personally I would use zscale in ffmpeg |
|
![]() |
![]() |
![]() |
#28 | Link | |
Registered User
Join Date: Apr 2024
Posts: 331
|
Quote:
|
|
![]() |
![]() |
![]() |
#29 | Link | |
Registered User
Join Date: Aug 2024
Posts: 378
|
Quote:
Last edited by Z2697; 10th December 2024 at 16:44. |
|
![]() |
![]() |
![]() |
#30 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
Quote:
For simplicity and most viewers, the auto-insert system is powerful, negotiating silently between disparate video and audio formats; it is part of FFmpeg's "magic." But for folk like us, who are aiming for reference correctness and full precision, it is a minefield, and I find I've got to verify every encoding script with -loglevel debug or trace to make sure the auto-inserted scale or resample filters aren't making an appearance. I think the FFmpeg team needs to audit the swscale codebase, line by line, and make sure that all conversions are being done according to reference convention and full precision (as zimg does); it's not 2010 any more and is baffling that "accurate" calculations have to be enabled. |
|
![]() |
![]() |
![]() |
#35 | Link |
Registered User
Join Date: Apr 2024
Posts: 331
|
One more thing, for videos with colorimetry flags, should I remove the
Code:
min=709,format=gbrp Code:
zscale=pin=2:p=2:tin=2:t=2 https://forum.doom9.org/showthread.p...15#post2010515 |
![]() |
![]() |
![]() |
#36 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
Quote:
Last edited by GeoffreyA; 1st January 2025 at 09:11. |
|
![]() |
![]() |
![]() |
#38 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
Quote:
Code:
ffmpeg -i "INPUT.mkv" -vf zscale=pin=2:p=2:tin=2:t=2:min=709,format=gbrp -sws_flags accurate_rnd+full_chroma_int "%%d.png" ffmpeg -i "INPUT.mkv" -vf zscale=pin=2:p=2:tin=2:t=2:min=709,format=gbrp -sws_flags accurate_rnd+full_chroma_int "OUTPUT.apng" Alternatively, to remove swscale out of the equation, you can try libplacebo, which uses the GPU and requires Vulkan support: Code:
ffmpeg -init_hw_device vulkan -i "INPUT.mkv" -vf libplacebo=format=rgb24 "%%d.png" Last edited by GeoffreyA; 2nd January 2025 at 09:47. |
|
![]() |
![]() |
![]() |
#39 | Link | |
Registered User
Join Date: Apr 2024
Posts: 331
|
Quote:
Code:
-vf zscale=pin=2:p=2:tin=2:t=2:min=709,format=gbrp |
|
![]() |
![]() |
![]() |
#40 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 265
|
I tried it on both flagged and unflagged videos (your anime one), and it seems to work all right, producing files without the gAMA and cHRM chunks.
Last edited by GeoffreyA; 2nd January 2025 at 20:37. |
![]() |
![]() |
![]() |
Tags |
colorspace, ffmpeg gui, image-quality |
Thread Tools | Search this Thread |
Display Modes | |
|
|