divx4linux,android - Can we play H264 videos in exoplayer? - Stack Overflow

在尝试使用ExoPlayer在Android上流式传输H264格式的MP4视频时遇到问题,视频无法播放。代码显示ExoPlayer似乎在下载但不播放视频或音频。日志中出现关于不识别的视频配置文件和不支持的mime类型的警告。寻求解答ExoPlayer是否支持这种格式以及如何解决播放问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I am trying to stream live video in android. Details - H264 - Mp4 format - demuxed.

z3Z4F.jpg

I am using this code

Questions:

Can i play video of this format in exoplayer?

Which library should i use to stream live video?

Code to play a video using Exoplayer

{

Handler mainHandler = new Handler();

BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);

TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

LoadControl loadControl = new DefaultLoadControl();

player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);

simpleExoPlayerView.setPlayer(player);

DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();

DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,

Util.getUserAgent(this, "Exo2"), defaultBandwidthMeter);

ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();

HlsMediaSource hlsMediaSource = new HlsMediaSource(Uri.parse(hlsVideoUri), dataSourceFactory, mainHandler, new AdaptiveMediaSourceEventListener() {

@Override

public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs) {

}

@Override

public void onLoadCompleted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) {

}

@Override

public void onLoadCanceled(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) {

}

@Override

public void onLoadError(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded, IOException error, boolean wasCanceled) {

}

@Override

public void onUpstreamDiscarded(int trackType, long mediaStartTimeMs, long mediaEndTimeMs) {

}

@Override

public void onDownstreamFormatChanged(int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaTimeMs) {

}

});

player.addListener(this);

player.prepare(hlsMediaSource);

simpleExoPlayerView.requestFocus();

player.setPlayWhenReady(true);

}

When i execute this code - it seems like exoplayer is downloading something because i can see buffering but i never plays any video or audio.

Logs:

I/Adreno: QUALCOMM build : 08cdca0, I5f270ba9bc

Build Date : 09/18/17

OpenGL ES Shader Compiler Version: EV031.20.00.04

Local Branch :

Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.6.5.R1.08.00.00.312.025

Remote Branch : NONE

Reconstruct Branch : NOTHING

I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.

I/Adreno: PFP: 0x005ff087, ME: 0x005ff063

I/OpenGLRenderer: Initialized EGL, version 1.4

D/OpenGLRenderer: Swap behavior 2

I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.

I/zygote64: Do partial code cache collection, code=30KB, data=29KB

I/zygote64: After code cache collection, code=30KB, data=29KB

I/zygote64: Increasing code cache capacity to 128KB

W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc

W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2

W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2

W/VideoCapabilities: Unsupported mime video/x-ms-wmv

W/VideoCapabilities: Unsupported mime video/x-ms-wmv

W/VideoCapabilities: Unsupported mime video/divx

W/VideoCapabilities: Unsupported mime video/divx311

W/VideoCapabilities: Unsupported mime video/divx4

W/VideoCapabilities: Unsupported mime video/mp4v-esdp

I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es

W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc

W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc

I/MediaCodec: name: OMX.qcom.video.decoder.avc

I/OMXClient: Treble IOmx obtained

D/SurfaceUtils: connecting to surface 0x7a8c920010, reason connectToSurface

I/MediaCodec: [OMX.qcom.video.decoder.avc] setting surface generation to 5571585

D/SurfaceUtils: disconnecting from surface 0x7a8c920010, reason connectToSurface(reconnect)

D/SurfaceUtils: connecting to surface 0x7a8c920010, reason connectToSurface(reconnect)

I/ExtendedACodec: setupVideoDecoder()

I/ExtendedACodec: Decoder will be in frame by frame mode

I/MediaCodec: start

D/SurfaceUtils: set up nativeWindow 0x7a8c920010 for 704x576, color 0x7fa30c06, rotation 0, usage 0x20002900

I/MediaCodec: name: OMX.google.aac.decoder

I/OMXClient: Treble IOmx obtained

W/ExtendedACodec: Failed to get extension for extradata parameter

I/MediaCodec: start

D/AudioTrack: set(): streamType -1, sampleRate 48000, format 0x1, channelMask 0x3, frameCount 15376, flags #0, notificationFrames 0, sessionId 0, transferType 3, uid -1, pid -1, cbf 0

D/AudioTrack: Client defaulted notificationFrames to 7688 for frameCount 15376

I/android.media.AudioTrack: bufferSizeInBytes:61504 mSampleRate:48000

I/zygote64: Do partial code cache collection, code=61KB, data=59KB

I/zygote64: After code cache collection, code=61KB, data=60KB

I/zygote64: Increasing code cache capacity to 256KB

I/zygote64: Do full code cache collection, code=124KB, data=92KB

I/zygote64: After code cache collection, code=91KB, data=49KB

I/zygote64: Do partial code cache collection, code=122KB, data=69KB

I/zygote64: After code cache collection, code=122KB, data=69KB

I/zygote64: Increasing code cache capacity to 512KB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值