Repository navigation
Build error on 1.19.2 #410
Copy link
Copy link
Open
Description
Activity
no
ensureDecodableVideoFormatimport。
android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt missing
`// MIME type reported by MediaExtractor for Dolby Vision tracks (e.g. iPhone .MOV files)
private const val MIMETYPE_VIDEO_DOLBY_VISION = "video/dolby-vision"/**
- Check whether the device exposes a decoder for the given MIME type.
*/
private fun hasDecoderForMime(mime: String): Boolean {
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
for (codec in codecList.codecInfos) {
if (codec.isEncoder) continue
for (type in codec.supportedTypes) {
if (type.equals(mime, ignoreCase = true)) return true
}
}
return false
}
/**
- Resolve the backward-compatible base-layer MIME type for a Dolby Vision track.
- Dolby Vision profiles 8.x (DvheSt) and 4 (DvheDtr) carry an HEVC base layer, and
- profile 9 (DvavSe) carries an AVC base layer; these can be decoded by the standard
- HEVC/AVC decoders. Profiles 5 (DvheStn) and 7 (DvheDtb) have no usable single base
- layer, so they return null. When the profile is unknown we assume HEVC, which covers
- the common consumer case (e.g. iPhone records Dolby Vision profile 8).
*/
private fun dolbyVisionBaseLayerMime(inputFormat: MediaFormat): String? {
if (!inputFormat.containsKey(MediaFormat.KEY_PROFILE)) {
return MediaFormat.MIMETYPE_VIDEO_HEVC
}
return when (inputFormat.getInteger(MediaFormat.KEY_PROFILE)) {
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvavSe -> MediaFormat.MIMETYPE_VIDEO_AVC
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheSt,
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheDtr -> MediaFormat.MIMETYPE_VIDEO_HEVC
else -> null
}
}
/**
- Ensure the input video format can be decoded on this device.
- Some containers (notably iPhone
.MOVfiles) expose the video track as video/dolby-vision. Many Android devices have no Dolby Vision decoder, soMediaCodec.createDecoderByType("video/dolby-vision")fails with NAME_NOT_FOUND.- When the dedicated decoder is missing but the stream carries a backward-compatible
- base layer, this rewrites the format MIME to the base-layer codec so the standard
- HEVC/AVC decoder can decode it. If no compatible decoder exists, it throws a clear
- error instead of letting the cryptic native failure surface (see issue Android:
.MOVvideo compression fails withFailed to initialize video/dolby-vision#398).
*/
fun ensureDecodableVideoFormat(inputFormat: MediaFormat) {
val mime = inputFormat.getString(MediaFormat.KEY_MIME) ?: return
if (hasDecoderForMime(mime)) return
if (mime.equals(MIMETYPE_VIDEO_DOLBY_VISION, ignoreCase = true)) { val fallbackMime = dolbyVisionBaseLayerMime(inputFormat) if (fallbackMime != null && hasDecoderForMime(fallbackMime)) { Log.w( "Compressor", "No Dolby Vision decoder on this device; decoding the $fallbackMime base layer instead." ) inputFormat.setString(MediaFormat.KEY_MIME, fallbackMime) return } throw IllegalStateException( "This video uses Dolby Vision, which is not supported by this device's decoders " + "and has no backward-compatible base layer to fall back to." ) } throw IllegalStateException("No decoder available for video format: $mime")}
}`Reacted by jamalud-lab- Check whether the device exposes a decoder for the given MIME type.
@numandev1 Please fix and issue an update to v1
Last working build for v1 for those who are interested is
1.19.0Reacted by jamalud-labI have pushed #413. Can we please merge it onto the
1.19.2branch.
So you can upload a new version in thev1series.Thanks!
Reacted by Eddie Xie and Srikanth1.19.4Builds with no issue.Safe to close.
Metadata
Metadata
Assignees
Labels
No labels
I don't think the latest push was build checked properly