Hi.
I am using Openh264 as a plugin to encode a game play in Unity3D engine.
The game is running 60 fps but I am encoding at 30 fps.
The encoding process looks like this: the encoder is running continuously from the start of the game.
Once a user presses a "save footage" the plugin grab the last 10 seconds of the video frames (I cache those in a buffer)
and saves it as raw h264 video steam on the disk. The problem I observe is that Openh264 can't keep up with the 30 fps. It gets an image frame (720p)fetched every 33ms , but for 10 seconds it able to produce only ~260-270 video frames when 300 is expected.To make sure the problem is not in the code around I tested also this scenario with Nvidia video encoder ( nvenc) and libx264 h264 encoders. These work fine. Additionally, the number of missing frames growth with the duration: the longer the video duration I am recording the larger the gap from the target number of video frames. I tried to set number of threads explicitly, but it doesn't change anything.
Why I think it has to do with multi-threading? I tested the encoder also in a standalone application which runs on a simple d3d11 renderer and uses just a couple of more threads,one of which is used to transform color space and encode - this one works correctly too.
Unity is heavily multi-threaded, and I suspect it impacts the encoder's performance. Maybe I am wrong about threads and it is something else. Would be glad to hear other ideas.
Thanks.
Hi. I am using Openh264 as a plugin to encode a game play in Unity3D engine. The game is running 60 fps but I am encoding at 30 fps.
The encoding process looks like this: the encoder is running continuously from the start of the game. Once a user presses a "save footage" the plugin grab the last 10 seconds of the video frames (I cache those in a buffer) and saves it as raw h264 video steam on the disk. The problem I observe is that Openh264 can't keep up with the 30 fps. It gets an image frame (720p)fetched every 33ms , but for 10 seconds it able to produce only ~260-270 video frames when 300 is expected.To make sure the problem is not in the code around I tested also this scenario with Nvidia video encoder ( nvenc) and libx264 h264 encoders. These work fine. Additionally, the number of missing frames growth with the duration: the longer the video duration I am recording the larger the gap from the target number of video frames. I tried to set number of threads explicitly, but it doesn't change anything. Why I think it has to do with multi-threading? I tested the encoder also in a standalone application which runs on a simple d3d11 renderer and uses just a couple of more threads,one of which is used to transform color space and encode - this one works correctly too. Unity is heavily multi-threaded, and I suspect it impacts the encoder's performance. Maybe I am wrong about threads and it is something else. Would be glad to hear other ideas. Thanks.