Low FPS and Pixelation Issues While Exporting Video Using Open CASCADE Image_VideoRecorder

I am using Open CASCADE’s Image_VideoRecorder to export videos, but I am facing performance issues.

System Configuration:
CPU: Intel i7-12700F
GPU: RTX 3050 (6GB)
RAM: 32GB
Storage: 1TB SSD
Monitor: 4K

Issue:
When exporting videos at 4K 60 FPS or 4K 30 FPS, the first 8–9 frames are high quality, but after that, the quality drops, and frames become pixelated. The maximum stable frame rate I achieve is 6 FPS, causing the video to appear choppy.
Attached zip file for reference.

Code Snippet:

Referance :
src/ViewerTest/ViewerTest_ViewerCommands.cxx


Image_VideoParams aRecParams;
Handle(Image_VideoRecorder) aRecorder;
V3d_ImageDumpOptions aDumpParams;
aDumpParams.BufferType = Graphic3d_BT_RGBA;
aDumpParams.StereoOptions = V3d_SDO_MONO;
aDumpParams.ToAdjustAspect = Standard_True;

Troubleshooting Done:
Tested different resolutions and frame rates.
Verified GPU and CPU usage during export.
Ensured sufficient SSD write speed.

Questions:
Is there a way to optimize Image_VideoRecorder for higher FPS and better quality?
Can I enable hardware acceleration (NVENC) in Open CASCADE for better encoding performance?
Are there recommended settings to reduce pixelation while maintaining 4K output?
Would lowering BufferType to Graphic3d_BT_RGB help improve performance?

Attachments: 
gkv311 n's picture

Mpeg4 codec doesn't suit well for 4K resolution (at least with default parameters - probably they should be adjusted somehow to improve quality).

I may propose using another codec like mjpeg (and reconvert result video file using external tools), or vp9 (with .mkv container), or h264 (but for the latter you need using FFmpeg built with this codec enabled):

pload MODELING VISUALIZATION
box b 100 200 300
vinit View1
vbackground -gradient SKYBLUE GRAY
vrotate 0 0.1 0
vdisplay -dispMode 1 b
vaspects b -faceBoundaryDraw 1
vfit
vzoom 0.5
vanimation anim -clear
vanimation anim/b -objectTrsf b -loc1 0 0 0 -loc2 100 0 0 -start 0 -duration 3
#vanimation anim -play 0.0
vanimation anim -record box.avi 3840 1440 -vcodec mjpeg
rahulmulik9's picture

Thank you
The problem was solved when I use codec "mjpeg "

rahulmulik9's picture

Sometimes, the file size is too large.
Is there a way to adjust the video quality to reduce the file size?

gkv311 n's picture

Sometimes, the file size is too large. Is there a way to adjust the video quality to reduce the file size?

mjpeg means 'motion jpeg', and JPEG is not that good at providing high compression ratios for videos. It does have a parameter defining quality / compression ratio qmin/qmax, but Image_VideoRecorder::openVideoCodec() doesn't allow changing it, and reducing JPEG quality is probably not very useful.

Consider playing with other codecs like VP9 which suit better for video and not still images.

I guess using NVENC should be also possible through FFmpeg, but this may require tuning OCCT.

rahulmulik9's picture

Whenever I use other formats like VP9, H.264, or H.265, the application crashes at
writeVideoFrame().
Standard_Boolean PushFrame()
{
return writeVideoFrame(Standard_False);
}

The PushFrame() method is called from:
aRecorder->PushFrame();
where aRecorder is an instance of Image_VideoRecorder.

The only setting that works for me is:
aRecParams.Format = "matroska";
aRecParams.VideoCodec = "mjpeg";

rahulmulik9's picture

Whenever I use other formats like VP9, H.264, or H.265, the application crashes at writeVideoFrame().
Standard_Boolean PushFrame()
{
return writeVideoFrame(Standard_False);
}
The PushFrame() method is called from:
aRecorder->PushFrame();
where aRecorder is an instance of Image_VideoRecorder.

The only setting that works for me is:
aRecParams.Format = "matroska";
aRecParams.VideoCodec = "mjpeg";