OpenCV Mat to NvBufSurface (to use in NvBufSurfTransform)

Works great , thanks !

Unrelated q (re-asking from the original post) - maybe you can refer me to some sample code / documentation:

How can I decode and convert a NvBufSurface efficiently (done in GPU/Hardware) to:
– JPEG img frame (which I will then move to host and save)
and/or
– MPEG stream packet ( and then host and to be saved into a mp4/avi file etc) ?

Thanks again for the great help !