QtAV icon indicating copy to clipboard operation
QtAV copied to clipboard

RTSP Stream : queue becomes empty after some seconds

Open Wise opened this issue 12 years ago • 22 comments

Trying to play a video stream coming from a server with my own RTSP implementation. After a few seconds of normal video play, the BlockingQueue in AVDemuxer becomes and remains empty

http://pastebin.com/7V8qaYWd

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1300732-rtsp-stream-queue-becomes-empty-after-some-seconds?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).

Wise avatar Jun 07 '13 07:06 Wise

can other players (ffplay, mplayer) play it normally? it seems that the player can not read the stream

wang-bin avatar Jun 08 '13 05:06 wang-bin

Hi, I have a similar problem with RTSP live camera input. It complains about hundreds missing packets when decoding video. Did you use some input caching depth when readind input stream?? Wherre?? Many thanks.

debosvi avatar Aug 26 '13 08:08 debosvi

many packet missing. i'm not sure why it happens.

wang-bin avatar Aug 26 '13 09:08 wang-bin

While decoding video, h264 codec complains it has not enough data to decode entire frame (especially at the beginning of video playing). I thought it was only a problem of data cache, but I fixed this issue by using rtsp_transport parameter set to TCP instead of UDP. But I think it is not enoug to fix the real issue. As many video payers do, it is possible to consider caching input data until frmaes can be deocded entirely. But I dont know how yet.

debosvi avatar Aug 26 '13 10:08 debosvi

@debosvi I think you are right. QtAV has not cache, it may decode an uncompelete frame. I will try to solve this problem. : )

wang-bin avatar Aug 26 '13 10:08 wang-bin

my camera is an Axis Brand which is not well known about pts and continuous stream on network. i have added AVDict options like

AVDictionary *opts=NULL; av_dict_set(&opts, "rtsp_transport", "tcp", 0); avformat_open_input(&format_context, qPrintable(_file_name), NULL, &opts);

debosvi avatar Dec 13 '13 07:12 debosvi

But not all rtsp streamers have such option

debosvi avatar Dec 13 '13 07:12 debosvi

Does AVDict solve the problem? pts will be added internally? I'm not familiar with avdict.

wang-bin avatar Dec 13 '13 07:12 wang-bin

Yes but only for camera (streamer) which allow such option. VLC rtsp stream is not compatible with this option for example (by default I think and I had not search more)

debosvi avatar Dec 13 '13 09:12 debosvi

So I have to add dict support

wang-bin avatar Dec 13 '13 10:12 wang-bin

how and for which class?? it is up to you or not, your choice!!

I found a bug around clock comparison in AVClock class. The fact is that QElapsed timer derived progressively between restart and timeout (a unary insignificant slice but repeated several times becomes significant). It could have the issue we faced.

Instead of having restartable timer, I fixed the issue in my side with continuous timer and then the issue disappeared.

debosvi avatar Dec 13 '13 12:12 debosvi

i think we can add it in avdemuxer. issue 86 also talk about this.

do you still use qelapsedtimer? can you give a patch for clock?

wang-bin avatar Dec 13 '13 13:12 wang-bin

I will send you a Unix patch (not really Qt). Then I think you can transpose it to Qt.

debosvi avatar Dec 16 '13 09:12 debosvi

how can I send you a patch file??

debosvi avatar Dec 16 '13 10:12 debosvi

you can paste here, or use gist

wang-bin avatar Dec 16 '13 10:12 wang-bin

I tried to paste my file, but the HMI adds some spurious presentation (not very readable afterwards) Git you mean?? How appart from pull request??

debosvi avatar Dec 16 '13 10:12 debosvi

you can see Gist on the top of this page. click it and you can paste something. Then past the gist url here

wang-bin avatar Dec 16 '13 10:12 wang-bin

https://gist.github.com/debosvi/7985027

debosvi avatar Dec 16 '13 10:12 debosvi

@debosvi I have added dict api.

QHash<QByteArray, QByteArray> dict;
dict.insert("rtsp_transport", "tcp");
mpPlayer->setOptionsForFormat(dict);

you can test now

wang-bin avatar Jan 09 '14 15:01 wang-bin

I use another QElapsedTimer to correct pts periodically to reduce the accumulative error. the error should always be not greater than the error of calling restart() once. this works fine for me.

see commit 6c7790fe28019fbe1c4181e437b8521eaf6b9e7b

@debosvi I don't use your patch because it's not cross-platform.

wang-bin avatar Oct 14 '14 10:10 wang-bin

Okay thank you. I will test soon on my platform.

debosvi avatar Oct 14 '14 11:10 debosvi

hey @wise, is there any e-mail I’m able to contact you? Sorry about sending in this non related thread, but it was the only way I found. This is regarding a job proposal.

vinisgomes avatar Jul 02 '25 13:07 vinisgomes