Open shujaatak opened 4 years ago
The above screenshot is from the following video https://www.youtube.com/watch?v=qw--VYLpxG4
I have a downloaded file of the above video on which I did comparison of the video quality of both ffplayer and hplayer.
The video in fullscreen mode looks more distorted. The colors do not match with the original video too!
The scaling of picture caused distortion, I changed GL_NEAEST => GL_LINEAR,this can help to reduce distortion, although it consumes more computing resources. See HGLWidget.cpp:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Great! Now there is no distortion! but the color difference is still there!
Video quality of ffplayer:
Video quality of hplayer:
The colors of hplayer video are dim/lighter while the colors of the ffplayer are bright/darker. I noticed that VLC and other media players also play same like ffplayer i.e. brighter and darker, this means there is still some issue which degrades the hplayer video quality.
The official ffplay has some sdl_texture_format_map which could be something needed for accurate colors?
static const struct TextureFormatEntry {
enum AVPixelFormat format;
int texture_fmt;
} sdl_texture_format_map[] = {
{ AV_PIX_FMT_RGB8, SDL_PIXELFORMAT_RGB332 },
{ AV_PIX_FMT_RGB444, SDL_PIXELFORMAT_RGB444 },
{ AV_PIX_FMT_RGB555, SDL_PIXELFORMAT_RGB555 },
{ AV_PIX_FMT_BGR555, SDL_PIXELFORMAT_BGR555 },
{ AV_PIX_FMT_RGB565, SDL_PIXELFORMAT_RGB565 },
{ AV_PIX_FMT_BGR565, SDL_PIXELFORMAT_BGR565 },
{ AV_PIX_FMT_RGB24, SDL_PIXELFORMAT_RGB24 },
{ AV_PIX_FMT_BGR24, SDL_PIXELFORMAT_BGR24 },
{ AV_PIX_FMT_0RGB32, SDL_PIXELFORMAT_RGB888 },
{ AV_PIX_FMT_0BGR32, SDL_PIXELFORMAT_BGR888 },
{ AV_PIX_FMT_NE(RGB0, 0BGR), SDL_PIXELFORMAT_RGBX8888 },
{ AV_PIX_FMT_NE(BGR0, 0RGB), SDL_PIXELFORMAT_BGRX8888 },
{ AV_PIX_FMT_RGB32, SDL_PIXELFORMAT_ARGB8888 },
{ AV_PIX_FMT_RGB32_1, SDL_PIXELFORMAT_RGBA8888 },
{ AV_PIX_FMT_BGR32, SDL_PIXELFORMAT_ABGR8888 },
{ AV_PIX_FMT_BGR32_1, SDL_PIXELFORMAT_BGRA8888 },
{ AV_PIX_FMT_YUV420P, SDL_PIXELFORMAT_IYUV },
{ AV_PIX_FMT_YUYV422, SDL_PIXELFORMAT_YUY2 },
{ AV_PIX_FMT_UYVY422, SDL_PIXELFORMAT_UYVY },
{ AV_PIX_FMT_NONE, SDL_PIXELFORMAT_UNKNOWN },
};
hplayer is about to be the best player, it's only one step away from being the best player! It only needs to have some algorithm for displaying accurate colors and that's it!
hplayer is neat, simple, fast and has appropriate features that no other player has!
By the way, QtAV project also displays accurate colors and they manage it like this.
May be it's due to some issues in OpenGL code?
OK, I found that setting dst_pix_fmt to BGR24 resolves the issue but hplayer doubles the CPU and GPU usage while ffplayer plays the same video with same quality at lower CPU and GPU usage.
ffplay uses ffmpeg and sdl,sdl uses d3d on Windows,OpenGL on Linux. OpenGL cross-platform, but d3d is more efficient on Windows. If set dst_pix_fmt = BGR24, sws_scale convert yuv -> rgb via CPU.
Set draw_fps = false
when you test.
Maybe we can try to integrate SDL into hplayer, renderer is too complex.
SDL looks good, it's easy to use and also efficient.
By the way, for windows and linux, VLC uses Qt https://code.videolan.org/videolan/vlc/-/tree/master/modules/gui/qt and I have noticed that VLC plays videos with lowest CPU and GPU usage. I know VLC uses it's own libraries alongwith ffmpeg but for rendering it uses Qt and OpenGL(by default).
By the way, ffplay(ffmpeg) is the best! VLC is only good for playing local videos. I compared both ffplay and VLC for streaming videos and I noticed that ffplay uses comparatively less CPU and GPU and also ffplay plays the videos smoothly with much less delay! VLC can play local videos efficiently because VLC loads a portion of the video to the RAM and then plays video from there rather than fetching each frame from the drive.
If you wonder how to integrate SDL2 with Qt then see this: https://github.com/Qt-Widgets/SDL2_Widget_Qt5
ffplay is SDL based and QtAV is Qt OpenGL(default) based. I noticed that both ffplay and QtAV has almost same CPU and GPU usage. This means that there is no issue with OpenGL whereas hplayer is missing something due to which it's efficiency is not as good as ffplay. However I have also noticed that QtAV is laggy for streaming videos.
Try hplayer.conf renderer = sdl
renderer = sdl
works perfect! but somehow the aspect ratio configs are not working now. I tried both aspect_ratio = w:h # ORIGINAL_RATIO
and aspect_ratio = wxh # ORIGINAL_SIZE
but the aspect ratio does not change.
I am going to create separate aspect ratio and freeze related issues to avoid cluttering this issue.
Playing a same video using both ffplayer and hplayer, I noticed that the hplayer video quality is different than the official ffplayer.c video quality.
Video quality of ffplayer:
Video quality of hplayer:
I noticed that the network / streaming and local video quality played by hplayer is poor. hplayer is an amazing project, it deserves high-quality video playback capabilities.