[FFmpeg-trac] #8211(avformat:open): ffplay doesn't play mjpeg stream
FFmpeg
trac at avcodec.org
Tue Jul 19 06:53:51 EEST 2022
#8211: ffplay doesn't play mjpeg stream
-------------------------------------+------------------------------------
Reporter: Anh | Owner: (none)
Type: enhancement | Status: open
Priority: wish | Component: avformat
Version: git-master | Resolution:
Keywords: rtsp mjpeg | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 1 |
-------------------------------------+------------------------------------
Comment (by Obadiah):
Replying to [comment:18 Carl Eugen Hoyos]:
> Sorry for my bad interpretation of the ticket, I had originally found an
Android binary but no source code!
>
> The issue is that the restart interval in the attached dump (and
according to the original description also in the rtp header) is 0x3de
(990) for the first frame and has similar values between 986 and 1026 for
the remaining frames. If I force the restart interval for each frame to
0x28 (40) in the decoder, the stream plays fine.
> Looking at RFC 2435 I don't see an obvious bug in
libavformat/rtpdec_jpeg.c and to the best of my knowledge there is no bug
related to the restart interval in FFmpeg's jpeg decoder indicating that
in the end, my interpretation may not have been so far off.
> I don't know how this issue can be fixed reliably.
> {{{
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index 20f310fd70..9a4c1b8b2b 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -1802,6 +1802,7 @@ static int mjpeg_decode_dri(MJpegDecodeContext *s)
> if (get_bits(&s->gb, 16) != 4)
> return AVERROR_INVALIDDATA;
> s->restart_interval = get_bits(&s->gb, 16);
> +s->restart_interval = 40;
> s->restart_count = 0;
> av_log(s->avctx, AV_LOG_DEBUG, "restart interval: %d\n",
> s->restart_interval);
> }}}
I have a similar camera with the same RTSP URL and whose app also uses
IjkPlayer. Without the patch applied, FFMPEG throws me "Could not find
codec parameters for stream 0". Testing the patch, I got the same error
the original poster had without the patch:
{{{
mjpeg_decode_dc: bad vlc: 0:0
error dc
error y=1 x=0
}}}
I could also get a green screen as a video. Could it be that the interval
for my camera is slightly different than the one proposed (40)? Can you
explain how did you find that value?
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8211#comment:25>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list