vedb / pupil_recording_interface

A pythonic interface for the Pupil Core system
https://vedb.github.io/pupil_recording_interface
GNU General Public License v3.0
1 stars 0 forks source link

Stress test the recording start, pause and stop #63

Closed KamranBinaee closed 3 years ago

KamranBinaee commented 4 years ago

There have been a few incidents that the ctrl+c doesn't stop the recording appropriately and either it needs a long delay or the recording streams are not terminated/saved correctly.

phausamann commented 3 years ago

The issue with quitting seems to be ffmpeg not shutting down gracefully. With Ctrl+C, at least the SIGINT seems to be propagated to the ffmpeg process but that doesn't work reliably all the time, hence the broken videos. When using another key, the ffmpeg processes aren't stopped at all.

We have two options:

  1. Figure out a way to shut down the ffmpeg sub-processes gracefully
  2. Use PyAV instead of ffmpeg

The second one is probably the cleaner solution, but PyAV doesn't support encoding of the raw Bayer RGGB8 buffers that the FLIR camera produces (yet).

phausamann commented 3 years ago

If we figure out a way to stop ffmpeg gracefully without Ctrl-C, we need to make sure the SIGINT is not propagated to the sub-processes. There seems to be a solution for that:

import subprocess
import signal

def preexec_function():
    # Ignore the SIGINT signal by setting the handler to the standard
    # signal handler SIG_IGN.
    signal.signal(signal.SIGINT, signal.SIG_IGN)

my_process = subprocess.Popen(
    ["my_executable"],
    preexec_fn = preexec_function
)
phausamann commented 3 years ago

Closing this for now, but feel free to re-open if the issue persists (e.g. broken video files because the 3 second timeout before killing the ffmpeg process isn't enough).