How to Synchronize File Saving Between Two Separate GStreamer Pipelines (Audio and Video)

I have two separate GStreamer pipelines: one for audio and one for video. Here’s my current pipeline setup:

gst-launch-1.0 -e videotestsrc is-live=1 ! video/x-raw,width=1920,height=1080,framerate=60/1 ! nvvideoconvert ! queue ! nvv4l2h265enc iframeinterval=60 idrinterval=60 ! h265parse ! splitmuxsink location=output/video_%02d.h265 max-size-time=1000000000 audiotestsrc is-live=1 ! queue ! avenc_aac ! aacparse ! sm.audio_0 splitmuxsink name=sm location=output/audio_%02d.aac max-size-time=1000000000

The problem is that the audio files are being saved faster than the video files. I need to synchronize the file saving process so that the audio file is saved only after the corresponding video file is saved.

Ideally, I want the video file to be saved before the audio file in each segment (h264 files are saved BEFORE aac).

How can I implement this synchronization or add a mechanism to enforce the save order between audio and video files in GStreamer?