wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.96k stars 1.5k forks source link

Live stream playing keeps freezing after input stream is stopped and then started again #1346

Open Bonnie080 opened 3 years ago

Bonnie080 commented 3 years ago

QtAV, Qt version and platform

QtAV: master (2a470d2) Qt: I'm using 5.15.1 mingw32, but I've also tested with QtAV-Qt5.9-VS2017x64-release-2a470d2.7z downloaded from appveyor OS: Windows 10

Reproduction steps

Actually I was mainly experiencing this problem when playing srt streams from srt-live-transmit or srt-live-server, but simple udp streams can also reproduce it.

  1. Use ffmpeg from command line to push camera video to local udp stream: ffmpeg -f dshow -i video="PC Camera" -c:v mpeg4 -b:v 900k -pkt_size 1316 -flush_packets 0 -f mpegts "udp://127.0.0.1:4201"
  2. Use Player example to play url: udp://127.0.0.1:4201
  3. After several seconds, terminate ffmpeg by Ctrl+C, and then start it again with same parameters.

Expected behavior

When using "ffplay -i udp://127.0.0.1:4201" to play, the playing freezes when ffmpeg is terminated but continues to play when ffmpeg is started again.

Actual behavior

When using Player app, the playing freezes when ffmpeg is terminated and keeps freezing even if ffmpeg is started again.

Log file

