Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set video_callback bitrate #26

Closed
gtxaspec opened this issue May 9, 2022 · 16 comments
Closed

set video_callback bitrate #26

gtxaspec opened this issue May 9, 2022 · 16 comments

Comments

@gtxaspec
Copy link

gtxaspec commented May 9, 2022

@mnakada, are you familiar with a way to set the bitrate (kbps) for the video hooked by video_callback? perhaps it could be adjusted in the source.

@mnakada
Copy link
Owner

mnakada commented May 9, 2022

I don't know.
But I think it is difficult because the values held by iCamera_app must be changed at the same time as the settings on the SDK side to be consistent.
I think you can change the values on the SDK side by calling the API, but on the iCamera_app side, you cannot get the reference address to the variables.

@gtxaspec
Copy link
Author

ah, yes the api, I understand. comparisons with the official rtsp (1000kbps avg) and the libcallback (200kpbs avg) the difference is remarkable.

@mnakada
Copy link
Owner

mnakada commented May 13, 2022

How do you measure that bitrate?
Can I check it?

@gtxaspec
Copy link
Author

gtxaspec commented May 14, 2022

@mnakada i have discovered you can adjust the bitrate using:

        /system/bin/impdbg --enc_rc_s 0:48:4:2048
        /system/bin/impdbg --enc_rc_s 0:52:4:2048

the api can reset these changes, be aware.

impdbg --enc_info
gives more info on what the other options are.

the first one is MAX BITRATE
the second is TARGET bitrate.

the quality is much improved.

@thematrixdev
Copy link

Is the video bitrate mentioned here refers to the video saving to SD-card?
I wonder if the bitrate could be reduced so as to reduce IO load.

@gtxaspec
Copy link
Author

gtxaspec commented May 14, 2022

i am not sure if it related to SD card, you should try it
edit: yes it does
file sizebefore change: 7.7mb
after change: 16mb
per 1 minute chunks
at 2048 bitrate

@mnakada
Copy link
Owner

mnakada commented May 14, 2022

Thanks for the information.
I will check it.

@thematrixdev
Copy link

@gtxaspec Is it possible to make the audio better quality?
Most of the time I cannot hear the content of the conversation.

@gtxaspec
Copy link
Author

gtxaspec commented May 16, 2022

@thematrixdev not sure, from what I have discovered, the debug tools only allow us to adjust some of the video parameters. perhaps @mnakada has some further insight or knowledge from his experience.

@mnakada
Copy link
Owner

mnakada commented May 16, 2022

@gtxaspec
I tried changing various impdbg setting values and audio on/off, but I did not see any change in bitrate.
In the case of AtomCam, observing the stream bitrate in VLC Statistics, it is about 600 kb/s when the video is still and about 2500 kb/s when the video is moving in front of the camera.

@thematrixdev
Audio is 8K/mono so the sampling frequency is low, but it looks like the hardware is not picking up the sound properly.

@gtxaspec
Copy link
Author

gtxaspec commented May 16, 2022

@mnakada i understand, perhaps there are differences between the atomcam and wyze. Would you share the output of impdbg --enc_info ?

@gtxaspec
Copy link
Author

gtxaspec commented May 16, 2022

@thematrixdev maybe it could be related to the noise suppression of the T31 SDK... the documentation states:

int IMP_AI_EnableNs ( IMPAudioIOAttr * attr ,
    int mode
  )    
