[Libav-user] RTP/MJPEG low contrast image on low quality setting

Ico Doornekamp libav at zevv.nl
Thu Mar 24 13:13:15 CET 2016


* On 2016-03-24 12:01:41 +0100, Carl Eugen Hoyos wrote:
 
> Please try to dump the mjpeg stream to a file:
> $ ffmpeg -i input -vcodec copy -f rawvideo -map 0:v:0 out.mjpeg
> Or use mplayer -dumpvideo

I tried this already, but forgot to mention in my original mail. 

  http://zevv.nl/div/libav/out.mjpeg
  
The resulting MJPEG file shows the same washed out image, in this case
also when played with VLC.

After some investigating I found out the problem has likely to do with
the quantization tables of the JPG stream. In the RTP stream the 'Q'
field is set to 14, which according to RFC2435 sec4.2 means that the
quantization tables are not embedded in the JPG stream, but are
calculated from a predefined formula. With some trial and error I
altered the calculated prescale factor in libavformat/rtpdec_jpeg.c's
create_default_qtables() and was able to get reasonable results with the
output quality.

My next task is to determine if the problem is in the device generating
the stream, or in the way libav handles the quantization tables. I'll no
go dig into the VLC source to see how the Q field is handled there,
since VLC seems to be able to generate a proper image from the same RTP
stream.

Thanks,

 


More information about the Libav-user mailing list