我们可以在exoplayer中播放H264视频吗?

时间:2018-02-16 10:35:49

标签: android h.264 exoplayer

我正在尝试在Android中传输实时视频。详细信息 - H264 - Mp4格式 - demuxed。 Codec details given by VLC Player

我正在使用this code

问题:

  1. 我可以在exoplayer中播放这种格式的视频吗?

  2. 我应该使用哪个库来直播视频?

  3. 使用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);
        }
    

    当我执行此代码时 - 似乎exoplayer正在下载一些东西,因为我可以看到缓冲,但我从不播放任何视频或音频。 日志:

        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
    

0 个答案:

没有答案