我正在尝试播放在TextureView
上呈现的mp4视频,它正在使用API LEVEL> = 21(在Lollipop之后),但在以前的版本中它没有播放。我在logcat中遇到以下错误:error (1, -2147483648)
。我认为这是一个未知的错误(据我所知)。
该文件从assets文件夹加载。
private MediaPlayer mMediaPlayer;
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
TextureView textureView = (TextureView) findViewById(R.id.textureView);
textureView.setSurfaceTextureListener(this);
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture txtSurface, final int width, final int height) {
Surface surface = new Surface(txtSurface);
mMediaPlayer = new MediaPlayer();
AssetFileDescriptor afd = getAssets().openFd("video/test.mp4");
mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
mMediaPlayer.setSurface(surface);
mMediaPlayer.setLooping(false);
mMediaPlayer.setVolume(0f, 0f);
mMediaPlayer.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaPlayer.start();
}
});
mMediaPlayer.prepareAsync();
}
表面尺寸为:768x1280,视频尺寸为:350x500像素。我还试图调整不同大小的视频(创建新视频)的大小:768x1280,1080x1920和4k。是什么导致错误?宽高比或不同的设备/视频分辨率?
我正在准备文件时在logcat中收到以下消息:
04-30 17:56:01.752 432-432/? V/FFmpegExtractor: SniffFFMPEG
04-30 17:56:01.752 432-432/? I/FFmpegExtractor: android-source:0xb83b8e00
04-30 17:56:01.752 432-432/? D/FFMPEG: android source begin open
04-30 17:56:01.752 432-432/? D/FFMPEG: android open, url: android-source:0xb83b8e00
04-30 17:56:01.752 432-432/? D/FFMPEG: ffmpeg open android data source success, source ptr: 0xb83b8e00
04-30 17:56:01.752 432-432/? D/FFMPEG: android source open success
04-30 17:56:01.800 432-432/? I/FFMPEG: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'android-source:0xb83b8e00':
04-30 17:56:01.800 432-432/? I/FFMPEG: Metadata:
04-30 17:56:01.800 432-432/? I/FFMPEG: major_brand : mp42
04-30 17:56:01.800 432-432/? I/FFMPEG: minor_version : 0
04-30 17:56:01.800 432-432/? I/FFMPEG: compatible_brands: mp42mp41
04-30 17:56:01.800 432-432/? I/FFMPEG: creation_time : 2017-04-30 21:22:53
04-30 17:56:01.800 432-432/? I/FFMPEG: Duration: 00:00:29.50, start: 0.000000, bitrate: 2522 kb/s
04-30 17:56:01.800 432-432/? I/FFMPEG: Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 350x500, 2517 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
04-30 17:56:01.800 432-432/? I/FFMPEG: Metadata:
04-30 17:56:01.800 432-432/? I/FFMPEG: creation_time : 2017-04-30 21:22:53
04-30 17:56:01.800 432-432/? I/FFMPEG: handler_name : Alias Data Handler
04-30 17:56:01.800 432-432/? I/FFmpegExtractor: FFmpegExtrator, url: android-source:0xb83b8e00, format_name: mov,mp4,m4a,3gp,3g2,mj2, format_long_name: QuickTime / MOV
04-30 17:56:01.800 432-432/? I/FFmpegExtractor: list the formats suppoted by ffmpeg:
04-30 17:56:01.800 432-432/? I/FFmpegExtractor: ========================================
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[00]: mpeg
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[01]: mpegts
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[02]: mov,mp4,m4a,3gp,3g2,mj2
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[03]: matroska,webm
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[04]: asf
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[05]: rm
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[06]: flv
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[07]: swf
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[08]: avi
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[09]: ape
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[10]: dts
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[11]: flac
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[12]: ac3
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[13]: wav
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[14]: ogg
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[15]: vc1
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: format_names[16]: hevc
04-30 17:56:01.800 432-432/? I/FFmpegExtractor: ========================================
04-30 17:56:01.800 432-432/? V/FFmpegExtractor: major_brand tag is:mp42
04-30 17:56:01.800 432-432/? D/FFmpegExtractor: suppoted codec(h264) by official Stagefright
04-30 17:56:01.800 432-432/? D/FFMPEG: android source close
04-30 17:56:01.800 432-432/? I/FFmpegExtractor: sniff through BetterSniffFFMPEG success
04-30 17:56:01.800 432-432/? D/FFmpegExtractor: ffmpeg detected media content as 'video/mp4' with confidence 0.08
04-30 17:56:01.804 432-432/? I/SampleTable: There are reordered frames present.
04-30 17:56:01.816 432-15591/? I/OMXCodec: [OMX.google.h264.decoder] AVC profile = 77 (Main), level = 31
04-30 17:56:01.816 432-15591/? I/OMXCodec: [OMX.google.h264.decoder] video dimensions are 320 x 240
04-30 17:56:01.816 432-15591/? I/OMXCodec: [OMX.google.h264.decoder] Crop rect is 320 x 240 @ (0, 0)
视频是使用Adobe After Effects
创建的,并保存为.AVI
文件,然后导入Adobe Premier Pro
并导出到.mp4
(H.264)
答案 0 :(得分:0)
看起来导出的文件没有有效的配置文件。 listed media formats显示唯一支持的配置文件是H.264的基线配置文件。
要添加基准配置文件,您需要通过下载ffmpeg并使用以下命令行创建新的mp4文件来添加它:
ffmpeg.exe -i your_file.mp4 -c:v libx264 -profile:v baseline -level 1 new_file_name.mp4