hbiyik / FFmpeg

PLEASE USE https://github.com/nyanmisaka/ffmpeg-rockchip REPO INSTEAD.
https://github.com/nyanmisaka/ffmpeg-rockchip
Other
90 stars 7 forks source link

High cpu load when ffmpeg decodes a rtsp stream and output rawvideo to pipe #43

Closed ywangwxd closed 6 months ago

ywangwxd commented 6 months ago

Hello,

Now I can transcode a video stream and save to a mkv file. The debug output shows it is using mpp decoder and encoder, and the cpu load is very low, everyting sounds good.

Howerver, when I change to use pipe, strange thing happened. The cpu load is 500%, and the output often remind me delays happened. Here is the command I use to test

ffmpeg -loglevel info -i rtsp_url -pix_fmt bgr24 -f rawvideo pipe: > /dev/null

Here, I did not specify hevc codec, ffmpeg chose to use mpp hevc decoder, as can be seen in the debug output. Howerver, if I used -codec hevc option, it chose to use cpu decoder, no mpp decoder shown in the debug output. When the cpu decoder is used, the cpu load is only 300%, and no delay complains. What is wrong? Should not mpp decoder be much faster than cpu decoder and the cpu load be very low?

ywangwxd commented 6 months ago

I know the reason, it is because the pix_fmt. Changing bgr24 to nv12 can lower down the cpu load to 60%. Seems that the cpu very busy to convert yuv420 to bgr24, but not nv12.