title: Can we play H264 videos in exoplayer?
body: <p>I am trying to stream live video in android. Details - H264 - Mp4 format - demuxed. 
  <a href="https://i.stack.imgur.com/z3Z4F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z3Z4F.jpg" alt="Codec details given by VLC Player"></a></p>
  
  <p>I am using <a href="https://github.com/yusufcakmak/ExoPlayerSample" rel="nofollow noreferrer">this code</a> </p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Can i play video of this format in exoplayer?</p></li>
  <li><p>Which library should i use to stream live video?</p></li>
  </ol>
  
  <p>Code to play a video using Exoplayer</p>
  
  <pre><code>    {
          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);
      }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>    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
  </code></pre>