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

Failed to initialize video/dolby-vision, error 0xfffffffe (NAME_NOT_FOUND) #211

Open
soroa opened this issue Feb 7, 2025 · 0 comments
Open

Comments

@soroa
Copy link

soroa commented Feb 7, 2025

Stacktrace

 Unexpected error while transcoding. (Ask Gemini)
                                                                                                    java.lang.IllegalArgumentException: Failed to initialize video/dolby-vision, error 0xfffffffe (NAME_NOT_FOUND)
                                                                                                    	at android.media.MediaCodec.native_setup(Native Method)
                                                                                                    	at android.media.MediaCodec.<init>(MediaCodec.java:2154)
                                                                                                    	at android.media.MediaCodec.<init>(MediaCodec.java:2132)
                                                                                                    	at android.media.MediaCodec.createDecoderByType(MediaCodec.java:2069)
                                                                                                    	at com.otaliastudios.transcoder.internal.codec.Decoder.<init>(Decoder.kt:43)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.PipelinesKt.VideoPipeline$lambda$1(pipelines.kt:62)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.PipelinesKt.$r8$lambda$m1rlbwqPaEygFy8BQNNSagwe4_w(Unknown Source:0)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.PipelinesKt$$ExternalSyntheticLambda1.invoke(Unknown Source:12)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.Pipeline$Companion.build$lib_release(Pipeline.kt:169)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.PipelinesKt.VideoPipeline(pipelines.kt:60)
                                                                                                    	at com.otaliastudios.transcoder.internal.pipeline.PipelinesKt.RegularPipeline(pipelines.kt:48)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.DefaultTranscodeEngine.createPipeline(DefaultTranscodeEngine.kt:83)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.DefaultTranscodeEngine.access$createPipeline(DefaultTranscodeEngine.kt:27)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.DefaultTranscodeEngine$segments$1.invoke(DefaultTranscodeEngine.kt:42)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.DefaultTranscodeEngine$segments$1.invoke(DefaultTranscodeEngine.kt:42)
                                                                                                    	at com.otaliastudios.transcoder.internal.Segments.tryCreateSegment(Segments.kt:87)
                                                                                                    	at com.otaliastudios.transcoder.internal.Segments.next(Segments.kt:46)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.DefaultTranscodeEngine.transcode(DefaultTranscodeEngine.kt:114)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.TranscodeEngine$Companion.transcode(TranscodeEngine.kt:48)
                                                                                                    	at com.otaliastudios.transcoder.internal.transcode.TranscodeEngine.transcode(Unknown Source:2)
                                                                                                    	at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:102)
                                                                                                    	at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:99)
                                                                                                    	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
2025-02-07 10:52:48.486  9692-9692  <no-tag>                <package-name>              E  Transcoding for content://com.google.android.apps.docs.storage.legacy/enc%3Dencoded%3DW0Q7pRNUU33m6n98tAFuukNHbP3oKVm9OIHRCUrI2Cfll5wc9TDP3qlZgCGCoQ%3D%3D failed with exception: java.lang.IllegalArgumentException: Failed to initialize video/dolby-vision, error 0xfffffffe (NAME_NOT_FOUND)
2025-02-07 10:52:48.674  9692-12632 MediaMetad...trieverJNI <package-name>               E  getFrameAtTime: videoFrame is a NULL pointer
2025-02-07 10:52:48.675  9692-12632 MediaMetad...trieverJNI <package-name>               E  getFrameAtTime: videoFrame is a NULL pointer
2025-02-07 10:52:48.683  9692-12632 MediaMetad...trieverJNI <package-name>               E  getFrameAtTime: videoFrame is a NULL pointer

File

https://drive.google.com/file/d/1_LPev08GL2u41zPvKHYsviIJzjPlbVRG/view?usp=drive_link

Code

    /**
     * Sets the profile to AVCProfileBaseline for compatibility with older devices.
     * [DefaultVideoStrategy] does not allow to set the output profile, so we need to override
     * this method to set it manually.
     */
    override fun createOutputFormat(inputFormats: MutableList<MediaFormat>, outputFormat: MediaFormat): TrackStatus {
        val result = super.createOutputFormat(inputFormats, outputFormat)
        outputFormat.setInteger(MediaFormat.KEY_PROFILE, CodecProfileLevel.AVCProfileBaseline)
        val supportedLevel = getSupportedAVCLevel()
        if (supportedLevel != null) {
            outputFormat.setInteger(MediaFormat.KEY_LEVEL, supportedLevel)
        }
        return result
    }

    /**
     * Checks the highest supported AVC level.
     * AVC level 4.1 is a widely supported level.
     * @return AVC level 4.1 or `null` if no compatible level is found
     */
    private fun getSupportedAVCLevel(): Int? =
        MediaCodecList(MediaCodecList.ALL_CODECS).codecInfos
            .filter { it.isAVCVideoEncoder() }
            .flatMap { it.getAVCProfileLevels() }
            .firstOrNull { level ->
                level >= SUPPORTED_AVC_LEVEL
            }

    private fun MediaCodecInfo.isAVCVideoEncoder() =
        isEncoder &&
            supportedTypes.any { it.startsWith("video/") } &&
            supportedTypes.contains(MediaFormat.MIMETYPE_VIDEO_AVC)

    /**
     * Retrieves the list of supported AVC profile levels for a given codec.
     */
    private fun MediaCodecInfo.getAVCProfileLevels(): List<Int> {
        return getCapabilitiesForType(MediaFormat.MIMETYPE_VIDEO_AVC)
            .profileLevels
            .filter { it.profile == CodecProfileLevel.AVCProfileBaseline }
            .map { it.level }
    }

    companion object {
        private const val MAX_DIMENSION_ALLOWED = 1280
        private const val BIT_RATE = 3 * 1024 * 1024L // 3 Mbps
        private const val FRAME_RATE = 30
        private const val SUPPORTED_AVC_LEVEL = CodecProfileLevel.AVCLevel41
    }

What I've tried

  • I've tried forcing the mime type to be "videos/avc" but no luck
        for (format in inputFormats) {
            val mime = format.getString(MediaFormat.KEY_MIME)
            logDev("mime: $mime")
            if (mime == "video/dolby-vision") {
                logDev("Dolby Vision detected. Changing input format to H.264")
            // Force input format to H.264 (This prevents the Dolby Vision decoder from being used)
            format.setString(MediaFormat.KEY_MIME, "video/avc")
            }
        }
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

1 participant