Keylost / jetson-ffmpeg

ffmpeg support on nvidia jetson
Other
78 stars 26 forks source link

Setting framerate does not work with FFMPEG C++ API #29

Closed marearth closed 4 days ago

marearth commented 1 week ago

When I send processed frame to rtsp server by ffmpeg h264_nvmpi, encoder framerate parameter is set as follows: avcc->time_base = (AVRational){1, sc.framerate}; // avcc is AVCodecContext object avcc->framerate = (AVRational){sc.framerate, 1}; RTSP stream works as expected but not framerate. The framerate is set as default value 30 by nvmpi. Nvmpi warns the setting framerate is not valid(0~300). I check avcc->framerate.num and avcc->framerate.den is set as expected. Maybe they are not handled properly by jetson-ffmpeg library.

Environment: FFMPEG 6.0 ubuntu 20.04 jetson orin nx jetpack 5.1.3

Keylost commented 1 week ago

Hi! I doubt that the problem is on the nvmpi side. I tried to re-encode the video with changing FPS via the command line utility. I used the command: ffmpeg -i 1.mp4 -filter:v fps=25 -c:v h264_nvmpi 2_test.mkv

Before: Duration: 00:12:45.14, start: 0.000000, bitrate: 1333 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31 637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1198 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default) After: Duration: 00:12:45.14, start: -0.006000, bitrate: 1698 kb/s Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)

I didn't get any problems with output video fps or warnings about incorrect fps. Try to transcode the video using the ffmpeg utility. If you don't encounter any problems then the problem is somewhere in your code.

marearth commented 4 days ago

The VLC framerate display maybe misguided me. I get real FPS by ffprobe.