o-gs / dji-firmware-tools

Tools for handling firmwares of DJI products, with focus on quadcopters.
GNU General Public License v3.0
1.57k stars 424 forks source link

Inspire 1 bitrate change doesn't apply #120

Closed nicolov closed 5 years ago

nicolov commented 5 years ago

Thanks again! I've managed to unpack, edit, and reflash the m0100 module on my Inspire with X5. I've hex-edited all occurrences of 25000000 (4078 7d01) to 60000000 (0087 9303) in the m0100_part_sys.a9s file.

I was expecting 1080p 24fps videos to now be recorded at 60mbps (from 25mbps), but there seems to be no change. Do you happen to know if I'm missing anything?

mefistotelis commented 5 years ago

Try using hardcoder tool - if it exports the table correctly, it will be much easier for you to edit it.

Here's an example from P3X_FW_V01.01.0006_m0100_part_sys - note that a single bit rate seem to be controlled by 3 values:

[
    {
        "index" : 0,
        "description" : "AuthorityLevel established when SHA204 communication fail; 0-restricted,1-normal,2-superuser",
        "minValue" : 0,
        "maxValue" : 2,
        "defaultValue" : 0,
        "setValue" : 1,
        "name" : "og_hardcoded.p3x_ambarella.encrypt_query_fail_authority_level"
    },
    {
        "index" : 1,
        "description" : "AuthorityLevel established when encryption keys match; 0-restricted,1-normal,2-superuser",
        "minValue" : 0,
        "maxValue" : 2,
        "defaultValue" : 1,
        "setValue" : 1,
        "name" : "og_hardcoded.p3x_ambarella.verify_state_good_authority_level"
    },
    {
        "index" : 2,
        "description" : "AuthorityLevel established on encryption mismatch; 0-restricted,1-normal,2-superuser",
        "minValue" : 0,
        "maxValue" : 2,
        "defaultValue" : 0,
        "setValue" : 1,
        "name" : "og_hardcoded.p3x_ambarella.verify_state_bad_authority_level"
    },
    {
        "index" : 3,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_00"
    },
    {
        "index" : 4,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_01"
    },
    {
        "index" : 5,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_02"
    },
    {
        "index" : 6,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_03"
    },
    {
        "index" : 7,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_04"
    },
    {
        "index" : 8,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_05"
    },
    {
        "index" : 9,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "30000000 45000000 60000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_06"
    },
    {
        "index" : 10,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "20000000 30000000 40000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_07"
    },
    {
        "index" : 11,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "20000000 30000000 40000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_08"
    },
    {
        "index" : 12,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "20000000 30000000 40000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_09"
    },
    {
        "index" : 13,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "15000000 20000000 25000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_10"
    },
    {
        "index" : 14,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "15000000 20000000 25000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_11"
    },
    {
        "index" : 15,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "15000000 20000000 25000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_12"
    },
    {
        "index" : 16,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "20000000 30000000 40000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_13"
    },
    {
        "index" : 17,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "15000000 20000000 25000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_14"
    },
    {
        "index" : 18,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "10000000 15000000 20000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_15"
    },
    {
        "index" : 19,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "7000000 9000000 11000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_16"
    },
    {
        "index" : 20,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "20000000 30000000 40000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_17"
    },
    {
        "index" : 21,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "10000000 15000000 20000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_18"
    },
    {
        "index" : 22,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "8000000 12000000 16000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_19"
    },
    {
        "index" : 23,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "8000000 12000000 16000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_20"
    },
    {
        "index" : 24,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "5000000 7500000 10000000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_21"
    },
    {
        "index" : 25,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "4000000 6000000 8300000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_22"
    },
    {
        "index" : 26,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "4000000 6000000 8300000",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_23"
    },
    {
        "index" : 27,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "1702256979 1702065440 1702043762",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_24"
    },
    {
        "index" : 28,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "1852404852 1948283751 1330782319",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_25"
    },
    {
        "index" : 29,
        "description" : "Bitrates used for h.264 video compression; 3 values: min, avg, max",
        "minValue" : "1000000 1000000 1000000",
        "maxValue" : "64000000 64000000 64000000",
        "setValue" : "1948269133 1768580128 1953723680",
        "name" : "og_hardcoded.p3x_ambarella.vid_setting_bitrates_26"
    }
]
nicolov commented 5 years ago

I think I got the section offset right on my firmware (I used the 0405 0607 0809 0a0b 0c0d 0e0f 0a0b 0c0d pattern in the dump file, is this a good idea?). However, the script couldn't find the functions, and I ended up writing a python script.

Sadly, it seems that the X5 can't go above 64 mbps (where did you get that magic number, btw?). If I set 80mbps, files are recorded at 15mbps (for all resolutions, so it seems to be some sort of fallback).

Still a big improvement, 1080p/24fps videos are now 63mbps up from 25mbps.

Can you send me a slack invite?

mefistotelis commented 5 years ago

There's a "Slack" button with invite here: http://dji.retroroms.info/

If it doesn't work - let me know.

Magic number - we got it via trial and error.

nicolov commented 5 years ago

Thanks a lot for all your help!