Changing bitrate of Exo Player - android

This question might have been asked many times. I searched everywhere but could not find the correct answer. I am using ExoPlayer in my project to play HLS videos.
I want to give user the option to select the bandwidth of videos. Something like what YouTube does.Any idea how this can be achieved using ExoPlayer?

From ExoPlayer issue tracker:
ExoPlayer currently selects the first variant listed in the master
playlist. If I remember correctly, this is what Apple
recommends/specifies as correct client behavior. If you want to start
in the lowest quality, you should technically have your server
generate the master playlist with the lowest quality listed first.
The above aside, we do agree that it makes more sense for the client
to make the initial variant selection locally, as opposed to the
recommended behavior. We'll be moving HLS over to use FormatEvaluator
in ExoPlayer V2, which will give more control over the initial
selection (and over the adaptive algorithm in general).
And as the solution, this comment:
Have a look at AdaptiveTrackSelection.Factory. Its parameters may
provide enough customization for your case.
I think this should give you either the answer you need, or it will guide you in the right direction.
Note that you have to provide streams in lower qualities to be able to use this. If you ONLY have the video in HD, ExoPlayer can't downsample the video, its not its job and not what it is intended for. ExoPlayer can only sync and enable smooth transition between the video in multiple resolutions when they are provided.

Related

Extracting and Streaming audio from YouTube videos in Android

I'm trying to find a way to separate and stream the audio from a youtube video given it's url/video ID. I've looked into youtube extractors and most of them are pretty old or no longer maintained. I'm working in Kotlin and jetpack compose. I found an app, newpipe, that does exactly what I want, but the codebase is huge and it's way beyond my experience. I'd like to play it in the background as well, so I suppose I would use exoplayer in combination with a background service. My only obstacle is obtaining the audio from it's url. Is there a quick and dirty way to achieve this within the context of an Android app?

Check/observe what is currently being played by the Android system

I'm looking for a solution to observe what the app is currently playing. At minimum I would need to know what URI is being used to play Media and what is current playback position.
We are giving developers API with media content (MP3/HLS files) and to give them the best experience we are asking them to send various events to our API. Based on those events we can prepare better content for their users. We would like to ease the process of tracking events by implementing library that will be responsible for tracking those events. To do it we need to observe/query what their app is currently playing and what is a playback position. That's why I'm looking for a solution that will let me do this without caring too much what kind of player app is using (MediaPlayer, ExoPlayer or any other solution).
Is there any tool that will let me check those informations?

Is there a solution to implement an "low-speed" scrubbing on Exoplayer2?

I'm working on an application who needs some precision when scrubbing on the videoplayer, in order to get an image from the video.
The problem is, the timebar is too imprecise.
I'm looking to implement a solution like the native iOS player, when you scrub and you swipe down your finger to slow down.
-> https://lifehacker.com/how-to-control-the-audio-and-video-scrubbing-speed-on-y-5811660
If you have a solution, it would be really cool.
Thanks in advance !
Exoplayer cannot do this for streaming. A similar discussion has been seen regarding AVPlayer - to allow the described behaviour for streaming, and some have suggested making snapshots which would also not be close to your want of getting the same behaviour as on the example you have provided.
If you are looking for this kind of experience I would recommend heading over to movi.ai to get your hands on our cross platform solution with this ready out of the box.

Android video record libraries

