Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib Ng support #489

Closed
wants to merge 3 commits into from
Closed

Zlib Ng support #489

wants to merge 3 commits into from

Conversation

reinismu
Copy link

I have done my testing and zlib-ng is a big improvement for me.

With fast compression in around the same time I get 10x lower size.
At default settings it is around 70% faster

I did my examples using gstreamer plugin

before

gst-launch-1.0 videotestsrc is-live=false num-buffers=1000 ! videoconvert ! video/x-raw, format=RGBA, width=1920, height=1080 ! rspngenc compression-level=1 ! filesink location=test.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:07.891137892
Setting pipeline to NULL ...
Freeing pipeline ...


3,3G jūl 26 11:00 test.mp4

gst-launch-1.0 videotestsrc is-live=false num-buffers=1000 ! videoconvert ! video/x-raw, format=RGBA, width=1920, height=1080 ! rspngenc compression-level=0 ! filesink location=test1.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:17.072891381
Setting pipeline to NULL ...
Freeing pipeline ...

238M jūl 26 11:01 test1.mp4

after

gst-launch-1.0 videotestsrc is-live=false num-buffers=1000 ! videoconvert ! video/x-raw, format=RGBA, width=1920, height=1080 ! rspngenc compression-level=1 ! filesink location=test3.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:04.044782989
Setting pipeline to NULL ...
Freeing pipeline ...

422M jūl 26 11:29 test3.mp4

gst-launch-1.0 videotestsrc is-live=false num-buffers=1000 ! videoconvert ! video/x-raw, format=RGBA, width=1920, height=1080 ! rspngenc compression-level=0 ! filesink location=test3.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:10.079236244
Setting pipeline to NULL ...
Freeing pipeline ...

258M jūl 26 11:30 test3.mp4

Note: I was running on x64_86 linux

@reinismu
Copy link
Author

Noticed that not Fast compression uses another library. Why not move it to new compression option?

@fintelia fintelia closed this Aug 25, 2024
@fintelia
Copy link
Contributor

This can already be enabled by downstream users. No need to include here

@Shnatsel
Copy link
Contributor

We might want to expose zlib-rs as an option for faster encoding/decoding at the cost of some unsafe code. flate2 now exposes a feature to enable it. You get the performance of zlib-ng without any of the horrors of compiling C code, and it is marginally safer too.

@fintelia
Copy link
Contributor

If you add flate2 = { version = "1.0.33", features = "zlib-rs"} to your Cargo.toml, this crate will use zlib-rs for encoding (if you pick Default or Best as the compression level). Same for zlib-ng.

The Fast compression level and all decoding uses fdeflate.

@Shnatsel
Copy link
Contributor

That's true, I was just considering whether it could be exposed in a more user-friendly way and/or better documented.

A common concern with this method is that the flate2 crate version may get out of sync between the png crate and the user's crate, but with flate2 staying at 1.0 for so long it's probably not a big issue in practice, at least for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants