Jetson Gstreamer Encoding Deadlock

Hi, I’m using Jetson AGX Xavier and having an issue when terminating Gstreamer app (via OpenCV).

when the encoding pipeline is finished, it just waits forever increasing the output file size unlimitly.

here are the detail,

  • Gstreamer by OpenCV frame work
    it is writing the opencv mat images and muxing the silence audo stream. it is to playback well with some browser which needs an audio stream.
//
// pipeline and open
pipeline = "appsrc ! video/x-raw, format=(string)BGR "
                       "! queue ! videoconvert ! video/x-raw, format(string)I420 "
                       "! nvvidconv ! video/x-raw(memory:NVMM), width=4096, height=2060 "
                       "! queue ! omxh265enc qp-range=15,30:5,20:-1,-1 temporal-tradeoff=0 "
                       "control-rate=0 quality-level=3 profile=8 "
                       "! video/x-h265 ! h265parse ! mux. audiotestsrc wave=silence freq=200 ! "
                       "voaacenc ! aacparse ! queue ! mux. mpegtsmux name=mux ! hlssink "
                       "max-files=0 playlist-length=0 target-duration=2 playlist-location=playlist%d.ts location=playlist.m3u8 ";

//opencv videowriter
video_writer.open(gstr, cv::CAP_GSTREAMER, 0, m_fps, m_size, true);

//
// in the loop
video_writer.write(mat_image);


// when terminate
// exit the loop above
// and call the video_writer.release() if necessary. (but it is called in the destructor)

// but the process hangs here. and keeps accumulating output file size increased.
video_writer.release() ;


I guess even though there is no image to input, stil the audiotestsrc is feeding the pipeline infinitely.

Could you give me some advice here such as…

  1. is it correct way to add dummy silence audio stream when encode video?

  2. does the pipeline look good? or is there any unecesarry part?

Thank you.

Hi,
If you don’t need audio track, you can encoder video-only file. Or set num-buffers to audiotestsrc so that it doesn’t generate data infinitely.

1 Like

Thank you,
the problem is that it is a live recording(or streaming) system and the target recording duration may changes during the recording. so the num-buffer is not necessarily defined in the initialization stage.

I need to add audio stream as well, since the apple browser’s compatibility.
(without audio stream it keeps pausing in hls streaming)

Hi,
Please go to https://forum.opencv.org/

We don’t actually have experience to have audio track in cv2.VideoWriter(). Would suggest go to OpenCV forum to get further help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.