Android:无法播放mp4视频

发布于 2024-12-22 14:15:31 字数 4502 浏览 2 评论 0原文

我正在尝试使用本机 VideoView 从服务器播放 mp4 视频流,遗憾的是我不断收到“无法播放视频”错误。

奇怪的是,同一个视频在 Froyo 上播放得很好,但在 HoneyComb 上却无法播放。 我用 MX Video Player(在 HC 上)尝试了相同的视频,它播放得很好。

另一个主要问题是我无法重新编码视频,所以我必须按原样使用视频。

  • 是什么导致了错误?
  • 我怎样才能播放视频?
  • 我应该找到一种方法将编解码器库包含到我的应用程序中吗?

以下是 logcat 的详细信息:

E/MediaExtractor(  242): **********MediaExtractor::Create
D/DivXPlugin(  241): DivXPlugin::onInitialize : 75
D/DivXPlugin(  241): DivXPlugin::onSetOnInfoListener : 75
D/DivXPlugin(  241): DivXPlugin::onOpenDecryptSession: Enter : 75
E/DivXPlugin(  241): DivXPlugin::onOpenDecryptSession() Not a Divx File.
E/DrmManager(Native)(  241): DrmManager::openDecryptSession: no capable plug-in found
D/DivXPlugin(  241): DivXPlugin::onTerminate : 75
E/MediaExtractor(  242): ************Autodetected media content as 'video/mpeg4' with confidence 0.40
D/AwesomePlayer(  242): finishSetDataSource_l getDrmInfo
D/AwesomePlayer(  242): setDataSource_l
E/MPEG4Extractor(  242): ftyp chunk found
D/MPEG4Extractor(  242): kKeyAVCC found
E/MPEG4Extractor(  242): ERROR_MALFORMED because ret=-108
E/MPEG4Extractor(  242): return ERROR_UNSUPPORTED
E/MPEG4Extractor(  242): return ERROR_UNSUPPORTED
D/AwesomePlayer(  242): UNKNOWN_ERROR: no Video and no Audio
D/AwesomePlayer(  242): abortPrepare
D/AwesomePlayer(  242): notifyListener_l
E/MediaPlayer( 3906): error (1, -2147483648)
E/MediaPlayer( 3906): Error (1,-2147483648)
D/VideoView( 3906): Error: 1,-2147483648

以及无法播放的视频的规格:

    General
    Format                           : MPEG-4
    Format profile                   : Base Media
    Codec ID                         : isom
    File size                        : 60.7 MiB
    Duration                         : 7mn 3s
    Overall bit rate mode            : Variable
    Overall bit rate                 : 1 201 Kbps
    Writing application              : Lavf52.37.0

    Video
    ID                               : 1
    Format                           : AVC
    Format/Info                      : Advanced Video Codec
    Format profile                   : [email protected]
    Format settings, CABAC           : Yes
    Format settings, ReFrames        : 4 frames
    Codec ID                         : avc1
    Codec ID/Info                    : Advanced Video Coding
    Duration                         : 7mn 3s
    Duration_FirstFrame              : 40ms
    Bit rate                         : 1 072 Kbps
    Width                            : 1 024 pixels
    Height                           : 576 pixels
    Display aspect ratio             : 16:9
    Frame rate mode                  : Constant
    Frame rate                       : 25.000 fps
    Color space                      : YUV
    Chroma subsampling               : 4:2:0
    Bit depth                        : 8 bits
    Scan type                        : Progressive
    Bits/(Pixel*Frame)               : 0.073
    Stream size                      : 54.2 MiB (89%)
    Writing library                  : x264 core 65 r0+1016 dbc5ef0
    Encoding settings                : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=8 / psy_rd=1.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-2 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=16 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / keyint=125 / keyint_min=25 / scenecut=40(pre) / rc=2pass / bitrate=1072 / ratetol=1.0 / qcomp=0.80 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.41 / pb_ratio=1.25 / aq=1:1.00
    Language                         : English

    Audio
    ID                               : 2
    Format                           : AAC
    Format/Info                      : Advanced Audio Codec
    Format profile                   : LC
    Codec ID                         : 40
    Duration                         : 7mn 3s
    Bit rate mode                    : Variable
    Bit rate                         : 122 Kbps
    Channel(s)                       : 2 channels
    Channel positions                : Front: L R
    Sampling rate                    : 48.0 KHz
    Compression mode                 : Lossy
    Stream size                      : 6.18 MiB (10%)
    Language                         : English

I'm trying to play mp4 videos streaming from a server using native VideoView, sadly I keep getting a "Cannot play video" error.

The weird thing is that the same video plays well on Froyo but will not play on HoneyComb.
I tried the same video with MX Video Player (on HC) and it plays just fine.

Another major problem is that I cannot re-encode the videos, so I have to use the videos as they are.

  • What is causing the error?
  • How can I play the video?
  • Should I find a way to include a codec library into my app?

Below are details from logcat:

E/MediaExtractor(  242): **********MediaExtractor::Create
D/DivXPlugin(  241): DivXPlugin::onInitialize : 75
D/DivXPlugin(  241): DivXPlugin::onSetOnInfoListener : 75
D/DivXPlugin(  241): DivXPlugin::onOpenDecryptSession: Enter : 75
E/DivXPlugin(  241): DivXPlugin::onOpenDecryptSession() Not a Divx File.
E/DrmManager(Native)(  241): DrmManager::openDecryptSession: no capable plug-in found
D/DivXPlugin(  241): DivXPlugin::onTerminate : 75
E/MediaExtractor(  242): ************Autodetected media content as 'video/mpeg4' with confidence 0.40
D/AwesomePlayer(  242): finishSetDataSource_l getDrmInfo
D/AwesomePlayer(  242): setDataSource_l
E/MPEG4Extractor(  242): ftyp chunk found
D/MPEG4Extractor(  242): kKeyAVCC found
E/MPEG4Extractor(  242): ERROR_MALFORMED because ret=-108
E/MPEG4Extractor(  242): return ERROR_UNSUPPORTED
E/MPEG4Extractor(  242): return ERROR_UNSUPPORTED
D/AwesomePlayer(  242): UNKNOWN_ERROR: no Video and no Audio
D/AwesomePlayer(  242): abortPrepare
D/AwesomePlayer(  242): notifyListener_l
E/MediaPlayer( 3906): error (1, -2147483648)
E/MediaPlayer( 3906): Error (1,-2147483648)
D/VideoView( 3906): Error: 1,-2147483648

And the specs of the video that cannot be played:


    General
    Format                           : MPEG-4
    Format profile                   : Base Media
    Codec ID                         : isom
    File size                        : 60.7 MiB
    Duration                         : 7mn 3s
    Overall bit rate mode            : Variable
    Overall bit rate                 : 1 201 Kbps
    Writing application              : Lavf52.37.0

    Video
    ID                               : 1
    Format                           : AVC
    Format/Info                      : Advanced Video Codec
    Format profile                   : [email protected]
    Format settings, CABAC           : Yes
    Format settings, ReFrames        : 4 frames
    Codec ID                         : avc1
    Codec ID/Info                    : Advanced Video Coding
    Duration                         : 7mn 3s
    Duration_FirstFrame              : 40ms
    Bit rate                         : 1 072 Kbps
    Width                            : 1 024 pixels
    Height                           : 576 pixels
    Display aspect ratio             : 16:9
    Frame rate mode                  : Constant
    Frame rate                       : 25.000 fps
    Color space                      : YUV
    Chroma subsampling               : 4:2:0
    Bit depth                        : 8 bits
    Scan type                        : Progressive
    Bits/(Pixel*Frame)               : 0.073
    Stream size                      : 54.2 MiB (89%)
    Writing library                  : x264 core 65 r0+1016 dbc5ef0
    Encoding settings                : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=8 / psy_rd=1.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-2 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=16 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / keyint=125 / keyint_min=25 / scenecut=40(pre) / rc=2pass / bitrate=1072 / ratetol=1.0 / qcomp=0.80 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.41 / pb_ratio=1.25 / aq=1:1.00
    Language                         : English

    Audio
    ID                               : 2
    Format                           : AAC
    Format/Info                      : Advanced Audio Codec
    Format profile                   : LC
    Codec ID                         : 40
    Duration                         : 7mn 3s
    Bit rate mode                    : Variable
    Bit rate                         : 122 Kbps
    Channel(s)                       : 2 channels
    Channel positions                : Front: L R
    Sampling rate                    : 48.0 KHz
    Compression mode                 : Lossy
    Stream size                      : 6.18 MiB (10%)
    Language                         : English

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

子栖 2024-12-29 14:15:31

问题可能出在视频编码上。 Android FROYO 和 Gingerbread 不支持除“Baseline”H264 之外的 H264 格式。 H264 编码确保其“AVC 基线”编码。使用 Windows/Linux 中的“媒体信息”等工具并检查您的视频编码。

The problem might be with the video encoding. Android FROYO and Gingerbread doesn't support H264 formats other than "Baseline" H264. So if your video is Mp4 & H264 encoded make sure its "AVC baseline" encoded. Use some tools like "Media info" in windows/Linux and check your video encoding.

时常饿 2024-12-29 14:15:31

一些 Froyo 设备(例如 Samsung Galaxy Tab)使用 OpenCore 媒体框架,而其他设备则使用 Stagefright。从姜饼所有设备到我的知识使用 Stagefright。所以这也许可以解释你的经历。

通过 HTTP 或 RSTP 播放时,视频容器存在其他限制。

来自开发人员文档:

对于 3GPP 和 MPEG-4 容器,moov 原子必须位于任何 mdat 之前
原子,但必须在 ftyp 原子之后。

Some Froyo devices (e.g., Samsung Galaxy Tab) use the OpenCore mediaframework while others use Stagefright. From gingerbread all devices to my knowledge use Stagefright. So this could maybe explain your experience.

When playing over HTTP or RSTP there are additional constraints for the video container.

from the developer docs:

For 3GPP and MPEG-4 containers, the moov atom must precede any mdat
atoms, but must succeed the ftyp atom.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文