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.98k stars 1.51k forks source link

QML MediaPlayer position out of bounds #1060

Open MiWitt opened 6 years ago

MiWitt commented 6 years ago

Thank you very much for your great effort on QtAV. Great project ...

I noticed an issue when using QtAV MediaPlayer in QML.

QtAV, Qt version and platform

commit 2521892844a9a931b1f077c998b80b488323220e on Desktop Windows7, Windows10, MacOS Sierra and Ubuntu 14.04 With any kind of video

Reproduction steps

Using QtAV QML.

When I only start playing close to the end of the video it does not not seem to be a problem. But when pausing the MediaPlayer immediately it almost always happens. This issue is somehow related with reaching the end of the video. It does not happen somewhere else.

Kind regards MiWitt

Initially I thought the error was caused by (MediaPlayer.position > MediaPlayer.duration), but this is not the driving fact. So I edited this posting but the title remained unchanged ...

MiWitt commented 6 years ago

Debugging starts QML debugging is enabled. Only use this in a safe environment. QML Debugger: Waiting for connection on port 45880... AudioResampler::Register(..., FFmpeg) Singleton 0x7fffc82803a0 created... AudioResampler::Register(..., Libav) AudioOutputBackend::Register(..., OpenAL) Singleton 0x7fffc828da50 created... AudioOutputBackend::Register(..., Pulse) VideoDecoder::Register(..., CUDA) Singleton 0x7fffc828b2d0 created... VideoDecoder::Register(..., VAAPI) VideoRenderer::Register(..., OpenGLWindow) Singleton 0x7fffc82885d0 created... SubtitleProcessor::Register(..., LibASS) Singleton 0x7fffc827b8d0 created... SubtitleProcessor::Register(..., FFmpeg) AudioDecoder::Register(..., FFmpeg) Singleton 0x7fffc806bb80 created... AudioEncoder::Register(..., FFmpeg) Singleton 0x7fffc8292980 created... ImageConverter::Register(..., FFmpeg) Singleton 0x7fffc8287cd0 created... MediaIO::Register(..., QIODevice) Singleton 0x7fffc80ecb40 created... MediaIO::Register(..., QFile) AudioOutputBackend::Register(..., null) VideoDecoder::Register(..., FFmpeg) VideoDecoder::Register(..., QSV) VideoDecoder::Register(..., CrystalHD) VideoEncoder::Register(..., FFmpeg) Singleton 0x7fffc80adb40 created... VideoRenderer::Register(..., QQuickItem) VideoRenderer::Register(..., QuickFBO) QtAV 1.12.0(Mar 29 2018, 14:47:42) Multimedia framework base on Qt and FFmpeg. Distributed under the terms of LGPLv2.1 or later. Shanghai University->S3 Graphics->Deepin->PPTV, Shanghai, China Copyright (C) 2012-2017 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 "Build with Qt-5.10.1" "FFmpeg/Libav configuration: --extra-version=QtAV --disable-doc --disable-debug --enable-shared --enable-runtime-cpudetect --enable-libmfx --enable-avresample --disable-postproc --cc=gcc-7 --enable-pic --extra-cflags='-Wa,--noexecstack -fdata-sections -ffunction-sections -fstack-protector-strong' --extra-ldflags='-Wl,--gc-sections' --extra-libs=-lrt --enable-small --disable-avdevice --disable-avresample --disable-filters --enable-filter='fade,format,resample,aeval,all,atempo,color,convolution,draw,eq,framerate,hw,null,volume' --disable-muxers --disable-encoders --disable-decoders --enable-decoder='sub,text,web,aac,ac3,alac,ape,ass,cc_dec,cook,eac3,flv,flac,h264,hevc,mp[1-3],peg,mpl2,nellymoser,opus,pcm,rawvideo,rv,sami,srt,ssa,v210,vc1,vorbis,vp[6-9],wm,wrapped_avframe' --disable-demuxers --enable-demuxer='sub,text,ac3,ac,peg,web,ape,ass,avi,concat,dash,flv,hls,h264,hevc,matroska,mlv,mov,mp3,mxf,nsv,nut,ogg,pcm,rawvideo,rtp,srt,vc1,v210,wav,pipe' --disable-parsers --enable-parser='sub,aac,ac3,cook,flac,h26[3-4],hevc,peg,opus,rv,vc1,vorbis,vp[8-9]' --cc=gcc-7 --enable-encoder='aac,gif,h26[3-4],hevc,mjpeg,mpeg[2-4],nellymoser,nvenc,opus,pcm,rawvideo,vorbis,vp,wrapped_avframe' --enable-muxer='dash,fifo,gif,h264,hevc,hls,mjpeg,matroska,mov,mp4,mpegts,nu,og,pcm,rawvideo,wav,webm,pipe'" "Build with avutil-55.78.100" "Build with avcodec-57.107.100" "Build with avformat-57.83.100" "Build with avfilter-6.107.100" "Build with avdevice-53.2.0" "Build with avresample-1.0.1" "Build with swresample-2.9.100" "Build with swscale-4.8.100" Registered audio backends: ("OpenAL", "Pulse", "null") AudioOutputBackend::id("OpenAL") QtAV 1.12.0(Mar 29 2018, 14:47:42) Multimedia framework base on Qt and FFmpeg. Distributed under the terms of LGPLv2.1 or later. Shanghai University->S3 Graphics->Deepin->PPTV, Shanghai, China Copyright (C) 2012-2017 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 capi::version: 0.6.0 [...] openal::capi::alcMakeContextCurrent(openal::capi::ALCcontext)@238:
[/foo/bar/Qt/QtAV/src/capi/openal_api.cpp] void openal::capi::alGetSourcei(openal::capi::ALuint, openal::capi::ALenum, openal::capi::ALint
)@208:
"audio thread gets an eof packet. pkt.pts: -1.000, d.render_pts0:-1.000" "[AudioDecoder] got_frame_ptr=false. decoded: 0, un: 3 Success" "Decode audio failed. undecoded: 3" "audio decode eof done" "video thread gets an eof packet." "waiting audio thread......." "audio thread gets an eof packet. pkt.pts: -1.000, d.render_pts0:-1.000" "[AudioDecoder] got_frame_ptr=false. decoded: 0, un: 3 Success" "Decode audio failed. undecoded: 3" "audio decode eof done" "Audio thread stops running..." "waiting video thread......." "no frame could be decompressed: Success 3/3" "video decode eof done. d.render_pts0: -1.000" "waiting video thread......." "wake up paused thread" "video thread gets an eof packet." "no frame could be decompressed: Success 3/3" "video decode eof done. d.render_pts0: -1.000" "Video thread stops running..." "setInSize => calculating aspect ratio from converted input data(0.000000)" "Demux thread stops running...." "demuxer thread emit finished. repeat: 0/0" "avplayer emit stopped()" "Can not copy codec properties when it's open" "(repeat 1)Can not copy codec properties when it's open\nclosing d->format_ctx"

