NVENC raw h264 to mp4 playback speed

I’m writing the output of NVENC to a raw file on disc. So that regular apps can play it I’m embedding it in a mp4 container with ffmpeg:

ffmpeg -i “output.h264” -c:v copy -f mp4 “output.mp4” -y

Now when I play the mp4 file with the built in video player in Windows, it plays back at the wrong speed (too fast).

I’ve tried setting NV_ENC_PIC_PARAMS::inputTimeStamp but nothing I’ve tried seems to affect playback speed. I’m not sure what kind of value is expected. I’ve tried the QuadPart of the struct returned by QueryPerformanceTimer, and also the current frame counter.

What am I missing?

During the ffmpeg conversion, it reports:

[mp4 @ 000002722202e7c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

Maybe this is a clue?


We are not able to reproduce this issue internally. Can you provide exact reproduction?
Is same issue observed with x264 generated file as well? Did you try with different players to see if this issue is specific to the decoder/player side?


It seems that playback speed is determined by N_ENC_INITIALIZE_PARAMS::frameRateNum and ::frameRateDen, which I had set incorrectly for this application.

Setting this correctly has solved my problem, but I am curious what NV_ENC_PIC_PARAMS::inputTimeStamp is supposed to do.

The error I quoted above from ffmpeg about unset timestamps appears to apply to the last frame, which is probably incorrectly written to the output file given that I do not gracefully terminate the application.