# Optimizing Video Frame Processing with GStreamer: GPU Acceleration and Parallel Processing

**URL:** https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190
**Category:** Application Development
**Tags:** rust
**Created:** [February 25, 2025, 10:40am UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190 "2025-02-25T10:40:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![altunenes](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/altunenes/32/799_2.png) [@altunenes](https://discourse.gstreamer.org/u/altunenes)
#### Post date: [February 25, 2025, 10:40am UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/1 "2025-02-25T10:40:55Z")

</div>

Hello! I’ve developed an open-source application that performs face detection and applies scramble effects to facial areas in videos. The app works well, thanks to the gstreamer, but I’m looking to optimize its performance.

My pipeline currently:

1. Reads video files using `filesrc` and `decodebin`
2. Processes frames one-by-one using `appsink`/`appsrc` for custom frame manipulation
3. Performs face detection with an ONNX model
4. Applies scramble effects to the detected facial regions
5. re-encode…

The full implementation is available on GitHub: [scramblery/video-processor/src/lib.rs at main · altunenes/scramblery · GitHub](https://github.com/altunenes/scramblery/blob/main/video-processor/src/lib.rs)

My question is there a “general” way to modify the pipeline to process multiple frames in parallel rather than one-by-one? What’s the recommended approach for parallelizing custom frame processing in GStreamer while maintaining synchronization? of course I am not expecting a “code”, I am just looking for insight or an example on this topic so that I can study it and experiment with it. 🙂

saw some comments replacing elements like `x264enc` with GPU-accelerated encoders (like `nvenc` or `vaapih264enc`) but I think they are more meaningful after I make my pipeline parallel (?)… 🤔

---

<div class="post-metadata">

### Author: ![altunenes](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/altunenes/32/799_2.png) [@altunenes](https://discourse.gstreamer.org/u/altunenes)
#### Post date: [February 26, 2025, 10:55am UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/2 "2025-02-26T10:55:26Z")

</div>

I got an answer from here:  
[https://www.reddit.com/r/gstreamer/comments/1ixzrdk/optimizing\_video\_frame\_processing\_with\_gstreamer/](https://www.reddit.com/r/gstreamer/comments/1ixzrdk/optimizing_video_frame_processing_with_gstreamer/)

But I’d be grateful for additional comments always 🙂

---

<div class="post-metadata">

### Author: ![ndufresne](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/ndufresne/32/10_2.png) [@ndufresne](https://discourse.gstreamer.org/u/ndufresne)
#### Post date: [February 26, 2025, 12:35pm UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/3 "2025-02-26T12:35:17Z")

</div>

I could not view in a browser the suggestion on Reddit (it strictly forces using the app for this post). To make your use case entirely in GStreamer, you’d need to develop an variant of funnel that actually place back the frames in the right order. Then you’d simply use a combination of tee, queue and syncfunnel. I’ll keep that in mind, perhaps a project for later. Fits well with our goal to try and keep in the graph the AI processing (we have onnx plugins and AI metadata).

Now, since you already use an appsrc, and your explanation suggest the scrambling is done outside of the pipeline, my suggestion would be to create number of threads. Each thread when activated would process one frame, and signal it.

A very simple scheduling that will provide parallelism and ordering is to feed incoming frames into each thread and in a second thread wait for frames to be ready. You’d wait on one thread at a time in the same ordering. This should work for a handful of threads, but if you aim for bigger number, be aware that the ping-pong quickly becomes expensive and inefficient (e.g. won’t scale for 100cores).

The encoding must stay in order, so using a faster encoder such as VA encoders is the best optimization.

---

<div class="post-metadata">

### Author: ![altunenes](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/altunenes/32/799_2.png) [@altunenes](https://discourse.gstreamer.org/u/altunenes)
#### Post date: [February 26, 2025, 12:55pm UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/4 "2025-02-26T12:55:58Z")

</div>

thank you so much! I’ll experiment this idea 🙂

---

<div class="post-metadata">

### Author: ![rgonzalezfluendo](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rgonzalezfluendo/32/114_2.png) [@rgonzalezfluendo](https://discourse.gstreamer.org/u/rgonzalezfluendo)
#### Post date: [February 26, 2025, 3:02pm UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/5 "2025-02-26T15:02:36Z")

</div>

For your information, we open-sourced our solution to maximize encoding performance using all the cores. This solution is based on time-slicing parallelization (fixed duration in this case).

The concept can be used not only for encoding but also for any type of custom frame processing.

You can read our blog post [1] and the implementation done in Rust is in GitHub [2].

[1] [HYPE: HYbrid Parallel Encoder - Fluendo](https://fluendo.com/blog/hype-hybrid-parallel-encoder/)  
[2] [GitHub - fluendo/flu-plugins-oss at hype](https://github.com/fluendo/flu-plugins-oss/tree/hype)

---

<div class="post-metadata">

### Author: ![altunenes](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/altunenes/32/799_2.png) [@altunenes](https://discourse.gstreamer.org/u/altunenes)
#### Post date: [February 26, 2025, 4:26pm UTC](https://discourse.gstreamer.org/t/optimizing-video-frame-processing-with-gstreamer-gpu-acceleration-and-parallel-processing/4190/6 "2025-02-26T16:26:23Z")

</div>

great resource thank you!
