[Bug]: App crashes or black screen when setting fps = 60
Version
2.6.1
Environment that reproduces the issue
Samsung A35 5G - Android 13 Samsung S20 Plus - Android 13 Samsung S22 Ultra - Android 14
RTMP/SRT/... Server
SRT
Audio configuration
No response
Video configuration
Resolution: 1920x1080 FPS: 60
Is it reproducible in the demos application?
Yes
Reproduction steps
- Use CameraSrtLiveStreamer
- Setting fps = 60 for VideoConfig
- Resolution 1920x1080
Expected result
Livestream 60fps
Actual result
I am using Samsung Galaxy A35 5G phone, which supports FullHD 1080p 60fps video recording, but when I check it in helper only returns a maximum of 30fps (upper), tested both front and rear cameras:
helper.video.getSupportedFramerates(requireContext(), MediaFormat.MIMETYPE_VIDEO_AVC, cameraID)
If I set fps = 60 in VideoConfig, the app will crash or black screen. With fps = 30 everything works fine.
I have also tested on other devices such as Samsung S20 Plus, S22 Ultra and it also only stops at a maximum of 30fps. Please check again for me.
Additional context
No response
Relevant logs output
Hi,
Could you provide the crashtrace and the logcat?
The helper supported fps list comes from CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES.
Hi.
1. Black screen (1920 x 1080, 60fps):
onPreviewFailed: java.security.InvalidParameterException: Failed to find a single FPS range that contains 60
2. Crash (2560 x 1440, 30fps or 2560 x 1440, 60fps):
FATAL EXCEPTION: main
Process: vn.app.golivestream, PID: 30723
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: io.github.thibaultbee.streampack.error.StreamPackError: java.security.InvalidParameterException: Failed to create codec for: {color-format=2130708361, i-frame-interval=1.0, mime=video/avc, width=2560, bitrate=2300000, priority=0, frame-rate=30, height=1440}
at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.configure(BaseStreamer.kt:255)
at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.configure(BaseStreamer.kt:277)
Caused by: java.security.InvalidParameterException: Failed to create codec for: {color-format=2130708361, i-frame-interval=1.0, mime=video/avc, width=2560, bitrate=2300000, priority=0, frame-rate=30, height=1440}
at io.github.thibaultbee.streampack.internal.encoders.MediaCodecHelper.findEncoder(MediaCodecHelper.kt:65)
at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder.createCodec(MediaCodecEncoder.kt:164)
at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder.configure(MediaCodecEncoder.kt:200)
at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.configure(BaseStreamer.kt:250)
at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer.configure(BaseStreamer.kt:277)
Ok, that's 2 different issues.
The first one is thrown by the CameraSource when CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES does not contains 60 fps. This has been changed to just a warning log starting from 3.0. You can already test on branch dev_v3.
It is a crash that comes from the hardware encoder. I don't know why yet.
- Could you provide all the files from your phone
media_codecs*.xml. There are multiple files. In my phone, it is undervendor/etc. It looks like: https://android.googlesource.com/device/google/marlin/+/android-7.1.1_r6/media_codecs.xml - What if you try a lower resolution like 1080p? It is not obvious but for a live, you should avoid really high resolution because your phone won't be able to hold it for a long time due to heat.
Stalled issue. Please open if you need more info.