Please refer to the softeware encoding part. Here is the simplified cmd.
gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert copy-hw=2 ! 'video/x-raw, format=I420' ! x264enc bitrate=1000000 ! filesink location=test.264
please refer to ths faq for the “Failed in mem copy” error.