2011-12-22 195 views
5

我试图发挥MP4视频使用本地VideoView从服务器流,可悲的是我不断收到一个“无法播放视频”的错误。安卓:不能播放MP4视频

奇怪的是,相同的视频在Froyo上播放不错,但不会在HoneyComb上播放。 我尝试了与MX视频播放器(在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 

+0

我正在考虑添加ffmpeg库到我的应用程序,但我对android NDK知之甚少。任何人都有提示或链接提供? – sebataz 2012-01-10 10:44:51

回答

0

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

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

从显影剂文档:

对于3GPP和MPEG-4容器,该MOOV原子必须先于任何的mdat原子 ,但必须成功的FTYP原子。

1

问题可能出在视频编码上。 Android FROYO和姜饼不支持除“基准”H264以外的H264格式。所以如果你的视频是MP4 4 & H264编码确保其“AVC基线”编码。在Windows/Linux中使用一些工具,如“媒体信息”,并检查您的视频编码。