Debug: vo: 2a470d2\bin\Player.exe
Debug: QtAV 1.13.0(Sep 10 2020, 03:04:40)
Multimedia framework base on Qt and FFmpeg.
Distributed under the terms of LGPLv2.1 or later.
Shanghai, China Copyright (C) 2012-2019 Wang Bin (aka. Lucas Wang) wbsecg1@gmail.com
Donate: http://qtav.org/donate.html
Source: https://github.com/wang-bin/QtAV
Home page: http://qtav.org
Debug: "Build with Qt-5.9.9"
Debug: "FFmpeg/Libav configuration: --extra-version=QtAV --disable-doc --disable-debug --enable-shared --disable-static --enable-runtime-cpudetect --disable-iconv --enable-hwaccels --enable-libmfx --enable-avresample --disable-postproc --enable-pic --extra-ldflags='-static-libgcc -Wl,-Bstatic'"
Debug: "Build with avutil-55.58.100"
Debug: "Build with avcodec-57.89.100"
Debug: "Build with avformat-57.71.100"
Debug: "Build with avfilter-6.82.100"
Debug: "Build with avdevice-57.6.100"
Debug: "Build with avresample-3.5.0"
Debug: "Build with swresample-2.7.100"
Debug: "Build with swscale-4.6.100"
Debug: engine: "LibASS"
Debug: engine: "FFmpeg"
Debug: engine: "FFmpeg"
Warning: "can not load cuda!"
Debug: Registered audio backends:  ("XAudio2", "OpenAL", "DirectSound", "null")
Debug: "XAudio2_9"
Debug: "Build with XAudio2 from Win8 or later SDK"
Debug: "Try symbol 'XAudio2Create' from WinSDK dll"
Debug: "xaudio2: 0x1f329170090"
Debug: "OpenGL version: 2.0  hasGLSL: 1"
Debug: "GL_VERSION: OpenGL ES 2.0 (ANGLE 2.1.0.8613f4946861)"
Debug: "GL_VENDOR: Google Inc."
Debug: "GL_RENDERER: ANGLE (Intel(R) Iris(R) Plus Graphics 655 Direct3D9Ex vs_3_0 ps_3_0)"
Debug: "GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.00 (ANGLE 2.1.0.8613f4946861)"
Debug: "Is OpenGLES: 1"
Debug: "Is EGL: 1"
Debug: "GLSL version: 100"
Debug: "Has PBO: 0"
Debug: "check gl3 rg: 0x822B"
Debug: "check es3 rg: 0x822B"
Debug: "check GL_EXT_texture_rg"
Debug: "check gl es>=3 rg"
Debug: "fallback to gl_param_compat"
Debug: "Has 16bit texture: 0"
Debug: "Has RG texture: 0"
Debug: QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 5, greenBufferSize 6, blueBufferSize 5, alphaBufferSize 0, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval -1, profile  QSurfaceFormat::OpenGLContextProfile(NoProfile))
Debug: Loading  QVariant(QString, "udp://127.0.0.1:4201")  ...
Debug: "all closed and reseted"
Debug: "avformat_open_input: d->format_ctx:'0x1f321fff140', url:'udp://127.0.0.1:4201'..."
Debug: "avformat_open_input: url:'udp://127.0.0.1:4201' ret:0"
Warning: [FFmpeg:mpeg4] time_increment_bits 0 is invalid in relation to the current bitstream, this is likely caused by a missing VOL header
Warning: [FFmpeg:mpeg4] time_increment_bits set to 5 bits, based on bitstream analysis
Warning: [FFmpeg:mpeg4] looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag
Warning: [FFmpeg:mpeg4] time_increment_bits 4 is invalid in relation to the current bitstream, this is likely caused by a missing VOL header
Warning: [FFmpeg:mpeg4] time_increment_bits set to 5 bits, based on bitstream analysis
Debug: "avfmtctx.flags: 2097665, iformat.flags"
Warning: "invalid index 0 (valid is 0~0) for stream type 2."
Debug: status changed  "已加载"
Debug: "notify_interval: 500"
Debug: "stream: 0, duration=-9223372036854775808 (-102481911520608624 ms), time_base=0.000011"
Debug: "codec: mpeg4(MPEG-4 part 2)"
Warning: "invalid index 0 (valid is 0~0) for stream type 0."
Debug: "**********trying video decoder: FFmpeg..."
Debug: "QtAV::VideoDecoderFFmpeg thread type: Frame, count: 9"
Debug: "**************Video decoder found:0x1f328fca3a0"
Debug: "setCapture 0x1f328cdde80"
Debug: "stream: 0, duration=-9223372036854775808 (-102481911520608624 ms), time_base=0.000011"
Debug: "codec: mpeg4(MPEG-4 part 2)"
Debug: "auto select clock: audio > external"
Debug: "No audio found or audio not supported. Using ExternalClock."
Debug: "Clock initial value: 34.633000"
Debug: "Starting video thread..."
Debug: "get av queue a/v thread = 0x0 0x1f328e34f80"
Warning: "no frame could be decompressed: Error number 1953 occurred 0/1953"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Debug: ScreenSaver::retrieveState
Debug: Succeed to enable screen saver (0)
Debug: status changed  "缓冲中..."
Debug: "AVClock started!!!!!!!!"
Warning: [FFmpeg:mpeg4] warning: first frame is no keyframe
Warning: "no frame could be decompressed: Error number 1940 occurred 0/1940"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Debug: status changed  "已缓冲"
Warning: "no frame could be decompressed: Error number 919 occurred 0/919"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Warning: "no frame could be decompressed: Error number 1773 occurred 0/1773"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Warning: "no frame could be decompressed: Error number 1666 occurred 0/1666"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Warning: "no frame could be decompressed: Error number 1756 occurred 0/1756"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Warning: "no frame could be decompressed: Error number 1773 occurred 0/1773"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Warning: "no frame could be decompressed: Error number 1794 occurred 0/1794"
Warning: "invalid video frame from decoder. undecoded data size: 0"
Debug: "buffersrc_args=video_size=640x480:pix_fmt=0:time_base=1/1000000:pixel_aspect=1/1"
Warning: [FFmpeg:?] No such filter: ''
Warning: [FFmpeg:?] Error avfilter_graph_parse_ptr(filter_graph, options.toUtf8().constData(), &inputs, &outputs, 0) @166 C:\projects\qtav\src\filter\LibAVFilter.cpp: (0xffffffea) Invalid argument
Warning: "setup video filter graph error"
Debug: "QtAV::VideoRenderer::setInSize => calculating aspect ratio from converted input data(1.333333)"
Debug: QtAV::VideoFormat(pixelFormat: 15 "yuv420p" alpha: false, channels: 3, planes: 3, bpc: 8, bpp: 12/12 -8-8-8)
Debug: "pixel format changed:  => yuv420p 15"
Debug: material changed:  "gl material 16to8bit: 0, planar: 0, has alpha: 0, 2d texture: 0, 2nd plane rg: 0, xyz: 0"  =>  "gl material 16to8bit: 0, planar: 1, has alpha: 0, 2d texture: 1, 2nd plane rg: 0, xyz: 0"
Debug: "plane linesize 0: padded = 640, effective = 640. theoretical plane size: 640x480"
Debug: "plane linesize 1: padded = 320, effective = 320. theoretical plane size: 320x240"
Debug: "plane linesize 2: padded = 320, effective = 320. theoretical plane size: 320x240"
Debug: "effective_tex_width_ratio=1.000000"
Debug: texture internal format:  QVector(6409, 6409, 6406)
Debug: texture data format:  QVector(6409, 6409, 6406)
Debug: texture data type:  QVector(5121, 5121, 5121)
Debug: "///////////bpp 2, bpc: 8"
Debug: "texture width: 640 - 640 = pad: 0. bpp(gl): 1"
Debug: "texture width: 320 - 320 = pad: 0. bpp(gl): 1"
Debug: "(repeat 1)texture width: 320 - 320 = pad: 0. bpp(gl): 1\ncreating texture for plane 0"
Debug: "texture for plane 0 is created (id=1)"
Debug: "creating texture for plane 1"
Debug: "texture for plane 1 is created (id=2)"
Debug: "creating texture for plane 2"
Debug: "texture for plane 2 is created (id=3)"
Debug: "[ShaderManager] cache a new shader material type(10): gl material 16to8bit: 0, planar: 1, has alpha: 0, 2d texture: 1, 2nd plane rg: 0, xyz: 0"
Debug: "bind attribute: a_Position => 0"
Debug: "bind attribute: a_TexCoords0 => 1"
Debug: "uniform locations:"
Debug: "u_Texture0: 3"
Debug: "u_Texture1: 4"
Debug: "u_Texture2: 5"
Debug: "u_Matrix: 0"
Debug: "u_colorMatrix: 2"
Debug: "u_opacity: 1"
Debug: input yuv limited range
Debug: target rect:  QRectF(-1,1 2x-2)
Debug: creating VBO...
Debug: creating VAO...
Debug: vao updated
Debug: geometry attributes changed, rebind vao...
Debug: geometry updated
/**********After ffmpeg is stopped and started again**********/
Debug: status changed  "缓冲中..."
Warning: [FFmpeg:mpegts] DTS 126000 < 4719000 out of order
Debug: "delay -5.193365s @57.594s pts:52.400"
Debug: status changed  "已缓冲"
Debug: "delay -5.161106s @57.595s pts:52.433"
Debug: "video is too slow. skip decoding until next key frame."
Debug: status changed  "缓冲中..."
Warning: [FFmpeg:mpeg4] Error at MB: 817
Debug: [FFmpeg:mpeg4] concealing 483 DC, 483 AC, 483 MV errors in P frame
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: status changed  "已缓冲"
Debug: status changed  "缓冲中..."
Debug: "(repeat 132)video is too slow. skip decoding until next key frame.\ntimer: 1, current thread: 0x1f320589550, player thread: 0x1f320589550"
Debug: "stopping demuxer thread..."
Debug: stopping thread  QtAV::VideoThread(0x1f328e34f80)
Debug: "Invalid packet! flush video codec context!!!!!!!!!! video packet queue size: 0"
Debug: "Video thread stops running..."
Debug: "QtAV::VideoRenderer::setInSize => calculating aspect ratio from converted input data(0.000000)"
Debug: "all avthread finished. try to exit demux thread<<<<<<"
Debug: "Demux thread stops running...."
Debug: "demuxer thread emit finished. repeat: -1/0"
Debug: "avplayer emit stopped()"
Warning: "Can not copy codec properties when it's open"
Debug: "closing d->format_ctx"
Debug: "all audio/video threads stopped... state: 0"
Debug: sync config to  "C:/Users/Bonnie/AppData/Roaming/Player/Player.ini"
Debug: sync end
Debug: "Not playing~"
Debug: "(repeat 1)Not playing~\nsource_voice: 0x0, master: 0x0"
Debug: 
Debug: "(repeat 1)source_voice: 0x0, master: 0x0\n~AVThreadPrivate wake up paused thread"
Debug: "VideoFilterContext 0x1f3241872e0 delete paint device in 0x1f328cddee0"
Debug: "destroy GeometryRenderer 0x1f328e4ba20"
Warning: ScreenSaver::restoreState: no data, doing nothing
rysson commented 3 years ago

I have the same issue.