User Tools

Site Tools


doc:appunti:hardware:sjcam-8pro-custom-firmware

This is an old revision of the document!


SJCAM SJ8 Pro Custom Firmware

The SCAM SJ8 Pro is a mid-range priced action camera, equipped with chips well known for their quality: the Ambarella H22 S85 and the Sony IMX377 sensor. Still in 2022 it was well placed between the expensives GoPros and the plethora low-end budget cameras. Unfortunately the support from SJCAM was ended in 2020 with the firwmare 1.3.2 still affected by various bugs, image quality and video codec settings definitely to be improved. Also the Adnroid app is disappointing.

Fortunately enough, being equipped with the Ambarella chip, it was possible to reverse engineer some of its firmware and API. Creating a custom firmware you can imporove the overall experience. It is important to remember that this took a lot of hard work.

The main honorable mention goes to the hacker VMax, which created the software BitrateEditor.

See my other page about the SJCAM SJ8 Pro action camera: SJCAM SJ8 Pro Review, How to customize the Ambarella firmware of the SJCAM SJ8 Pro and SJCAM SJ8 Pro WiFi Ambarella API.

My Custom firmware

Download the custom firmware here: sj8pro_mod-rigacci.org_v1.8_20220618.zip.

This is a breif list of customizations, see the README.txt contained into the archive for more details:

  • Increased bitrates, as per other 4K action cameras. Particular attention to default settings and 1920×1080 mode.
  • Increased keyframes rates (reducing GOP-N): one keyframe every 1/4 second instead of 1 per second.
  • YUV color profiles: all the three profiles Default, SJCAM - Vivid and Flat are made equals and neutral; multiplier is 1 and offset is zero for all the three Y, Cb and Cr components.
  • Fixed exposition profiles: Center, Spot and Average.
  • Changed gamma curves: added some brightness to shadows with an overall gamma coefficient of 1.10 and removed a slight red casting when using Auto White Balance in early hours of sunny days. All the gamma tables for video modes are the same, for photo modes we leaved a linear gamma (1.0) for R, G and B.
  • Change chroma curves to reduce banding in blue sky and to attenuate over-saturated colors.
  • Changed power-on, power-off and photo shutter sounds with louder ones.
  • Disabled LRV (low resolution videos) recording.

Bitrates

The SJ8 Pro camera has by default very low bitrates compared with other 4K action cameras. In the following table you can compare three cameras in various video modes. My custom settings are geared to always keep the standard quality and to film mainly at 1920×1080, to save space and battery.

Bitrates
SJCAM
SJ8Pro
Xiaomi
Yi 4K+
DJI Osmo
Action 4K
My Custom
SJ8Pro
Video Mode Eco Std Fine Default S-Fine Default Eco Std Fine
4K@60 50 60 100 100 135 100 80 100 120
4K@30 30 40 60 60 100 100 46 72 98
2.7K@60 46 60 72 60 75 100 40 60 80
2.7K@30 24 34 52 45 60 82 30 48 60
1440@60 24 30 36 60 75 36 56 76
1440@30 24 30 36 45 60 28 46 58
1080@120 44 58 74 60 75 100 40 60 80
1080@60 24 30 36 45 60 82 30 48 60
1080@30 18 24 30 45 60 36 24 38 48
720@240 24 30 36 60 75 100 40 60 80

NOTICE: For bitrates of 100 Mbit/s or above you have to consider the micro SD card performances. Recording a stream of 100 Mbit/s means writing a sustained stream of 12 Mb/s (megabytes/second). Checking the speed class ratings from the Wikipedia SD card page, you understand that you need at least a V30 Video Speed Class, or U3 UHS Speed Class.

Bitrates GOP

I want at least 4 keyframes per second, so I can cut scenes without re-encoding with the precision of about 0.25 seconds. The original firmware instead put only a keyframe every second.

GOP-N Values
FPS 24 25 30 60 120 240
SJ8Pro Default 24 32 32 64 120 240
My Custom SJ8Pro 6 8 8 16 32 64

YUV Profiles

