I am using ffmpeg to play RTSP streams in an application. I have been running into a problem that once I reach the end of an RTSP stream, I am no longer able to see back to anywhere in the stream.
The program I am writing is using LGPL shared libraries, but I can see the same behavior using ffplay using GPL version.
ffplay.exe "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
While the video is playing, I can seek forward or backwards using the keyboard shortcuts for ffplay (left / right arrow key). Once the stream reaches the end, it is not possible and the stream is paused or playing, seeking no longer works. I see errors in the shared lib, but in ffplay, I do not see errors unless I use the s
key (which may make sense that I cannot seek). In other streams, I have seen an issue where the stream is longer than the reported length, and once the extra video is buffered/downloaded, it is not possible to seek. Any guidance on what is going on here?
Using ffplay.exe
(also verified with newer build):
C:\Users\kealist\Downloads\ffmpeg-20180526-63c4a4b-win64-static\bin>ffplay "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
ffplay version N-91158-g63c4a4b0d6 Copyright (c) 2003-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.104 / 58. 19.104
libavformat 58. 17.100 / 58. 17.100
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 24.100 / 7. 24.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
[udp @ 0000023ce71807c0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0000023ce7174ac0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0000023ce71a6f40] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0000023ce7174bc0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[rtsp @ 0000023ce717d900] UDP timeout, retrying with TCP 0B f=0/0
Input #0, rtsp, from 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov':
Metadata:
title : BigBuckBunny_115k.mov
Duration: 00:09:56.48, start: 0.000000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 12000 Hz, stereo, fltp
Stream #0:1: Video: h264 (Constrained Baseline), yuv420p(progressive), 240x160, 24 fps, 24 tbr, 90k tbn, 48 tbc
rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov: error while seeking
rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov: error while seeking
596.27 A-V:-32.424 fd=1290 aq= 0KB vq= 0KB sq= 0B f=1/1
With -v trace
I can see that there is a Seek message, but no seeking actually occurs whether it is paused or playing.
video: delay=0.000 A-V=0.173265
Seek to 37% ( 0:03:38) of total duration ( 0:09:56) B f=1/1
Seek to 83% ( 0:08:14) of total duration ( 0:09:56) B f=1/1
Seek to 57% ( 0:05:42) of total duration ( 0:09:56) B f=1/1
Seek to 78% ( 0:07:41) of total duration ( 0:09:56) B f=1/1
Seek to 85% ( 0:08:24) of total duration ( 0:09:56) B f=1/1
Seek to 92% ( 0:09:06) of total duration ( 0:09:56) B f=1/1
Last message repeated 1 times
Seek to 92% ( 0:09:08) of total duration ( 0:09:56) B f=1/1
Last message repeated 1 times
597.08 A-V:-34.561 fd= 312 aq= 0KB vq= 0KB sq= 0B f=1/1
Is there a way to mitigate this without reloading the stream?
This is a bug in FFMPEG. It exists in all players using ffmpeg that I have seen in Windows and OSX. It is reported here. For the specific issue I was facing, I had to save/record the stream locally and play the video locally instead of using RTSP playback.