ithewei / hplayer

A multi-screen player using Qt + FFmpeg.

Home Page:https://hewei.blog.csdn.net/article/category/9275796

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hplayer plays local videos but doesn't play rtsp stream

shujaatak opened this issue · comments

I noticed that the latest hplayer plays local videos but fails and crashes when I try to play rtsp stream.

In QtCreator Application Output shows following message:

C:\hplayer\bin\msvc14_x86\hplayer.exe ...
[dshow @ 000001eb628d09c0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000001eb628d09c0]  "HP Truevision HD"
[dshow @ 000001eb628d09c0]     Alternative name "@device_pnp_\\?\usb#vid_0bda&pid_5776&mi_00#6&33f079c4&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000001eb628d09c0] DirectShow audio devices
[dshow @ 000001eb628d09c0]  "Microphone (Realtek High Definition Audio)"
[dshow @ 000001eb628d09c0]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{E96AB72D-4A92-494C-AF9C-604A911E046C}"
[udp @ 000001eb628d5a80] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001eb628eac40] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001eb628fb500] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001eb6290b800] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[rtsp @ 000001eb628d3240] UDP timeout, retrying with TCP
[rtsp @ 000001eb628d3240] Could not find codec parameters for stream 1 (Video: h264, none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[h264_cuvid @ 000001eb6294e4c0] Cannot load cuvidGetDecodeStatus
[h264_cuvid @ 000001eb6294e4c0] Failed loading nvcuvid.
Assertion desc failed at src/libswscale/swscale_internal.h:670
14:15:48: C:\hplayer\bin\msvc14_x86\hplayer.exe exited with code 3

The hplayer log shows this:

[2020-04-03 14:15:26.140][INFO ] C:\hplayer\bin\msvc14_x86\hplayer.exe version: 1.20.4.3 [..\hplayer\src\main.cpp:119:main]
[2020-04-03 14:15:32.114][INFO ] ifile:rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [..\hplayer\src\video\hffplayer.cpp:112:HFFPlayer::open]
[2020-04-03 14:15:43.743][INFO ] interrupt quit=0 media.src=rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [..\hplayer\src\video\hffplayer.cpp:39:interrupt_callback]
[2020-04-03 14:15:43.743][INFO ] interrupt quit=0 media.src=rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [..\hplayer\src\video\hffplayer.cpp:39:interrupt_callback]
[2020-04-03 14:15:43.744][INFO ] stream_num=2 [..\hplayer\src\video\hffplayer.cpp:150:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] video_stream_index=1 [..\hplayer\src\video\hffplayer.cpp:155:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] audio_stream_index=0 [..\hplayer\src\video\hffplayer.cpp:156:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] subtitle_stream_index=-1381258232 [..\hplayer\src\video\hffplayer.cpp:157:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] video_stream time_base=1/90000 [..\hplayer\src\video\hffplayer.cpp:168:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] codec_id=27:h264 [..\hplayer\src\video\hffplayer.cpp:171:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] decoder=h264_cuvid [..\hplayer\src\video\hffplayer.cpp:190:HFFPlayer::open]
[2020-04-03 14:15:43.744][INFO ] codec_name: h264_cuvid=>Nvidia CUVID H264 decoder [..\hplayer\src\video\hffplayer.cpp:204:HFFPlayer::open]
[2020-04-03 14:15:43.747][INFO ] Can not open hardwrae codec error: -1, try software codec. [..\hplayer\src\video\hffplayer.cpp:223:HFFPlayer::open]
[2020-04-03 14:15:43.747][INFO ] codec_name: h264=>H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [..\hplayer\src\video\hffplayer.cpp:204:HFFPlayer::open]

As far as I think hplayer assumes that every user must have h264_cuvid (Nvidia CUVID H264 decoder ) but this can't be true for some users. Also there should be some algorithm to stop hplayer from crashing and play video successfully if it get hardware codec error..

On my laptop I have 2 GPUs, one Intel(R) HD Graphics 5500 and one NVIDIA GeForce 820M.

I noticed that local videos play smoothly and they use Intel(R) HD Graphics 5500 but when I try to play rtsp stream, I think, hplayer trys to play rtsp video through NVIDIA GeForce 820M which I think don't have Nvidia CUVID H264 decoder so hplayer fails and crash!

Can the rtsp stream be played through Intel(R) HD Graphics 5500 just like the local videos?

According to the analysis Application Output,Could not find codec parameters,this was probably caused by UDP packet loss. You can set rtsp_transport = tcp in hplayer.conf.
I have fixed the bug that caused the application to crash due to miss codec parameters.

With rtsp_transport = tcp , now the rtsp stream works and also the application doesn't crash!
Thank you so much for improving hplayer!
BUT I noticed that while I stream rtsp video if I disconnect Wifi for about 10-20 seconds then the video automatically closes and the default media open button appears! I was expecting hplayer that it would try to reconnect the stream!
I also noticed that if I use mjpeg stream then hplayer automatically reconnect the video after reconnecting Wifi which is great!
I am using the following config:

# [root]

logfile = hplayer.log
# loglevel = [VERBOSE,DEBUG,INFO,WARN,ERROR,FATAL,SILENT]
loglevel = INFO
log_remain_days = 3
log_filesize = 16M

[ui]
skin = dark
# 0xAARRGGBB
palette = 0xFF132D48
# language = [en, zh_CN, ...]
language = 
fontsize = 12

main_window_width = 800
main_window_height = 600
mv_fullscreen = false
fullscreen = false
maximized = true
# rect(x,y,w,h)
main_window_rect = rect(0,23,1366,705)

menubar_visible = true
toolbar_visible = true
statusbar_visible = true
lside_visible = false
rside_visible = false

mv_row = 3
mv_col = 3

draw_fps = true

[video]
frame_cache = 5
fps = 25

# aspect_ratio = [0:0, w:h, x:y]
# aspect_ratio = 0:0 # SPREAD
aspect_ratio = w:h	# ORIGINAL_RATIO
# aspect_ratio = 4:3 # CUSTOM_RATIO

# SOFTWARE_DECODE         = 1,
# HARDWARE_DECODE_QSV     = 2,
# HARDWARE_DECODE_CUVID   = 3,
decode_mode = 3

# pix_fmt = [YUV420P, BGR24]
dst_pix_fmt = YUV420P

# rtsp_transport = [tcp, udp]
rtsp_transport = tcp

retry_interval = 10000	# ms
retry_maxcnt = -1	# -1 means INFINITE

[media]
# 0:file 1:network 2:capture
last_tab = 1
last_file_source = 
last_network_source = rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream

hplayer-2020-04-10.log:
I am going to show you the log in two pieces but, the log which is generated before disconnecting the Wifi (video is displayed smoothly):

[2020-04-10 11:52:39.783][INFO ] C:\Qt_Sandbox\HPlayer\LATEST\hplayer\bin\msvc14_x86\hplayer.exe version: 1.20.4.9 [src\main.cpp:119:main]
[2020-04-10 11:52:53.239][INFO ] ifile:rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [src\video\hffplayer.cpp:112:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] stream_num=2 [src\video\hffplayer.cpp:150:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] video_stream_index=1 [src\video\hffplayer.cpp:155:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] audio_stream_index=0 [src\video\hffplayer.cpp:156:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] subtitle_stream_index=-1381258232 [src\video\hffplayer.cpp:157:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] video_stream time_base=1/90000 [src\video\hffplayer.cpp:168:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] codec_id=27:h264 [src\video\hffplayer.cpp:171:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] decoder=h264_cuvid [src\video\hffplayer.cpp:190:HFFPlayer::open]
[2020-04-10 11:52:55.832][INFO ] codec_name: h264_cuvid=>Nvidia CUVID H264 decoder [src\video\hffplayer.cpp:204:HFFPlayer::open]
[2020-04-10 11:52:56.155][INFO ] sw=1280 sh=720 dw=1280 dh=720 [src\video\hffplayer.cpp:238:HFFPlayer::open]
[2020-04-10 11:52:56.155][INFO ] src_pix_fmt=23:nv12 dst_pix_fmt=0:yuv420p [src\video\hffplayer.cpp:240:HFFPlayer::open]
[2020-04-10 11:52:56.157][INFO ] fps=59 duration=0ms start_time=128ms [src\video\hffplayer.cpp:299:HFFPlayer::open]
[2020-04-10 11:52:56.158][INFO ] postEvent 10001 [src\ui\HVideoWidget.cpp:32:hplayer_event_callback]

Now the log which is generated after disconnecting the Wifi(Video stops and the Open Button appears of the screen):

[2020-04-10 11:53:38.360][INFO ] No frame: -541478725 [src\video\hffplayer.cpp:383:HFFPlayer::doTask]
[2020-04-10 11:53:38.360][INFO ] postEvent 10003 [src\ui\HVideoWidget.cpp:32:hplayer_event_callback]
[2020-04-10 11:53:38.461][INFO ] interrupt quit=1 media.src=rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [src\video\hffplayer.cpp:39:interrupt_callback]
[2020-04-10 11:53:38.461][INFO ] No frame: -541478725 [src\video\hffplayer.cpp:383:HFFPlayer::doTask]
[2020-04-10 11:53:38.525][INFO ] interrupt quit=1 media.src=rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen03.stream [src\video\hffplayer.cpp:39:interrupt_callback]

The changes I have made in the hplayer.conf:

aspect_ratio = w:h	# ORIGINAL_RATIO
rtsp_transport = tcp
retry_maxcnt = -1	# -1 means INFINITE

I noticed an another major issue in hplayer but I will post that when this issue is resolved. I don't want to create a storm of issues here :)

Now you try!

Great! now it works!
Thank you so much for making hplayer even smarter and mature!

Now I will post the other issue in a separate post.