MiWitt commented 6 years ago

I tried calling setCodecContext one more time if isOpen() and the error occurred less often: void setCodecContext(void* codecCtx, bool isRecall = false); //protected

void AVDecoder::setCodecContext(void *codecCtx, bool isRecall)
{
    ...
    if (isOpen()) {
        qWarning("Can not copy codec properties when it's open");
        close(); //
        if(!isRecall)
            setCodecContext(codecCtx,true);
   ...
}

Now the debug-output changes and and the player/video recovers: [...] "avplayer emit stopped()" "Can not copy codec properties when it's open" "(repeat 1)Can not copy codec properties when it's open\nclosing d->format_ctx" Loading QVariant(QString, "/media/path/tEST.mp4") ... "all closed and reseted" "avformat_open_input: d->format_ctx:'0x7fb83c000ae0', url:'/media/path/tEST.mp4'..." "avformat_open_input: url:'/media/path/tEST.mp4' ret:0"

Nevertheless I also managed to to create the error with these setting as well and the output now shows: "Demux thread stops running...." "demuxer thread emit finished. repeat: 0/0" "avplayer emit stopped()" "Can not copy codec properties when it's open" "(repeat 1)Can not copy codec properties when it's open\nclosing d->format_ctx" "Not playing~" "No gl context"