Remark
The mode parameter of noise suppression indicates the level of noise suppression, ranging from [0 to 3]. The higher the level, the cleaner the noise suppression.
However, the cleaner the noise suppression is, the more sound details will be lost, so there is a contradiction here, which needs to be
balance when using it.
Notice
Echo cancellation includes noise suppression, if echo cancellation is enabled, noise suppression is not required.
int IMP_AI_EnableNs ( [IMPAudioIOAttr](https://github.com/mnakada/atomcam_tools/issues/struct_i_m_p_audio_i_o_attr.html) * attr , int mode )

checking logcat :

I/ai      (  262): AI Enable Chn: 1-0
I/ai      (  262): EXIT AI Enable Chn: 1-0
I/ai      (  262): AI Set Gain: 31
I/ai      (  262): AI Set Vol: 90
I/ai      (  262): AI AGC ENABLE: targetLevelDbfs = 4, compressionGaindB = 10, limiterEnable =1
I/ai      (  262): AI HPF Enable
I/ai      (  262): HPF version is: Ingenic High Pass Filter 1.1.0

i'm not sure how to check what it is set to

@mnakada
Copy link
Owner

mnakada commented May 16, 2022

@gtxaspec The output of impdbg -enc_info is as follows.

GROUP 0
	CHANNEL 0    1920x 1080     START H264 tf:673530     df:387        encdur:33667364, encodingFrameCnt:673143,endencodeFrameCnt=673143,endrelaseFrameCnt=673143,Fps:20.01,Bitrate:459.52
-------------------------------------------------
ch->index = 0
chnAttr->encAttr->eProfile = 77(0x4d) offset:size = 0:4
chnAttr->encAttr->uLevel = 41(0x29) offset:size = 4:1
chnAttr->encAttr->uTier = 0(0x0) offset:size = 5:1
chnAttr->encAttr->uWidth = 1920(0x780) offset:size = 6:2
chnAttr->encAttr->uHeight = 1080(0x438) offset:size = 8:2
chnAttr->encAttr->ePicFormat = 392(0x188) offset:size = 12:4
chnAttr->encAttr->eEncOptions = 294952(0x48028) offset:size = 16:4
chnAttr->encAttr->eEncTools = 156(0x9c) offset:size = 20:4
chnAttr->rcAttr->rcMode = 8(0x8) offset:size = 44:4
chnAttr->rcAttr->CappedQuality->uTargetBitRate = 720(0x2d0) offset:size = 48:4
chnAttr->rcAttr->CappedQuality->uMaxBitRate = 960(0x3c0) offset:size = 52:4
chnAttr->rcAttr->CappedQuality->iInitialQP = -1(0xffffffff) offset:size = 56:2
chnAttr->rcAttr->CappedQuality->iMinQP = 23(0x17) offset:size = 58:2
chnAttr->rcAttr->CappedQuality->iMaxQP = 51(0x33) offset:size = 60:2
chnAttr->rcAttr->CappedQuality->iIPDelta = 3(0x3) offset:size = 62:2
chnAttr->rcAttr->CappedQuality->iPBDelta = 3(0x3) offset:size = 64:2
chnAttr->rcAttr->CappedQuality->eRcOptions = 1(0x1) offset:size = 68:4
chnAttr->rcAttr->CappedQuality->uMaxPictureSize = 1920(0x780) offset:size = 72:4
chnAttr->rcAttr->CappedQuality->uMaxPSNR = 48(0x30) offset:size = 76:2
chnAttr->rcAttr->outFrmRate->frmRateNum = 20(0x14) offset:size = 80:4
chnAttr->rcAttr->outFrmRate->frmRateDen = 1(0x1) offset:size = 84:4
chnAttr->gopAttr->uGopCtrlMode = 2(0x2) offset:size = 88:4
chnAttr->gopAttr->uGopLength = 20(0x14) offset:size = 92:2
chnAttr->gopAttr->uNumB = 0(0x0) offset:size = 94:1
chnAttr->gopAttr->uMaxSameSenceCnt = 1(0x1) offset:size = 96:4
chnAttr->gopAttr->bEnableLT = 0(0x0) offset:size = 100:1
chnAttr->gopAttr->uFreqLT = 0(0x0) offset:size = 104:4
chnAttr->gopAttr->bLTRC = 0(0x0) offset:size = 108:1
	CHANNEL 4    1920x 1080      STOP JPEG tf:6950       df:8          encdur:33649471, encodingFrameCnt:6942,endencodeFrameCnt=6942,endrelaseFrameCnt=6942,Fps:0.50,Bitrate:235.95
-------------------------------------------------
ch->index = 4
chnAttr->encAttr->eProfile = 67108864(0x4000000) offset:size = 0:4
chnAttr->encAttr->uLevel = 0(0x0) offset:size = 4:1
chnAttr->encAttr->uTier = 0(0x0) offset:size = 5:1
chnAttr->encAttr->uWidth = 1920(0x780) offset:size = 6:2
chnAttr->encAttr->uHeight = 1080(0x438) offset:size = 8:2
chnAttr->encAttr->ePicFormat = 392(0x188) offset:size = 12:4
chnAttr->encAttr->eEncOptions = 294952(0x48028) offset:size = 16:4
chnAttr->encAttr->eEncTools = 156(0x9c) offset:size = 20:4
chnAttr->rcAttr->rcMode = 0(0x0) offset:size = 44:4
chnAttr->rcAttr->FixQP->iInitialQP = 32(0x20) offset:size = 48:2
chnAttr->rcAttr->outFrmRate->frmRateNum = 20(0x14) offset:size = 80:4
chnAttr->rcAttr->outFrmRate->frmRateDen = 1(0x1) offset:size = 84:4
chnAttr->gopAttr->uGopCtrlMode = 2(0x2) offset:size = 88:4
chnAttr->gopAttr->uGopLength = 40(0x28) offset:size = 92:2
chnAttr->gopAttr->uNumB = 0(0x0) offset:size = 94:1
chnAttr->gopAttr->uMaxSameSenceCnt = 1(0x1) offset:size = 96:4
chnAttr->gopAttr->bEnableLT = 0(0x0) offset:size = 100:1
chnAttr->gopAttr->uFreqLT = 0(0x0) offset:size = 104:4
chnAttr->gopAttr->bLTRC = 0(0x0) offset:size = 108:1
	CHANNEL 2    1920x 1080     START H265 tf:673530     df:124        encdur:33667365, encodingFrameCnt:673406,endencodeFrameCnt=673405,endrelaseFrameCnt=673405,Fps:20.01,Bitrate:70.39
-------------------------------------------------
ch->index = 2
chnAttr->encAttr->eProfile = 16777217(0x1000001) offset:size = 0:4
chnAttr->encAttr->uLevel = 50(0x32) offset:size = 4:1
chnAttr->encAttr->uTier = 1(0x1) offset:size = 5:1
chnAttr->encAttr->uWidth = 1920(0x780) offset:size = 6:2
chnAttr->encAttr->uHeight = 1080(0x438) offset:size = 8:2
chnAttr->encAttr->ePicFormat = 392(0x188) offset:size = 12:4
chnAttr->encAttr->eEncOptions = 294952(0x48028) offset:size = 16:4
chnAttr->encAttr->eEncTools = 156(0x9c) offset:size = 20:4
chnAttr->rcAttr->rcMode = 8(0x8) offset:size = 44:4
chnAttr->rcAttr->CappedQuality->uTargetBitRate = 600(0x258) offset:size = 48:4
chnAttr->rcAttr->CappedQuality->uMaxBitRate = 800(0x320) offset:size = 52:4
chnAttr->rcAttr->CappedQuality->iInitialQP = -1(0xffffffff) offset:size = 56:2
chnAttr->rcAttr->CappedQuality->iMinQP = 32(0x20) offset:size = 58:2
chnAttr->rcAttr->CappedQuality->iMaxQP = 51(0x33) offset:size = 60:2
chnAttr->rcAttr->CappedQuality->iIPDelta = -1(0xffffffff) offset:size = 62:2
chnAttr->rcAttr->CappedQuality->iPBDelta = -1(0xffffffff) offset:size = 64:2
chnAttr->rcAttr->CappedQuality->eRcOptions = 1(0x1) offset:size = 68:4
chnAttr->rcAttr->CappedQuality->uMaxPictureSize = 1920(0x780) offset:size = 72:4
chnAttr->rcAttr->CappedQuality->uMaxPSNR = 48(0x30) offset:size = 76:2
chnAttr->rcAttr->outFrmRate->frmRateNum = 20(0x14) offset:size = 80:4
chnAttr->rcAttr->outFrmRate->frmRateDen = 1(0x1) offset:size = 84:4
chnAttr->gopAttr->uGopCtrlMode = 2(0x2) offset:size = 88:4
chnAttr->gopAttr->uGopLength = 40(0x28) offset:size = 92:2
chnAttr->gopAttr->uNumB = 0(0x0) offset:size = 94:1
chnAttr->gopAttr->uMaxSameSenceCnt = 1(0x1) offset:size = 96:4
chnAttr->gopAttr->bEnableLT = 0(0x0) offset:size = 100:1
chnAttr->gopAttr->uFreqLT = 0(0x0) offset:size = 104:4
chnAttr->gopAttr->bLTRC = 0(0x0) offset:size = 108:1
GROUP 1
	CHANNEL 1     640x  360     START H265 tf:673541     df:112        encdur:33667365, encodingFrameCnt:673429,endencodeFrameCnt=673429,endrelaseFrameCnt=673429,Fps:20.01,Bitrate:95.16
-------------------------------------------------
ch->index = 1
chnAttr->encAttr->eProfile = 16777217(0x1000001) offset:size = 0:4
chnAttr->encAttr->uLevel = 50(0x32) offset:size = 4:1
chnAttr->encAttr->uTier = 1(0x1) offset:size = 5:1
chnAttr->encAttr->uWidth = 640(0x280) offset:size = 6:2
chnAttr->encAttr->uHeight = 360(0x168) offset:size = 8:2
chnAttr->encAttr->ePicFormat = 392(0x188) offset:size = 12:4
chnAttr->encAttr->eEncOptions = 294952(0x48028) offset:size = 16:4
chnAttr->encAttr->eEncTools = 156(0x9c) offset:size = 20:4
chnAttr->rcAttr->rcMode = 8(0x8) offset:size = 44:4
chnAttr->rcAttr->CappedQuality->uTargetBitRate = 135(0x87) offset:size = 48:4
chnAttr->rcAttr->CappedQuality->uMaxBitRate = 180(0xb4) offset:size = 52:4
chnAttr->rcAttr->CappedQuality->iInitialQP = -1(0xffffffff) offset:size = 56:2
chnAttr->rcAttr->CappedQuality->iMinQP = 23(0x17) offset:size = 58:2
chnAttr->rcAttr->CappedQuality->iMaxQP = 51(0x33) offset:size = 60:2
chnAttr->rcAttr->CappedQuality->iIPDelta = -1(0xffffffff) offset:size = 62:2
chnAttr->rcAttr->CappedQuality->iPBDelta = -1(0xffffffff) offset:size = 64:2
chnAttr->rcAttr->CappedQuality->eRcOptions = 1(0x1) offset:size = 68:4
chnAttr->rcAttr->CappedQuality->uMaxPictureSize = 640(0x280) offset:size = 72:4
chnAttr->rcAttr->CappedQuality->uMaxPSNR = 48(0x30) offset:size = 76:2
chnAttr->rcAttr->outFrmRate->frmRateNum = 20(0x14) offset:size = 80:4
chnAttr->rcAttr->outFrmRate->frmRateDen = 1(0x1) offset:size = 84:4
chnAttr->gopAttr->uGopCtrlMode = 2(0x2) offset:size = 88:4
chnAttr->gopAttr->uGopLength = 20(0x14) offset:size = 92:2
chnAttr->gopAttr->uNumB = 0(0x0) offset:size = 94:1
chnAttr->gopAttr->uMaxSameSenceCnt = 1(0x1) offset:size = 96:4
chnAttr->gopAttr->bEnableLT = 0(0x0) offset:size = 100:1
chnAttr->gopAttr->uFreqLT = 0(0x0) offset:size = 104:4
chnAttr->gopAttr->bLTRC = 0(0x0) offset:size = 108:1
	CHANNEL 5     640x  360      STOP JPEG tf:19         df:4          encdur:33235296, encodingFrameCnt:15,endencodeFrameCnt=15,endrelaseFrameCnt=15,Fps:0.00,Bitrate:0.20
-------------------------------------------------
ch->index = 5
chnAttr->encAttr->eProfile = 67108864(0x4000000) offset:size = 0:4
chnAttr->encAttr->uLevel = 0(0x0) offset:size = 4:1
chnAttr->encAttr->uTier = 0(0x0) offset:size = 5:1
chnAttr->encAttr->uWidth = 640(0x280) offset:size = 6:2
chnAttr->encAttr->uHeight = 360(0x168) offset:size = 8:2
chnAttr->encAttr->ePicFormat = 392(0x188) offset:size = 12:4
chnAttr->encAttr->eEncOptions = 294952(0x48028) offset:size = 16:4
chnAttr->encAttr->eEncTools = 156(0x9c) offset:size = 20:4
chnAttr->rcAttr->rcMode = 0(0x0) offset:size = 44:4
chnAttr->rcAttr->FixQP->iInitialQP = 32(0x20) offset:size = 48:2
chnAttr->rcAttr->outFrmRate->frmRateNum = 20(0x14) offset:size = 80:4
chnAttr->rcAttr->outFrmRate->frmRateDen = 1(0x1) offset:size = 84:4
chnAttr->gopAttr->uGopCtrlMode = 2(0x2) offset:size = 88:4
chnAttr->gopAttr->uGopLength = 40(0x28) offset:size = 92:2
chnAttr->gopAttr->uNumB = 0(0x0) offset:size = 94:1
chnAttr->gopAttr->uMaxSameSenceCnt = 1(0x1) offset:size = 96:4
chnAttr->gopAttr->bEnableLT = 0(0x0) offset:size = 100:1
chnAttr->gopAttr->uFreqLT = 0(0x0) offset:size = 104:4
chnAttr->gopAttr->bLTRC = 0(0x0) offset:size = 108:1

@gtxaspec
Copy link
Author

ah, i can see the default settings are simliar:

AtomCam:

chnAttr->rcAttr->rcMode = 8(0x8) offset:size = 44:4
chnAttr->rcAttr->CappedQuality->uTargetBitRate = 720(0x2d0) offset:size = 48:4
chnAttr->rcAttr->CappedQuality->uMaxBitRate = 960(0x3c0) offset:size = 52

Wyze:

chnAttr->rcAttr->rcMode = 8(0x8) offset:size = 44:4
chnAttr->rcAttr->CappedQuality->uTargetBitRate = 720(0x2d0) offset:size = 48:4
chnAttr->rcAttr->CappedQuality->uMaxBitRate = 960(0x3c0) offset:size = 52:4

running the following increases quality from the rtsp stream significantly for:

/system/bin/impdbg --enc_rc_s 0:44:4:2
/system/bin/impdbg --enc_rc_s 0:48:4:4096
/system/bin/impdbg --enc_rc_s 0:52:4:4096

you can run impdbg after you run the commands to verify they have been applied properly. Does this work with ATOM?

@mnakada
Copy link
Owner

mnakada commented May 17, 2022

The setting values have changed, but the RTSP bitrate is still the same.
The image quality does not appear to have changed either.

chnAttr->rcAttr->rcMode = 2(0x2) offset:size = 44:4
chnAttr->rcAttr->Vbr->uTargetBitRate = 4096(0x1000) offset:size = 48:4
chnAttr->rcAttr->Vbr->uMaxBitRate = 4096(0x1000) offset:size = 52:4

Maybe AtomCam has some other setting.

@gtxaspec
Copy link
Author

closing pending more research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants