Closed gwappa closed 2 years ago
migrated to use PyAV.
What was observed during testing 1f77fc3 :
Possible causes: the additional frame-copy step. Some rough checks on a decent CPU tell that a single-frame copy()
(640 x 480 RGB24) can take ~3 ms on average! On the other hand, just copying the content took ~0.3 ms/frame, suggesting most of the latency comes from memory allocation.
Temporary solutions:
BufferThread
so that array allocation should not occur in the callback context (3fa2c1f).tested 5226735, and found the results to be even worse than when I used bare ffmpeg
...
the (relatively heavy) use of python in the callback context seems to be the culprit. It may be necessary to refine the encoder code based on PyAV, and migrate completely to Cython-based.
The use of bare ffmpeg
(possibly with buffers?) could be at least better than PyAV-based code. I will try this approach for the time being.
1e42336 back to the original figures after migrating to ffmpeg pipe + buffering.
In theory, further steps may be taken as:
libavcodec
without bothering the GIL.But I have no idea how long it could take for me to implement them...
come to think of it, buffering frames as soon as they are acquired (in addition to buffering at the storage step) would be even better solution.
need to modify ks-tisgrabber
then...
as of 2b1e938
it does not seem like the limit of GPU encoding but rather an error in task prioritization (which I probably do not have much control on).
Now everything is clear:
prepareLive()
call. This means (1) one will always miss several "frame triggers" up to the point startLive()
is called, and (2) on e can miss a frame or two after calling stopLive()
, as it can prevent the camera from sending the incoming frame(s).The problem now is to reworking with the system of trigger modes... (see #22 )
The number of strobe triggers do not often match with that of the resulting frames in the saved video.
Some of the most recent figures:
Based on the discussion in this issue https://github.com/TheImagingSource/IC-Imaging-Control-Samples/issues/37 , frame drops must be strictly avoided by minimizing the overhead taken to process individual frames (i.e. during callbacks).
Possible bottlenecks (those I can think of currently):
ffmpeg
processThere are two possibilities:
ffmpeg
-related libraries, cf.