Addressing Snowing (Static Noise) and Enhancing Video Quality/Size in Our App

83 views
Skip to first unread message

Oleg Ator

unread,
Nov 23, 2023, 2:56:58 PM11/23/23
to Android CameraX Discussion Group

Hi team,


We have a video recording feature in our app. However, the output quality is not very well. It is quite snowing(static noise) even with the default setup in which we got from: https://github.com/android/camera-samples/blob/main/CameraXVideo/app/src/main/java/com/example/android/camerax/video/fragments/CaptureFragment.kt


val rotation = binding.cameraPreview.display.rotation


val resolutionSelector = ResolutionSelector.Builder()
.setAspectRatioStrategy(AspectRatioStrategy(screenAspectRatio, AspectRatioStrategy.FALLBACK_RULE_AUTO))
.build()


val recorder = Recorder.Builder()
.setQualitySelector(qualitySelector)
.setTargetVideoEncodingBitRate(2500000)
.build()


videoCapture = VideoCapture.Builder(recorder)
.setResolutionSelector(resolutionSelector)
.setTargetRotation(rotation)
.build()


In addition to that, video size is being enormous unless we set maximum bitrate. However, while setting a bitrate constraint helps us reduce the video size, but quality is becoming even worse. I am attaching a video sample so you can also check. Do you know how do I get good quality videos while maintaining the size?


Thanks!

Leo Huang

unread,
Nov 23, 2023, 11:16:05 PM11/23/23
to Oleg Ator, Android CameraX Discussion Group
Hi,
For video size, please remove the call VideoCapture.setResolutionSelector() since it isn't a public API and may cause conflict to Recorder.Builder().setQualitySelector().
You can also remove the setQualitySelector() call which will result in the default QualitySelector being used.

For video quality, to achieve optimal video quality, CameraX will automatically utilize the manufacturer's predefined video settings (from CamcorderProfile) when only the QualitySelector is specified, ensuring the best possible recording experience across a range of devices. However, if video quality is unsatisfactory on a particular device, manual adjustments (ex: smaller Quality or a different bit rate) may be necessary. Please feel free to report any problems you may experience.

Oleg Ator <o.str...@gmail.com> 於 2023年11月24日 週五 上午3:57寫道:
--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/6c192323-ddb4-4ad1-a1ce-9fd2c8c2b7e4n%40android.com.
Message has been deleted

Oleg Ator

unread,
Nov 24, 2023, 4:46:34 PM11/24/23
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group

Hello,


Video quality has been improved but video size is still big than it should be(in accordance with our app's requirement). For instance, 1min video is around 20MB but we'd still like to reduce it a bit more, tho. To do so, we set a maximum bitrate of 250000 via


val recorder = Recorder.Builder()
.setTargetVideoEncodingBitRate(2500000)
.build()


and it helped but we wonder if it is possible to have much smaller videos while maintaining quality. We'd like to know what is the best approach;


* Either removing setTargetVideoEncodingBitRate completely
* Or set a smaller bitrate


Thanks

Leo Huang

unread,
Nov 26, 2023, 9:46:36 PM11/26/23
to Oleg Ator, Android CameraX Discussion Group
The most straightforward way is by lowering the resolution such as using Quality.SD.
Even adjust the bitrate to be more appropriate based on the resolution.
Adjusting the frame rate to a minimum acceptable value, such as 24fps.
Choosing a more efficient codec is also a solution, but currently there is no API to set the codec type. It can still be done by post-editing. Such as using media3-transformer.

Oleg Ator <o.str...@gmail.com> 於 2023年11月25日 週六 上午5:46寫道:

Oleg Ator

unread,
Dec 3, 2023, 4:39:46 PM12/3/23
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group
Praise to this group and thanks for the answer. However, unfortunately, your advices didn't help to reduce the size. What else can be done?
vid_1701282300666.mp4
Reply all
Reply to author
Forward
0 new messages