Compare the performance of ffmpeg and pyav #1887
Replies: 1 comment
-
I have solved my original question (timecode-aware encoding) by combining x264 (cli) and mp4fpsmod tool. This discussion could be closed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using pyav to help me encode raw video stream from a industrial camera. The camera API can output frames (numpy array) and timestamp to keep video sync to the actual time. That is, although my camera is set to 60fps, the actual fps would always be slightly faster than 60 (60.47 maybe? but it's hard to predict the behaviour of my camera). PyAV gave me the chance to set pts, which I found it's hard to set using ffmpeg directly.
But I noticed that when encoding, the CPU usage is only 35%, while 50% when using ffmpeg. And the encoding speed is also ~75% of the newest ffmpeg(7.1.1). I am using libx264 with medium preset, and the threads are set to 0(auto). I am using i9-14900K with dual channel DDR5 4800MHz.
Here's example code for PyAV encoding:
When encode 1000 random noise image, the result shows the encode method is the bottleneck (95% time).
Compare to the performace of ffmpeg, for the same 1000 random noise image, it only cost 9s.
I wonder if the performance comparison of PyAV and ffmpeg is expected? Are there any other optimization I can do to increase the CPU usage in order to get better performance? Since the bottleneck is stream.encode, I would expected that the PyAV can have similar encode performance compared with ffmpeg.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions