ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Detecting and playing AC-4 audio?

Open cncb-gh opened this issue 2 years ago • 5 comments

Is it possible to detect and play AC-4 audio? I have the FFMpeg extension built with a version of FFMpeg that should be able to decode AC-4 but when I try to play the (.ts) file ExoPlayer reports there is no audio track. I can get audio from other players with the same files. I sure am cursing the ATSC folks for choosing a new proprietary audio format...

cncb-gh avatar Sep 14 '22 18:09 cncb-gh

May be related to #10464, @tonihei can you please take a look.

rohitjoins avatar Sep 16 '22 18:09 rohitjoins

The issue, is the extension isn't aware that unofficial ffmpeg versions can decode AC-4 so unofficial ExoPlayer builds also need to update FFmpegLibrary.java

      case MimeTypes.AUDIO_AC4:
        return "ac4";

emveepee avatar Sep 17 '22 21:09 emveepee

Does the FFmpeg decoding AC-4 works well for you? I tried few video samples with AC-4 but the audio synced badly with video. Not sure if it had anything to do with the fact that I took the changes (from https://github.com/makrsmark/FFmpeg/tree/ac4) and applied them in the FFmpeg 4.2 branch. Anyway, seems like some devices include system AC-4 decoder (like Samsung Galaxy S21 serie).

moneytoo avatar Sep 18 '22 22:09 moneytoo

The issue, is the extension isn't aware that unofficial ffmpeg versions can decode AC-4 so unofficial ExoPlayer builds also need to update FFmpegLibrary.java

      case MimeTypes.AUDIO_AC4:
        return "ac4";

Thanks for this. I added that to FFmpegLibrary.java and "ac4" to the enabled decoders array and rebuilt but still cannot get it to decode. Should ExoPlayer identify the audio track even if it cannot decode? That is, when playing it shows no audio track instead of AC4 with no sound. I am using 2.14.0 so maybe this version is too old?

cncb-gh avatar Sep 19 '22 20:09 cncb-gh

Should ExoPlayer identify the audio track even if it cannot decode?

There are two steps needed to get this to work: Extract the AC4 track from the container (TS) + Decode the samples. Only the decoding step is done by the FFmpeg extension, ExoPlayer still needs to detect the track itself inside the TS stream. If you want to debug this further, you can add an EventLogger to ExoPlayer to see which tracks it detects and if that doesn't work provide example media to investigate.

so unofficial ExoPlayer builds also need to update FFmpegLibrary.java

If there is an "official" Ffmpeg decoder for AC4, we can add the decoder name here to support it. Feel free to send a PR if that's the case.

tonihei avatar Sep 20 '22 09:09 tonihei

Closing because the question has been answered.

tonihei avatar Oct 07 '22 15:10 tonihei