FFmpegMediaMetadataRetriever from External Storage? Android Studio/Kotlin

-1

So I'm making my first Android app and I'm trying to get it to allow the user to pick a video from their gallery before seeing the video and the video's current details in the next activity. My problem is that when I use FFmpegMediaMetadataRetriever and pass it the video's filepath, I receive the error java.lang.IllegalArgumentException: setDataSource failed: status = 0xFFFFFFFF. I've heard through the grapevine that this means my filepath is invalid. When I Log.d the filepath, I get content://media/external/file/3565, which to me looks like a proper filepath! I hope somebody can help me figure this out.

Here is my activity class for context:

class NewProject : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_new_project)

        val videoPath = intent.getStringExtra("video")
        initVideo(videoPath)

        backButtonText.setOnClickListener{ goBack() }
    }

    private fun goBack() {
        val intent = Intent(this,MainActivity::class.java)
        startActivity(intent)
    }

    private fun initVideo(videoPath:String) {
        newProjVideoView.setVideoPath(videoPath)
        newProjVideoView.start()
        newProjVideoView.setOnCompletionListener {
            newProjVideoView.pause()
        }
        getVideoMetadata(videoPath)
    }

    private fun getVideoMetadata(videoPath: String) {
        try {
            e("videoPath", videoPath)
            val receiver = FFmpegMediaMetadataRetriever()
            receiver.setDataSource(videoPath)

        } catch (e:IOException) {
            e("retrieve1","There was an issue", e)
        }
    }
}

I'm also happy to hear any constructive feedback on my code! Please, thank you and have a nice day!

android
android-ffmpeg
mediametadataretriever
asked on Stack Overflow Jun 1, 2019 by Cal Courtney • edited Jun 1, 2019 by Zoe

1 Answer

0

So, I think my issue stemmed from trying to pass the video through an intent and then running the MetadataRetriever. I solved it by getting all the info in the previous activity before passing each value as an extra to be used on the next screen.

answered on Stack Overflow Jun 1, 2019 by Cal Courtney

User contributions licensed under CC BY-SA 3.0