Hello,
I’m working on a streaming application with Python that captures video and sound from a capture card. The problem is that I need to switch between several sources connected to the card, in particular between PAL in 576p @ 50Hz and NTSC in 720p @ 59.940/60Hz.
Currently, I have to recreate the pipeline each time the card’s resolution and frequency change. I’ve tried various approaches, such as using pipe/fifo, RTMP and UDP, but this leads to problems of desynchronization between sound and video, and in some cases video jerks.
The idea was to intercept the image, detect whether the card was still present or whether the signal had changed, and transmit a black image or the card image accordingly. It’s also essential to normalize the frequency to 60Hz and guarantee stable resolution at 576p.
I managed to achieve partially correct operation with pipes and FFmpeg by sending the normalized stream to the pipe. However, this solution is not always reliable.
With GStreamer, I tried using an appsrc
, but I couldn’t get the video and sound to synchronize properly. I’ve also tried setting v4l2src
to NULL
to refresh the card when the frequency changes, but GStreamer never resumes capture unless the card returns to the original signal.
I don’t know enough about GStreamer to know whether such a mechanism is feasible. What I’m looking to do is:
- Detect the frequency change between PAL/NTSC.
- Display a black image during the necessary operations.
- Restart the card if it crashes (which sometimes happens when the signal changes).
- Display the new image captured after the card has been restarted.
Unfortunately, in some cases I’m forced to restart the card via the usbreset
command, as it fails to recover the current frequency.
This is a real headache, and I would be very grateful for any help or suggestions to solve these problems.
Thanks in advance!