Closed sinankanmaz closed 2 years ago
Hello,
I am pretty sure your device has a codec that supports AVC/H.264 1280x720...
Have you call controller.create
multiple times? Or setVideoParameters
multiple times ?
Have you try to restart your device before testing ?
Best regards, Thibault
First of all, thank you very much for your answer. I think this error is caused by my device. I would like to share with you the results of the tests I made after opening this issue. Situations with errors on my device:
textureId = _controller.create(initialAudioConfig: config.audio, initialVideoConfig: VideoConfig.withDefaultBitrate());
textureId = _controller.create( initialAudioConfig: config.audio, initialVideoConfig: VideoConfig(bitrate: 60, resolution: Resolution.RESOLUTION_1080), );
3.I get an error when I initialize it as:
textureId = _controller.create( initialAudioConfig: config.audio, initialVideoConfig: VideoConfig(bitrate: 60, resolution: Resolution.RESOLUTION_720), );
No error occurs when I initialize it RESOLUTION_480. I'm thinking of starting it as RESOLUTION_480 initially. Thank you very much.
bitrate: 60
is really really low.
How old is your device?
Could you test this class from StreamPack:
object Video {
/**
* Get supported video encoders list
*/
val supportedEncoders = getSupportedMediaCodecEncoders()
/**
* Get device video encoder list.
*
* @return list of supported video encoder
*/
private fun getSupportedMediaCodecEncoders(): List<String> {
val encoders = mutableListOf<String>()
MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos
.filter { it.isEncoder }
.flatMap { it.supportedTypes.toList() }
.filter { it.isVideo() }
.distinct()
.forEach { encoders.add(it) }
return encoders
}
/**
* Get video encoder video capabilities.
*
* @param mimeType video encoder mime type
* @return encoder video capabilities
*/
private fun getCapabilities(mimeType: String): MediaCodecInfo.VideoCapabilities {
require(mimeType.isVideo()) { "MimeType must be video" }
val format = MediaFormat().apply { setString(MediaFormat.KEY_MIME, mimeType) }
val mediaCodecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
val encoderName = mediaCodecList.findEncoderForFormat(format)
val mediaCodec = MediaCodec.createByCodecName(encoderName)
val videoCapabilities = mediaCodec.codecInfo.getCapabilitiesForType(
mimeType
).videoCapabilities
mediaCodec.release()
return videoCapabilities
}
/**
* Get video encoder supported heights.
*
* @param mimeType video encoder mime type
* @return range of supported heights
*/
fun getSupportedHeights(mimeType: String): Range<Int> =
getCapabilities(mimeType).supportedHeights
/**
* Get video encoder supported widths.
*
* @param mimeType video encoder mime type
* @return range of supported widths
*/
fun getSupportedWidths(mimeType: String): Range<Int> =
getCapabilities(mimeType).supportedHeights
/**
* Get video encoder supported frame rate range.
*
* @param mimeType video encoder mime type
* @return range of frame in b/s
*/
fun getFramerateRange(mimeType: String): Range<Int> =
getCapabilities(mimeType).supportedFrameRates
/**
* Get video encoder supported bitrate.
*
* @param mimeType video encoder mime type
* @return range of bitrate in b/s
*/
fun getBitrateRange(mimeType: String): Range<Int> =
getCapabilities(mimeType).bitrateRange
}
with mimeType = MediaFormat.MIMETYPE_VIDEO_AVC
Could you get supported height, width, framerate range, bitrate range and capabilities?
The problem here is not with the bitrate. It also works fine when I enter a higher value for Bitrate. It's only a problem when the resolution is higher than 480. Is there a bitrate you recommend? I can enter any value I want here.
Then, use the default bitrate from VideoConfig.withDefaultBitrate
initialVideoConfig: VideoConfig.withDefaultBitrate(resolution: Resolution.RESOLUTION_480),
It worked great this way. Thanks
I get an error as soon as the controller.create method runs on Android. The error is as follows:
PlatformException (PlatformException(failed_to_create_live_stream, java.security.InvalidParameterException: Failed to create unknown codec for: {mime=video/avc, width=720, height=1280}, null, null))
This also occurs when I clone and run the example project or run my own project.