Hello Everyone, I had to recently dive in a proje...
# android
Hello Everyone, I had to recently dive in a project that uses GStreamer to video stream on the app h264 encoded videos from a remote camera device. This doesnt seem to work on Android 5 and above even after updating the library.(the surfaceview is black). Anyone with experience with, or knows of good android libraries to read and display video stream(H264 encoded) in an app?
stackoverflow 1
Hmm. ExoPlayer?)
What is your stream in the app? What’s your container and source? hls/dash/udp multicast/unicast.
Hello @Olenyov Kirill it appears to be UDP RTP
There is so little Docu about Gstreamer, amd what i mostly find on the internet is devs publishing stream from android camera to service. My purpose here is the opposite. Server sends h246 stream and the app should display it live in a Surfaceview like container
Ok. I know ExoPlayer can play udp multicast(because I’m doing it right now). So you can try to play udp rtp as well I think. Here is a fresh article how you can achieve it: https://medium.com/@jatinmishra27/playing-udp-stream-in-exoplayer2-55ea3ea6e1db
Hello, The exoplayer required AndroidX, is there a way to avoid thar since the app needs to run on Android 4 too? Or is a migration to AndroidX unavoidable.
We use Exo with min 19 api and don’t have any problems.
@Olenyov Kirill Hello, i have tried to use exoplayer with UdpDataSource and i only ever get java socketexception(at exoplayer2.upstream.UdpDataSource) with no other info. I have searched for it but could not find any answer elsewhere. Do you have an idea?
Hmm. 1. Could you give full exception? 2. Your device/devices connected by lan or wifi?
Also show the link or address you’re trying to play
1. The exception is as follow :
E/EventLogger: internalError [eventTime=170.62, mediaPos=0.00, window=0, period=0, loadError
com.google.android.exoplayer2.upstream.UdpDataSource$UdpDataSourceException: <http://java.net|java.net>.SocketTimeoutException
at com.google.android.exoplayer2.upstream.UdpDataSource.read(UdpDataSource.java:133)
at com.google.android.exoplayer2.upstream.StatsDataSource.read(StatsDataSource.java:91)
at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:287)
at com.google.android.exoplayer2.extractor.DefaultExtractorInput.read(DefaultExtractorInput.java:62)
at com.google.android.exoplayer2.extractor.ts.TsExtractor.fillBufferWithAtLeastOnePacket(TsExtractor.java:385)
at com.google.android.exoplayer2.extractor.ts.TsExtractor.read(TsExtractor.java:275)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
2. the device is connected through LAN
3. the way I am trying to connect :
Copy code
String streamURI = "<udp://>" + portNumber;
SimpleExoPlayer player = new SimpleExoPlayer.Builder(getActivity()).build();
// Log for debugging purposes
player.addAnalyticsListener(new EventLogger(null));
// UDP Test
UdpDataSource streamingSource = new UdpDataSource(3000);
Log.v("ExoPlayer", "Target Video Stream URI is " + streamURI);
DataSource.Factory udpDataSourceFactory = () -> streamingSource;

ExtractorsFactory tsExtractorFactory = () -> new TsExtractor[]{new TsExtractor(MODE_SINGLE_PMT,
        new TimestampAdjuster(0), new DefaultTsPayloadReaderFactory())};

MediaSource videoSource =
        new ProgressiveMediaSource.Factory(udpDataSourceFactory,tsExtractorFactory)

What is Is it android device or video streamer? How the streamer is configured? Where does it stream?
SocketTimeoutException means the you can’t connect/read from source..
That s the ip adtesse of the sender(video streamer) it is supposed to broadcast an UDP h264 video stream that the app then reads and displays
If your streamer is configured for broadcasting it means that it broadcast to the special addresses in IPv4 network: or So in this case you should connect your player to one of this addresses.
I think I phrased incorrectly, the videostream comes from a Remote Camera equipped Device that that provides the server IP and a port number. This info is retrieved on runtime through a rest call: the results is always :
Are your all devices on the one local network? Can you play this stream locally from computer using e.g. VLC player(it can play network streams)