3

I am trying to create a streaming app using ExoPlayer on Android. Most of the streams works fine, only some of them does not play sound on some devices only.

Here is the stream info extracted using this command:

ffprobe -v error -show_format -show_streams http://nasaiptv.com:8000/live/qSplUhwfcy/bE43JqZPSt/477.ts

[STREAM]
index=0
codec_name=mpeg2video
codec_long_name=MPEG-2 video
profile=Main
codec_type=video
codec_time_base=1/25
codec_tag_string=[2][0][0][0]
codec_tag=0x0002
width=720
height=576
coded_width=0
coded_height=0
has_b_frames=1
sample_aspect_ratio=16:15
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=8
color_range=tv
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
id=0x100
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/90000
start_pts=3471311880
start_time=38570.132000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=mp2
codec_long_name=MP2 (MPEG audio layer 2)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[3][0][0][0]
codec_tag=0x0003
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=0x101
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=3471301664
start_time=38570.018489
duration_ts=N/A
duration=N/A
bit_rate=112000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=http://nasaiptv.com:8000/live/qSplUhwfcy/AVbqREBSOh/477.ts
nb_streams=2
nb_programs=1
format_name=mpegts
format_long_name=MPEG-TS (MPEG-2 Transport Stream)
start_time=38570.018489
duration=N/A
size=N/A
bit_rate=N/A
probe_score=50
[/FORMAT]

And this is the way I start playing the stream:

   private SimpleExoPlayer player;
   private PlayerView exoPlayer;

   private void initializePlayer() {
      exoPlayer = findViewById(R.id.exo_player);
      player = ExoPlayerFactory.newSimpleInstance(
            new DefaultRenderersFactory(this, EXTENSION_RENDERER_MODE_ON),
            new DefaultTrackSelector(),
            new DefaultLoadControl());

      player.addListener(listener);

      exoPlayer.setPlayer(player);

      player.setPlayWhenReady(true);

      Uri uri = Uri.parse(stream.getStreamUriString());

      MediaSource mediaSource = new ExtractorMediaSource.Factory(
            new DefaultHttpDataSourceFactory("exoplayer-codelab")).createMediaSource(uri);
      player.prepare(mediaSource, true, false);
   }

I also tried with EXTENSION_RENDERER_MODE_OFF and with EXTENSION_RENDERER_MODE_PREFER, no success.

This is after importing the extensions in the sample project into my project.

Is this an ffmpeg problem? In case I have to build the extension from scratch, is there anyway to do it in Windows? Installing Linux on my PC is somewhat problematic. And is there any tutorial to do it correctly, according to my stream info?

ExoPlayer is a great media player, but it really lacks documentation (or is hard to find).

hiddeneyes02
  • 2,562
  • 1
  • 31
  • 58
  • Please provide some details about the kind of streaming protocol you use as well (UDP, DASH etc.) Also mention the command and parameters you used to get the stream info using ffmpeg – PrashanD Jun 12 '18 at 06:37
  • I really don't know how to find the protocol, but I updated my question (top code) with the command used and the url of the stream – hiddeneyes02 Jun 12 '18 at 09:32
  • I agree except for the surface of the Exoplayer library, it's not well documented at all. Did you get any error messages by overriding `onPlayerError`? – PrashanD Jun 15 '18 at 04:54
  • @PrashanD I waiting for the reports to come in, because it is on a device very far away from me, and I am using ACRA on my web server to store the reports – hiddeneyes02 Jun 15 '18 at 18:55

2 Answers2

2

You may try to get some detailed error info by attaching the ExoPlayer.EventListner to your SimpleExoPlayer instance and override onPlayerError.

@Override
    public void onPlayerError(ExoPlaybackException error) {
        switch (error.type) {
            case ExoPlaybackException.TYPE_SOURCE:
                Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
                break;

            case ExoPlaybackException.TYPE_RENDERER:
                Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
                break;

            case ExoPlaybackException.TYPE_UNEXPECTED:
                Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
                break;
        }
    }

Once you get the error messages please update your question

PrashanD
  • 2,643
  • 4
  • 28
  • 58
  • Sorry for my very late reply, but this callback is never been called. – hiddeneyes02 Mar 31 '20 at 07:51
  • Seems there is no explicit error generated from Exoplayer framework that pertains to sound not being played then. Since it's been almost two years.. may you can check with a newer version of Exoplayer. If the error still persists you could open a github issue for this. – PrashanD Mar 31 '20 at 08:25
1

Just to sum this up: ExoPlayer does not come with build in audio or video codecs. It uses the native codecs from the devices it is running on. Means if the device lacks the audio codec of the stream, you will have no sound. You can avoid this by using the ffmpeg extension. But as you have already noted, you need to build it by yourself, first.

See https://exoplayer.dev/supported-formats.html and https://developer.android.com/guide/topics/media/media-formats#core

Additionaly, you could transcode your stream with ffmepg, using a different audio codec.

Harry Developer
  • 260
  • 1
  • 3
  • 15