I'm trying to build a media player from scratch to improve my skills in android, the current problem I'm facing is that I am unable to read the internal subtitles as MediaPlayer does not support the codec I'm trying to load.
I tried using FFmpeg but the application does not even build when I use the library. Is there an alternate way to integrate a library into my application to get MediaPlayer to read the internal subtitle?
I read a bit about vlc but I cannot figure out how to integrate it to my application.
Any help would be appreciated
I used this library to compile VLC which allowed me to get the subtitle encoding.
implementation 'org.videolan.android:libvlc-all:3.3.13'
to get the subtitle track you need to pass the file to the media player and get the subtitle using this method
mediaPlayer.getSpuTracks();
Related
Which library is useful to load audio or video file from API and play to the application? I tried glide for the image. But no idea about audio or video. (I want to fetch the image and file name to the recycle view after click operation file will play to the next activity.) A short guideline with library name is very helpful.
Android has MediaPlayer to load and play Audio and Video from URL. you can setDataSource as URL.
refer this answer...
You have Two approach one of them is using official Library (Media Player Library for music and VideoView for video) and other approach is using custom library I suggest you to using ExoPlayer Library for playing music and video
you can use following link:
https://github.com/google/ExoPlayer
I am writing an Android application that plays a large MP3 file over the web. These files are usually about an hour or so and I've been getting some really inconsistent behavior with the stream cutting off in the middle in some cases.
To fix this, I decided to move to ExoPlayer and utilize an HLS implementation. While I am able to play the Apple test files (the beep boop) without issue, I can't seem to get any of my own streams to work.
Whenever I try to access my own stream, the player errors out and I get the following stack trace:
06-05 18:15:22.898 29566-29566/com.application E/EventLogger﹕ internalError [0.66, loadError]
java.io.EOFException
at com.google.android.exoplayer.extractor.DefaultExtractorInput.readFully(DefaultExtractorInput.java:73)
at com.google.android.exoplayer.extractor.ts.TsExtractor.read(TsExtractor.java:102)
at com.google.android.exoplayer.hls.HlsExtractorWrapper.read(HlsExtractorWrapper.java:214)
at com.google.android.exoplayer.hls.TsChunk.load(TsChunk.java:110)
at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:242)
What is the correct way to create an HLS Stream from an MP3 for Android? For testing, I have tried a number of ffmpeg exports and am using S3 to serve the files, but I have been unsuccessful.
One of the samples can be found here: https://s3.amazonaws.com/gte619n/test_stream/output_test.m3u8
Thank you for all your help and suggestions.
Your link works fine in the ExoPlayer currently available at GitHub.
How to do it:
1) git clone https://github.com/google/ExoPlayer.git
2) Open the ExoPlayer/demo app in Android Studio
3) Edit ExoPlayer/demo/src/main/java/com/google/android/exoplayer/demo/Samples.java and add
public static final Sample[] HLS = new Sample[] {
new Sample("Stackoverflow",
"https://s3.amazonaws.com/gte619n/test_stream/output_test.m3u8",
PlayerActivity.TYPE_HLS),
and it worked.
Can we determine whether the audio in a video is mono or stereo(without using ffmpeg)? I am unable to found any method in MediaMetadataRetreiver.
I think the simplest way is to use MediaPlayer() and try to open a media file. Once open you can easily find info for both audio and video track using getTrackType() and getFormat().
Specifically for audio track you can get number of channels from MediaFormat using key KEY_CHANNEL_COUNT.
I have a requirement where I need to extract ID3 tags from a MPEG2 TS(HLS STREAM). MPEG2 has a limited support in android in regards to playing the file. But my concern is to extract the ID3 tags(playing the file is not necessary). Hence I am not concerned with the codecs(encoding and decoding).
I have explored the following options:
libstagefright and OpenMax : A playback engine implemented by Google from Android 2.0.
It has a MediaExtractor is responsible for retrieving track data and the corresponding meta data from the underlying file system or http stream. But according to this post Adding video codec to Android I need to build my own firmware or my own media player.I am hoping I don't have to go down that path. More info on stagefright and openMax can be found here:
An overview of Stagefright player
Android’s Stagefright Media Player Architecture
Custom Wrapper Codec Integration into Android
How to integrate a decoder to multimedia framework
Compiling and using FFMPEG: A complete, cross-platform solution to record, convert and stream audio and video. We can demultiplex ts files with this library as mentioned here:
FFmpeg - Extracting video and audio from transport stream file (.ts).
But I am not sure if I will be able to extract the ID3 tags from the HLS Stream. libavformat might be able to do this but I still need to come up with a mechanism for signaling the read metadata to my application.
Compiling vlc for android: I have compiled vlc for android and made some modifications inside the transport module in demux component for extracting the tags, but it is not able to play all the streams that I am supplying to it.
After looking through these options , I am still at a fix in how to achieve this. I don't want to create a media player as I will not be playing the files nor do I want to build my own firmware. Using ffmpeg seems to be the most viable option, but I want to try this without using any third-party or open source library. My questions are:
Is it even possible to create a demultiplexer from scratch that will work on android?
If possible then ,how to go about it ?
Any options that I have missed?
I am new to this. Any help would be greatly appreciated..Thanks
In android, there is a support to extract ID3 tags. Please refer to ID3 module for further details.
Integration of ID3 into MP3 extractor can be found here.
From a quick check, I have found that ID3 is supported from Froyo onwards.
I have a small video clip and an audio file. The problem is how to write code to merge them into a single file. i have never written code for multimedia applications for android and don't know if the merging is possible with android media framework. Is there any third party library to do that?
Can we right a merging code in Java and call it in Android?
Please guide me through this. Thanks
You can try INDE Media for Mobile, tutorials are here: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials
It has a sample demonstating how to substitute audio track in mp4 video file by another audio track from another mp4 file. It's here: https://github.com/INDExOS/media-for-mobile/blob/master/Android/samples/effects/src/com/intel/inde/mp/effects/SubstituteAudioEffect.java
In sample app it's under Audio Effect: