Error recording and saving mp4 video segments (pipeline manipulation) using nvidia tx2 onboard camer...

‘’’

!!!

[def format_location_callback (splitmux, fragment_id): ]
[ date = str(round(time.time() * 1000)) # take the timestamp]
[ name = str(date) ]
[ return int(name) ]

[pipeline = Gst.parse_launch (“nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw(memory:NVMM), format=(string)I420 ! omxh264enc insert-sps-pps=true iframeinterval=30 ! video/x-h264, stream-format=(string)byte-stream ! h264parse ! splitmuxsink name=splitmux location=%d.mp4 max-size-time=5000000000”)]

#pipeline = Gst.parse_launch (“xxxxxxxx xxxxxxx xxxxx splitmuxsink name=splitmux location=%d.mp4 max-size-time=5000000000”)

[src = pipeline.get_by_name(‘splitmux’)]

Hi Marius,
Thanks for the sharing,but you may make it a complete comment so that others can understand it better. It seems spread into multiple comments.

Hello DaneLLL,
I have not finished writing the whole solution because I gave up fighting with your topic checking algorithms which are not letting me post a single line of code.
A solution was to post multiple topics.

…to continue with solution:

  • after getting the splitmux element by name from pipeline with the command above we need to connect
    a callback function which return the name of video file to the bus as a “signal”.
    connect by using the “format-location” name of the element.

{src.connect(“format-location”, format_location_callback)}

  • the callback function looks like:

def format_location_callback (splitmux, fragment_id):

local_frame_t = round(time.time() * 1000)
timestamp = str(local_frame_t)
name = str(timestamp) + ".mp4"
return str(name)

those 2 function paramenters are necessary.