Hello Everyone, I had to recently dive in a proje...
# android
s
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
o
Hmm. ExoPlayer?)
What is your stream in the app? What’s your container and source? hls/dash/udp multicast/unicast.
s
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
o
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
s
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.
o
We use Exo with min 19 api and don’t have any problems.
s
@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?
o
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
s
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://192.168.1.103:>" + 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)
                .createMediaSource(Uri.parse(streamURI));

player.prepare(videoSource);
player.setPlayWhenReady(true);
o
What is 192.168.1.103? 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..
s
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
o
If your streamer is configured for broadcasting it means that it broadcast to the special addresses in IPv4 network:255.255.255.255 or 0.0.0.0. So in this case you should connect your player to one of this addresses.
s
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 : 192.168.1.103:NEW_PORT.
o
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)
162 Views