For my taste the two YUV profiles are both too exagerated. The Vivid - SJCAM profile has too much contrast and colors are too much saturated, something that is eye-catching on a small smartphone screen, but rather disturbing on a larger and good quality screen. By contrast the Flat profile is so washed-out that you almost never want to use it.

For the default and vivid profile I reduced the multipliers by about 6% on the luminance channel and by about 14% on the colors channels. Then I decreased the luminance offset (2%) to recover a bit of the black. For the flat profile I reduced the luminance multiplier by about 19%, on both the color channels the multiplier was reduced by about 21%; then I added about 2.5% to the luminance offset, to get some more white.

The resulting two profiles are not so different from each other, may be you cannot tell them apart looking at the touch screen. This may be a problem, because of the firmware bug which does not properly show the selected profile name and which does not remember the selected profile on power-off/power-on. Neverthless you can use the flat profile when you want to have softer colors and contrast.

SJCAM SJ8Pro Default My Custom SJ8Pro
Default Vivid Flat Default Vivid Flat
Y 1024 1024 690 1024 1024 1024
U 1024 1024 820 1024 1024 1024
V 1024 1024 820 1024 1024 1024
Y-offset 0 0 40 0 0 0
U-offset 0 0 0 0 0 0
V-offset 0 0 0 0 0 0

Exposition

Metering tables were fixed, this simply means swapping profiles Spot and Average.

Gamma curves

There is no documentation on how the */255, */128 and */0 groups are mixed together, from my experiments it seems that:

  • Group */0 is not used at all.
  • Groups */255 and */128 are mixed togheter, but with some sort of brightness threshold, so it is very likely that you can obtain color banding if graphs curves are not accurately tuned.
  • It seems that in some particular circumstances (some color component of */255 is very dark) the gamma curve is replaced automatically with something different, may be a negative (descending) curve.

FIXME Version 1.8 was changed! No more color correction, but just some slight deviation from linear gamma!

After countless hours of testing, firmware uploads and color checking, it turned out that:

  • The camera is rather good in automatic withe balancing.
  • The camera produces rather fair colors when set with neutral gamma correction and neutral YUV profiles.
  • The stock firmware have somewhat exagerated saturation and contrast, just simply reducing them produces a better video quality (in my humble opinion).
  • Non-auto white balance settings produce un-natural color casting. It is possibile to correct it using gamma or YUV, but if you fix e.g. the Sunny white balance, you will break the auto setting.

I initally made a firmware where the original gamma curves were replaced with ascending linear lines, i.e. no actual gamma transformation. Using that firmware I filmed a color checker board and then I calculated a spline interpolation line for each RGB channel that will do a white balance on the color checker gray scale. It turned out that blue channel should be reduced in shadows and augmented in highlights, the contrary is necessary for the green channel.

The curves so calculated were loaded for all the video modes tables */255 and */128; the curve */0 seems not used at all, so I leaved it linear. For photo modes I leaved a linear gamma (no transformation at all), because I prefer to do color balancing in post-processing.

Chroma curves

I think that the original chroma curves programmed into the SJ8 Pro are responsible for the over-saturated colors and for some annoying banding often visible in the blue sky. I changed the curves reducing smoothly the graph toward the highlights for the table */128 (used for evenly exposed parts of the image) and increasing smoothly the graph starting from the shadows for the table */0 (used for over-exposed parts of the image). Based on my testing the table */255 is responsible for very low chrominance applied only for heavy under-exposed images, so I leaved the original graph, which is a straight line all at the maximum value.

Sounds

I changed the original sounds for power-on, power-off and photo shutter with something more audible. They are simple and loud beeps, but with different patterns, so they can be distinguished.

autoexec.ash

The autoexec.ash file is not actually part of the firmware; if you want you can copy it into the root directory of the SD card. It is written in Ambarella Shell and it is executed at camera power on.

The autoexec.ash file included into the archive consists of a single line of code to disable the recording of the .LRV (low resolution video) files into the SD card. I don't use them at all, so it is a waste of space and CPU/battery to create them.

doc/appunti/hardware/sjcam-8pro-custom-firmware.1656328064.txt.gz · Last modified: 2022/06/27 11:07 by niccolo