简体   繁体   English

正在下载缺少的编解码器?

[英]Downloading a missing codec?

I am facing an issue where i am unable to download codec for some random media files. 我遇到无法下载某些随机媒体文件的编解码器的问题。 i was hoping there was a way i could tell the android OS to download the respected codec inorder to play the file ? 我希望有一种方法可以告诉android OS下载受尊敬的编解码器以播放文件? right now i am using https://github.com/brianwernick/ExoMedia player which is some kind of fork of exoPlayer for android. 现在我正在使用https://github.com/brianwernick/ExoMedia播放器,它是exoPlayer for Android的一种分支。 and i it does not support a codec and will only play audio or nothing. 而且我不支持编解码器,只会播放音频或什么都不会播放。 how can i get it (or even the OS) to download the missing codec ? 我如何获取(甚至是操作系统)下载缺少的编解码器?

here is the mp4 file codec info that will not play on many devices that i wish to solve: 这是我想解决的许多设备上无法播放的mp4文件编解码器信息:

在此处输入图片说明

the code itself is trivial: 代码本身很简单:

 class MediaPlayerActivity : AppCompatActivity(), OnPreparedListener {

    private var uri: String = ""

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_media_player)
        uri = intent.getStringExtra("uri")

        setupVideoView(uri)
    }

    private fun setupVideoView(uri: String) {
        videoView.setOnPreparedListener(this)
        videoView.setVideoURI(Uri.parse(uri))
    }

    override fun onPrepared() {
        //Starts the video playback as soon as it is ready
        videoView.start()
    }

}

and respectively the xml file: 以及相应的xml文件:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black">

    <com.devbrackets.android.exomedia.ui.widget.VideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:useDefaultControls="true" />

</RelativeLayout>

i also installed mx player on the android device and mx player did not offer to install a codec. 我还在android设备上安装了mx播放器,而mx播放器不提供安装编解码器。 instead it played just hte audio, no visual. 相反,它只播放音频,没有视觉效果。 also if i open the mp4 in chrome it plays fine. 另外,如果我在Chrome中打开mp4,播放效果会很好。

You are trying to play a UHD (2160x3840) video encoded in H.264 on a variety of devices. 您正在尝试在各种设备上播放以H.264编码的UHD(2160x3840)视频。 This is a bad idea as each device has a upper limit of what it can decode reasonably even with hardware decode. 这是一个坏主意,因为即使使用硬件解码,每个设备都具有可以合理解码的上限。 This would explain why you can hear audio but not see anything. 这可以解释为什么您可以听到音频但看不到任何声音。

The general solution is to deliver an appropriated encoded video for the target client. 通用解决方案是为目标客户端提供适当的编码视频。 By implication it means that you aren't delivering a larger than necessary file/stream should the end user be on a metered data connection. 暗含的意思是,如果最终用户处于计量数据连接中,则您传送的文件/流不会大于所需的大小。

The Android site has size/format recommendations: Android网站有尺寸/格式建议:

https://developer.android.com/guide/topics/media/media-formats https://developer.android.com/guide/topics/media/media-formats

but real details are listed in the Android Compatibility Definition Document (CDD) 但实际详细信息在Android兼容性定义文档(CDD)中列出

You should transcode your video into a set of files of the appropriate codecs & bitrates for the customers you are expecting and deliver according. 您应该将视频transcode成一组适合您期望并交付的适当编解码器和比特率的文件。 For example if the file is for high end devices with UHD screens, as determined by Display.getSupportedModes() then you should be encoding the video in either H.265 or VP9 at 20 Mbps. 例如,如果文件用于具有UHD屏幕的高端设备Display.getSupportedModes()Display.getSupportedModes()确定Display.getSupportedModes()则您应该以20 Mbps的速度在H.265或VP9中对视频进行编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM