google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

How to play "xxx.h264" file? #6721

Closed JiannaiJ closed 4 years ago

JiannaiJ commented 4 years ago

file name is "xxx.h264", exoplayer cant play.

kim-vde commented 4 years ago

Please provide the video path (with and without audio) as described here.

JiannaiJ commented 4 years ago

@kim-vde I've already sent an email with test video file.

com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors could read the stream.

kim-vde commented 4 years ago

I tried to download the file you sent but I don't have sufficient rights. Can you send it directly instead of putting it on Google Drive?

Can FFMPEG or VLC play the file?

JiannaiJ commented 4 years ago

@kim-vde Sorry, I resend the mail and test files. The test video can be played normally in ffmpeg and VLC, and also in the open source project ijkplayer.

umangsaini commented 4 years ago

Raw encoded bit-stream without container is not supported by the player out-of-the box. There are two options -

  1. Write a custom MediaSource to play the same. Refer to the documentation on this link
  2. Add the h264 bitstream to any of the supported container formats and play the resulting file
andrewlewis commented 4 years ago

Just one thing to add: if this is an H.264/AVC Annex B stream you may find the information in #5175 helpful.

JiannaiJ commented 4 years ago

@andrewlewis I follow the instructions in the #5175 and #3503. I created an Extractor that is modeled after the Ac3Extractor but uses an H264Reader, as suggested by the previously mentioned issue. My Extractor is receiving the bytes from the DataSource and passing them to H264Reader.consume(ParsableByteArray). But there's only one frame to play, and then the app is carsh, which should be OOM. I found that there was the same problem as I encountered, but the problem was not solved.(#6519)

andrewlewis commented 4 years ago

There isn't enough information here for us to help, as is the case for the referenced bug. I'm afraid we generally don't have resources to give detailed guidance on implementing custom components, so you'll need to put some time into debugging this yourself. For example, you could set a breakpoint in the extractor to check that it's outputting samples as expected.