Nvstreammux

I am having trouble connecting the nvv4l2decoder to nvstreammux using DeepStream. Currently I am just trying to read a video from a file, convert it to a format nvinfer could use, and then save it in a new video format. My gst pipeline looks something like:
source.mp4 -> qtdemux -> h264parse -> nvv4l2decoder -> nvstreammux -> nvstreamdemux -> nvv4l2h265enc -> filesink.

I tried using both a bash script and compiling it to c (I tried bash because I was unsure if I was creating pads correctly with in C). Both give errors.

Bash Error: “WARNING: erroneous pipeline: could not link nvv4l2decoder0 to nvstreammux0”

C Error: " Running…
Pipeline ready
Dynamic pad created, linking demuxer/decoder
Dynamic pad created, linking demuxer/decoder
ERROR from element qtdemux: Internal data stream error.Error: Internal data stream error."

The Previous GST pipeline, worked:
source.mp4 -> qtdemux -> h264parse -> nvv4l2decoder -> nvv4l2h265enc -> filesink.

• AGX Xavier 8GB Volta
• DeepStream 5.0
• Jetpack 4.4
• TensorRT 7.1.3-1+cuda10.2

I tried with below pipeline and it can work well:
gst-launch-1.0 filesrc location= ./sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m width=1280 height=720 batch-size=1 ! nvstreamdemux name=s s.src_0 ! nvv4l2h265enc ! filesink location= file.h265

Thanks so much! I really appreciate your help.