everyone! I have a question. I need some video recorder (library project) which offer the possibility to set programmatically the maximum output file size and resolution of recording video. I know that native android video recorder allows to set max output file size, but it allows to set only two type of quality(best and worst). I need at least three different video resolutions. So maybe someone know library which can help me to solve my problem?
Also good to have:
-zoom;
-autofocus;
-flash;
Thanks!
The best libraries which I found:
CWAC-Camera library (https://github.com/commonsguy/cwac-camera);
OpenCamera (http://opencamera.sourceforge.net/). But Open Camera is released under the GPL v3. The source code is available from https://sourceforge.net/projects/opencamera/files/.
To anyone reading this recently, CWAC-Camera mentioned on accepted answer is discontinued, then the author re-attempted for a better version, which is found here. And the demo is here.
I also found Material Camera that is under the Apache License v2.0. Here is the sample project.
There is also ragnraok/RxCamera, based on android.hardware.camera although it is said to be still in very early stage, plus the android reference link says android.hardware.camera2 is the recommended API now.
The best libraries which I found:
FFmpegVideoRecorder
The library provides a way to record multiple videos using MediaRecorder and merge them together using FFmpeg Recorder from JavaCV. It is designed to allow maximum customization of the video encoding and recording.
It has built in activities for easy recording and previewing. But it also exposes basic components that can be used to customize your own UI and logic.
General Features
Able to record multiple clips and combine them into one video
Camera preview image is scaled, cropped, and padded to exactly how it will be recorded
Can generate a thumbnail image for the video
Can set recording parameters such as:
video codec
List item
video width
video height
List item
video frame
....etc
To anyone reading this recently,
The author mentioned he plans to DISCONTINUE the project cwac-cam2..
Here:
https://github.com/commonsguy/cwac-cam2/issues/336

Is there something in the Android architecture or API that prevents people from creating MP3 players that read embedded lyrics?

When I play certain MP3 files (such as lessons from JapanesePod101.com) on my iPod Touch, lyrics or transcripts that are embedded in the MP3 files are displayed in the media player. The lyrics are, I believe, stored as ID3/ID4 tags in the MP3 metadata.
I find this to be an extremely useful feature, and I believe I'm not alone. Despite that, neither the stock Android media player nor any other media player I've downloaded from the Market seems to support this. I just have not been able to find any way to get feature on my Nexus One.
This feature is important enough to me that I'm considering learning Android development just so I can write a simple media player that displays embedded lyrics or notes. However, the fact that nobody else seems to have done this makes me wonder - is it even possible? Is there something in the Android architecture or APIs that make it difficult or impossible to read and display lyrics information from MP3 files? I'd hate to get deep into the learning process and find out what I'm aiming for can't easily be done. (I mean, if all else fails I assume I could write my own MP3-decoder, but that's more trouble than I'm willing to go through right now).
I've already asked this question on the Android Enthusiasts Stack Exchange Beta Site, but in retrospect I decided it was more of a programming question and decided it was better to ask here.
Yeah, definitely more of a programming question. Just from my brief experience of reading through the ID3 spec, I think it's probably just that decoding ID3 tags is a complete PITA. I'm sure it can be done, as there are MP3 tag editing apps available for Android (whether any support lyrics or not, I do not know).
ID3v2.3 seems to have support for both synchronized and unsynchronized lyrics through the SYLT and USLT frames of the header. I imagine it's just such an underused feature that it isn't worth the effort to most to do so. Purchased MP3s don't carry this information (I've always wondered why not?), so they would have to manually be added (or automatically via a lyric service API, but there's a lot more coding involved with that).
Here is the ID3v2.3 spec if you'd like to look into it further...(abandon hope all ye who enter here)
The problem may be that most people would use the built-in mp3 playback mechanisms, and this may neither support lyric display nor be very easy to keep synchronized with something else doing lyric display.
So it may be that something needs to be written which does it's own mp3 decoding.
Most likely this would want to be done in native code. On the other hand, on android, audio output (and unless you use opengl, video display) pretty much has to be done from java. So you are looking at a fair amount of work to decode data with a native library and then dispatch it for playback and display from java.
So to answer your question - is it possible? Definitely
Is it made easy by the android APIs? - not really
I just added a new feature request that would give Android support for reading USLT in the ID3 tag. This will enable the native and 3rd party music players to display lyrics. If you want this feature, please star the request below, and post your comments.
http://code.google.com/p/android/issues/detail?id=32547

Categories

Resources