JPEG-Repair, no SOS detected

By | April 1, 2020

A common error message that JPEG-Repair reports is ‘no SOS detected’. I have written several posts and made videos to repair JPEG photos in case the Windows photo viewers report errors:

The old Windows photo viewer: File appears to be damaged, corrupted or is too large.

The new Windows Photos: It looks like we don’t support this file format.

The errors indicate the viewers can not read the JPEG header, it’s a catch all, broad message that can mean a lot of things. JPEG-Repair allows you to transplant the header of an intact file, a reference file, to a corrupt file. For this you use the ‘Repair header’ tool. A prerequisite for the Repair header tool to work is that the corruption is limited to the JPEG header. If corruption extends beyond that JPEG-Repair will report ‘no SOS detected’. A common comment below my posts and videos on the topic is people getting this error message. Pretty frustrating, I get that.

Let’s look at what it means – no SOS detected

A JPEG is divided into several sections, all preceded by a JPEG Marker. The JPEG marker tells the software that reads the file what it will find inside a particular section, and it also tells the size of the section. Using this size info it can find the next section. So it’s really a chain of sections with no real header. I personally refer to all sections preceding the actual image data as ‘the header’.

The section containing the actual image data starts with the SOS or start of scan marker (FF DA in hex). It is the only marker that does not contain a size value! Instead the SOS section contains a compressed and encoded stream of image data. The software is supposed to keep decoding this data until it reached the EOI marker (FF D9 in hex).

JPEG markers - JPEG file structure

JPEG-Repair giving the error ‘no SOS detected’ basically means the corruption extends beyond the ‘header’ and the tool being unable to locate the start of the JPEG image stream. And therefor it can not determine what to glue an intact header onto.

It’s however not the only thing JPEG-Repair reports, it also reports ‘entropy’ for the files affected by the error:

JPEG-Repair shows the file size and entropy. This information can give you hints if a file can be repaired or not. Common issues you can get from these values are:

  • File size 0 KB. This file can not be repaired which may be obvious. But also with larger files you may want to compare the file size against the average file size for photos produced by your camera with similar settings. If the file is considerably smaller it is unlikely it can be repaired.
  • Entropy: Entropy is a measure of chaos and JPEGs, largely consisting of compressed data usually have an entropy value between 7.6x and 7.9x. If this value is considerably off then the file probably does not contain JPEG data and can therefor not be repaired.

IOW, the message no SOS detected in itself gives very limited info. You need to combine it with the other data to reach a meaningful conclusion. If the file size appears to be valid and entropy is between 7.6x and 7.9x the file still may be repairable.

How to repair a file with error no SOS detected

You can not batch process these files, you will need to repair these file by file. Repair requires manual interaction.

After you determined the file has a valid size and entropy you need to:

  • Select the patch tool
  • Enable ‘append option’
  • Select the corrupt file
  • Select the reference file
  • Click OK
  • Click Repair

JPEG-Repair will process the file and get rid of any invalid data that will prevent the file from rendering. The file will probably misaligned and colors may look off. The following video shows a repair from start to end:

Leave a Reply

Your email address will not be published. Required fields are marked *