viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

Video Textures Playback Error #261

Open Murph-Dev opened 5 years ago

Murph-Dev commented 5 years ago

Environment

Please provide the following information about your environment:

  1. OS: Mac
  2. Version: 1.13
  3. Device(s): Pixel (first gen)

Description

I am getting these errors in my Logcat when trying to create multiple Video Textures:

2019-02-22 14:01:45.007 18960-19642/com.trekk.burpeemuseum E/ACodec: Unable to instantiate codec 'OMX.qcom.video.decoder.mpeg4' with err 0xfffffff4.
2019-02-22 14:01:45.007 18960-19642/com.trekk.burpeemuseum E/ACodec: signalError(omxError 0xfffffff4, internalError -12)
2019-02-22 14:01:45.007 18960-19641/com.trekk.burpeemuseum E/MediaCodec: Codec reported err 0xfffffff4, actionCode 0, while in state 1
2019-02-22 14:01:45.029 18960-19636/com.trekk.burpeemuseum E/ExoPlayerImplInternal: Playback error.
    com.google.android.exoplayer2.ExoPlaybackException
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.java:420)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.mpeg4, Format(1, null, video/mp4v-es, -1, null, [320, 200, -1.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
     Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.mpeg4, error 0xfffffff4
        at android.media.MediaCodec.native_setup(Native Method)
        at android.media.MediaCodec.<init>(MediaCodec.java:1811)
        at android.media.MediaCodec.createByCodecName(MediaCodec.java:1792)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:394)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 

I have about 25 image targets that are supposed to play a video when found. (Note: I am only tracking 1 target at a time so there aren't multiple videos playing simultaneously) When the target is found, the video does not play. (Note: Only some of them fail to play. Not all of them.) Does anyone know how I can fix this problem?

Reproducible Demo

Here is what I am doing: In my onRenderCreate() function I am calling this function:

private fun createImageTargets(){
        // Get Video Uri
        val ignUri = Uri.parse("file:///android_asset/IgneousRock.3gp")
        val metaUri = Uri.parse("file:///android_asset/MetamorphicRock.3gp")
        val sediUri = Uri.parse("file:///android_asset/SedimentaryRock.3gp")

        // Debug
        var count = 0
        // debugMarkers: This is an array (String) of filenames for the images that will be the targets
        for(target in debugMarkers){
            count++

            // Get Bitmap
            val bitmap = getBitmapFromAssets(target)

            // Make Targets
            val tar = ARImageTarget(bitmap, ARImageTarget.Orientation.Up, 0.2f)

            // Make Video Textures
            var vTexture: VideoTexture
            when (count % 3) {
                1 -> vTexture = VideoTexture(mViroView.viroContext, metaUri)
                2 -> vTexture = VideoTexture(mViroView.viroContext, sediUri)
                else -> vTexture = VideoTexture(mViroView.viroContext, ignUri)
            }

            // Make AugmentedVideo Object
            val augVid = AugmentedVideo(tar, vTexture, object : VideoListener {
                override fun onVideoFinished(targetId: String) {
                    removeTarget(targetId)
                }
            })

            // Add to AllTargets
            mAllAugmentsMap.put(augVid.getTargetID(), augVid)

            // Add to Valid Targets
            mValidTargets.put(augVid.getTargetID(), augVid)

            // Add to Scene
            mScene.addARImageTarget(augVid.getImageTarget())
        }

    }

Here is the AugmentedVideo Class:

class AugmentedVideo(var target: ARImageTarget, var texture: VideoTexture, var listener: VideoListener, var width: Float = 0.48f, var height: Float = 0.33f) {

    private val node = Node()
    private val material = Material()

    init {
        // Make Quad
        val quad = Quad(width, height)
        // Set Quad as Node Geometry
        node.geometry = quad
        // Set Listener for video texture
        texture.playbackListener = object : VideoTexture.PlaybackListener{
            override fun onVideoUpdatedTime(p0: VideoTexture?, p1: Float, p2: Float) {
                // no-op
            }

            override fun onVideoFinish(p0: VideoTexture?) {
                listener.onVideoFinished(target.id)
            }

            override fun onReady(p0: VideoTexture?) {
                // no-op
            }

            override fun onVideoBufferStart(p0: VideoTexture?) {
                // no-op
            }

            override fun onVideoBufferEnd(p0: VideoTexture?) {
                // no-op
            }

            override fun onVideoFailed(p0: String?) {
                // no-op
            }

        }
        // Set Video Texture to Material
        material.diffuseTexture = texture
        // Set material to node geometry
        node.geometry.materials = Arrays.asList(material)
        // Set Rotation of Node
        node.setRotation(Vector(-1.5f, 0f, 0f))
        // Hide the Node
        node.opacity = 0f
        // Set Visibility
        node.isVisible = true
    }

    /*********** Public Functions ***********/
    fun play(){
        // Make Node Visible
        if(node.opacity == 0f) {
            show()
        }
        if(!texture.isPlaying){
            // Reset Video To Beginning
            texture!!.seekToTime(0.00f)
            // Play Video
            texture!!.play()
        }
    }

    fun stop(){
        // Hide Node
        if(node.opacity == 1f) {
            hide()
        }
            if (texture!!.isPlaying) {
                // Reset Video to Beginning
                texture!!.seekToTime(0.00f)
                // Stop Video
                texture!!.pause()
            }
    }

    /****** Getters/Setters ******/
    fun getImageTarget(): ARImageTarget{
        return target
    }

    fun getImageNode(): Node{
        return node
    }

    fun getTargetID(): String {
        return target.id
    }

    fun setPosition(pos: Vector){
        node.setPosition(pos)
    }

    fun setScale(scale: Vector){
        node.setScale(scale)
    }

    fun setRotation(rot: Vector){
        node.setRotation(rot)
    }

    /*********** Private Functions ***********/
    private fun show(){
        node.opacity = 1f
    }

    private fun hide(){
        node.opacity = 0f
    }
}
Murph-Dev commented 5 years ago

On further examination I found that the video texture hits the onVideoFailed function. The error string reads as follows:

Decoder init failed: OMX.qcom.video.decoder.mpeg4, Format(1, null, video/mp4v-es, -1, null, [320, 180, -1.0], [-1, -1])

The video file I am trying to load is of .3gp format. Any help is appreciated.

dam00n commented 5 years ago

These are the video formats Viro supports -> 'm4v', 'mov', 'mp4', 'mpeg', 'mpg', 'webm'

Can you try converting your .3gp video into something like mp4 and try to see if that works? Here is a link to some online video converter that might help -> https://www.lifewire.com/free-video-converter-programs-and-online-services-2622867

Murph-Dev commented 5 years ago

I converted the videos to mp4 and I am getting the same behavior.

2019-02-25 12:00:55.504 9646-9683/com.trekk.burpeemuseum I/ExoPlayerImpl: Init 4184eeb [ExoPlayerLib/2.7.1] [sailfish, Pixel, Google, 28]
2019-02-25 12:00:55.515 9646-9737/com.trekk.burpeemuseum W/GLConsumer: [SurfaceTexture--1-9646-0] bindTextureImage: clearing GL error: 0x501
2019-02-25 12:00:55.526 9646-9737/com.trekk.burpeemuseum I/Viro: AVPlayer reset
2019-02-25 12:00:55.532 9646-9737/com.trekk.burpeemuseum I/Viro: AVPlayer setting URL to [file:///android_asset/HOMER.mp4]
2019-02-25 12:00:55.533 9646-9737/com.trekk.burpeemuseum I/Viro: AVPlayer prepared for playback
2019-02-25 12:00:55.549 9646-9737/com.trekk.burpeemuseum W/GLConsumer: [SurfaceTexture--1-9646-0] bindTextureImage: clearing GL error: 0x501
2019-02-25 12:00:55.581 9646-10110/com.trekk.burpeemuseum I/OMXClient: IOmx service obtained
2019-02-25 12:00:55.583 9646-10110/com.trekk.burpeemuseum E/ACodec: Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
2019-02-25 12:00:55.583 9646-10110/com.trekk.burpeemuseum E/ACodec: signalError(omxError 0xfffffff4, internalError -12)
2019-02-25 12:00:55.583 9646-10109/com.trekk.burpeemuseum E/MediaCodec: Codec reported err 0xfffffff4, actionCode 0, while in state 1
2019-02-25 12:00:55.585 9646-9737/com.trekk.burpeemuseum W/GLConsumer: [SurfaceTexture--1-9646-0] bindTextureImage: clearing GL error: 0x501
2019-02-25 12:00:55.588 9646-10107/com.trekk.burpeemuseum W/MediaCodec-JNI: try to release MediaCodec from JMediaCodec::~JMediaCodec()...
2019-02-25 12:00:55.588 9646-10107/com.trekk.burpeemuseum W/MediaCodec-JNI: done releasing MediaCodec from JMediaCodec::~JMediaCodec().
2019-02-25 12:00:55.592 9646-10107/com.trekk.burpeemuseum E/ExoPlayerImplInternal: Playback error.
    com.google.android.exoplayer2.ExoPlaybackException
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.java:420)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, video/avc, -1, null, [640, 360, -1.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
     Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
        at android.media.MediaCodec.native_setup(Native Method)
        at android.media.MediaCodec.<init>(MediaCodec.java:1811)
        at android.media.MediaCodec.createByCodecName(MediaCodec.java:1792)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:394)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
2019-02-25 12:00:55.597 9646-9646/com.trekk.burpeemuseum W/Viro: AVPlayer encountered error [com.google.android.exoplayer2.ExoPlaybackException]
    com.google.android.exoplayer2.ExoPlaybackException
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.java:420)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, video/avc, -1, null, [640, 360, -1.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:407) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
     Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
        at android.media.MediaCodec.native_setup(Native Method)
        at android.media.MediaCodec.<init>(MediaCodec.java:1811)
        at android.media.MediaCodec.createByCodecName(MediaCodec.java:1792)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:394)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:898) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:468) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:522) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:305) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 

Its the same few video textures that are failing to load video. Also your documentation states you support .3gp for video textures: Here

Murph-Dev commented 5 years ago

I have created a sample project real quick to show what is going on: Here