Deepstream SDK 4.0 :call API to save deepstream-test1 error

command line for DeepStream 4.0 is right:
gst-launch-1.0 filesrc location= sample_720p.h264 ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m width=1920 height=1080 batch-size=1 ! nvinfer config-file-path=./config/dstest2_pgie_config.txt ! nvvideoconvert ! nvdsosd ! queue ! nvvideoconvert ! “video/x-raw(memory:NVMM), format=I420” ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=222.mp4

but when call API, report the following error:
ERROR from element h264parser: Internal data stream error.
Error details: gstbaseparse.c(3611): gst_base_parse_loop (): /GstPipeline:demo-pipeline/GstH264Parse:h264parser:
streaming stopped, reason not-linked (-1)

Duplicated thread as below: