[FFmpeg-trac] #9943(avformat:new): avformat/mpjpeg: should be more lenient when server fails to produce first boundary
FFmpeg
trac at avcodec.org
Mon Sep 26 11:09:09 EEST 2022
#9943: avformat/mpjpeg: should be more lenient when server fails to produce first
boundary
-------------------------------------+-------------------------------------
Reporter: Ratchanan | Type:
Srirattanamet | enhancement
Status: new | Priority: normal
Component: avformat | Version:
| unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary of the bug: Some old cameras (e.g. D-Link DCS-5020L) produce a
non-compliant `multipart/x-mixed-replace` stream which doesn't start with
the boundary. This trips the `mpjpeg` parser with `Invalid data found when
processing input` error. Since this format is autodetected, it should be
able to handle this case.
Specifying `-f mjpeg` works around this issue. However, many library users
don't allow specifying format directly, thus the workaround can't be
applied there.
Attached picture is the first parts of the camera's response, captured
from Wireshark. I want to just provide you the Wireshark dump, but I would
have to find a way to redact e.g. my credentials from it.
Reproducible on ffmpeg 4.4.2 and John Van Sickle's static Linux build
built on 2022-09-10.
How to reproduce:
{{{
$ ./ffprobe -report -v 9 -loglevel 99 -i http://<redacted>/mjpeg.cgi
ffprobe started on 2022-09-26 at 14:37:10
Report written to "ffprobe-20220926-143710.log"
Log level: 99
Command line:
./ffprobe -report -v 9 -loglevel 99 -i "http://<redacted>/mjpeg.cgi"
ffprobe version N-63101-gc92edd969a-static
https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2022 the FFmpeg
developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-
debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio
--cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp
--enable-libgme --enable-gray --enable-libaom --enable-libfribidi
--enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt
--enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab
--enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid
--enable-libzvbi --enable-libzimg
libavutil 57. 36.101 / 57. 36.101
libavcodec 59. 42.104 / 59. 42.104
libavformat 59. 30.101 / 59. 30.101
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 48.100 / 8. 48.100
libswscale 6. 8.108 / 6. 8.108
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100
[NULL @ 0x69644c0] Opening 'http://<redacted>/mjpeg.cgi' for reading
[http @ 0x6964d00] Setting default whitelist
'http,https,tls,rtp,tcp,udp,crypto,httpproxy,data'
[tcp @ 0x6967c00] Original list of addresses:
[tcp @ 0x6967c00] Address <redacted> port 80
[tcp @ 0x6967c00] Interleaved list of addresses:
[tcp @ 0x6967c00] Address <redacted> port 80
[tcp @ 0x6967c00] Starting connection attempt to <redacted> port 80
[tcp @ 0x6967c00] Successfully connected to <redacted> port 80
[http @ 0x6964d00] request: GET /mjpeg.cgi HTTP/1.1
User-Agent: Lavf/59.30.101
Accept: */*
Range: bytes=0-
Connection: close
Host: <redacted>
Icy-MetaData: 1
[http @ 0x6964d00] header='HTTP/1.0 401 Authorization Required'
[http @ 0x6964d00] http_code=401
[http @ 0x6964d00] header='Server: alphapd/2.1.8'
[http @ 0x6964d00] header='Date: Mon Sep 26 14:37:10 2022'
[http @ 0x6964d00] header='Pragma: no-cache'
[http @ 0x6964d00] header='Cache-Control: no-cache'
[http @ 0x6964d00] header='Content-type: text/html'
[http @ 0x6964d00] header='Content-length: 103'
[http @ 0x6964d00] header='WWW-Authenticate: Basic realm="NIPCA"'
[http @ 0x6964d00] header=''
[tcp @ 0x6968200] Original list of addresses:
[tcp @ 0x6968200] Address <redacted> port 80
[tcp @ 0x6968200] Interleaved list of addresses:
[tcp @ 0x6968200] Address <redacted> port 80
[tcp @ 0x6968200] Starting connection attempt to <redacted> port 80
[tcp @ 0x6968200] Successfully connected to <redacted> port 80
[http @ 0x6964d00] request: GET /mjpeg.cgi HTTP/1.1
User-Agent: Lavf/59.30.101
Accept: */*
Range: bytes=0-
Connection: close
Host: <redacted>
Icy-MetaData: 1
Authorization: Basic <redacted>
[http @ 0x6964d00] header='HTTP/1.0 200 OK'
[http @ 0x6964d00] http_code=200
[http @ 0x6964d00] header='Server: alphapd/2.1.8'
[http @ 0x6964d00] header='Date: Mon Sep 26 14:37:10 2022'
[http @ 0x6964d00] header='Pragma: no-cache'
[http @ 0x6964d00] header='Cache-Control: no-cache'
[http @ 0x6964d00] header='Content-Type: multipart/x-mixed-
replace;boundary=--video boundary--'
[http @ 0x6964d00] header=''
Probing mpjpeg score:0 increased to 75 due to MIME type
[mpjpeg @ 0x69644c0] Format mpjpeg probed with size=2048 and score=75
[AVIOContext @ 0x6978780] Statistics: 3000 bytes read, 0 seeks
http://<redacted>/mjpeg.cgi: Invalid data found when processing input
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9943>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list