Exoplayer load frame when seekbar change - android

I'm using Exoplayer to play a locally saved video.
I noticed that when you move the seekbar the video changes only when it is released.
Is there a way to load the video frame with every move of the seekbar?

The thumbnails you see when you seek a video timeline are actually usually contained in a separate media stream or 'track'.
This is created on the server side and delivered as part of the streamed video, or in your case the locally saved video file, as a track in the video container.
The client downloads (or uploads from s saved file) this track and when a user seeks, it displays the thumbnail image that is closest to the time the user is seeking to.
Generating the thumbnails on the fly is possible but it does require the video to be loaded, decoded and a frame displayed at the point the user was seeking to.
This is quite a bit of work to do in the time available so is not usually a practical approach.

Related

Receiving callbacks on Audio/Video Stream being Played and Paused in Android WebView

I am developing an android news application in which we are having a fragment that we use for Article details listing.
An article might contain any media like plain Image or a Video as the top content with the Article Title. The Fragment is simply consist of a plain RecyclerView in it.
When we scroll up, we will see the Article Body followed by the Relative Articles listing. The body might consist of plain text paragraph, HTML paragraphs having clickable Anchor tag text in it or the entire body might be a full web-based script that could be loaded in a webview.
The situation is being uncontrolled when we encounter media like YouTube Video iFrame, Tweet having video in it or some streamed audio with media controls. As of previous implementations this videos could be played inline on the same page and user can continue scrolling through the remaining article body, which was okay yet.
Now what we are doing, just lifting up the top title video out of recyclerView, so it could be continued playing even when user scrolled down a lot while reading the article body content.
Problem Statement: When the main Media is playing in the top (Could be a brightcove or youtube video), and if user clicks the play button of the media rendered in WebView, the previous native player video continues playing with the WebView video/audio stream. Yes they are playing simultaneously having the audio collision too.
What I want: I am in search of some callback that will notify me about the media stream started and finished playing in WebView from the WebView itself. Or if WebView is not capable to do so, a callback from the Android system also could help when the latest audio stream attached and de-attached to OS Audio Channel for being played via speakers.
What I have tried: I have went through lot of official and other documentations and articles about WebView methods and callbacks, Android MediaSession callback also. Nothing helped me that much, the problem is still there.
Points to consider:
The Top Title Video is being played in Native SDKs from Brightcove and YouTube.
We are having full controls over these players, so we can play, pause or restrict user interactions anytime programmatically on them.
So while some flag named isWebViewPlayingMedia valued true we will ignore user play requests on Native players.
The VideoPlayer will completely be independent of RecyclerView item lifecycle, it won't stop playing video when user scrolled up a lot even upto the bottom of the RecyclerView. The player is floating on the top of our recyclerView.

buffer and play videos faster in VideoView

Using Picasso I was able to download and display my images very quickly in my Android app. Now i want to stream my videos from my S3 server and play them through my app faster than my code here:
try {
MediaController VideoController = new MediaController(VideoPlayerActivity.this);//Creates a media controller to this activity.
VideoController.setAnchorView(AdVideoView);//Adds the media controller to the video view.
Uri video = Uri.parse(VideoURL);//Creates a Uri to hold the URL of the video.
AdVideoView.setMediaController(VideoController);//Add the media controller to the video view.
AdVideoView.setVideoURI(video);//Make the video view play from the Uri.
} catch(Exception e) {
Log.e("Video Stream Error", e.getMessage());//Sets the message for the log.
e.printStackTrace();//Displays the error in the stack trace.
e.notify();
}
Is there a faster way to display videos through a GitHub or better code?
Thanks in advance!
The things that usually slow down streamed video playback are server and network related rather than client side - unless you have a very slow or very busy device it is unlikely it won't be able to play the video back at the rate it is received over the network.
Taking this and assuming you are are seeing delays in your streamed videos, there are a couple of common things to look for.
First, mp4 videos in normal format have the metadata at the end of the video file which is not good for streaming. There is a technique called quickstart, which moves the metadata to the start which you definitely want to use. More info here:
http://multimedia.cx/eggs/improving-qt-faststart/
Secondly, network connections can obviously vary and slow networks make streaming high quality video files a problem. A technique called adaptive bit rate streaming (ABR) allows the client request lower quality video 'chunks' if the network quality is bad and then change to higher quality when it improves.
ABR also helps startup time as it allows you quickly start the video stream by using a lower quality level, and hence smaller size chunk, and then increase the quality as the video progresses. You can see this effect when you start up most online video services, such as Netflix, today (July 2016).
One thing to note is that video hosting and streaming is a specialist area so it is generally easier to leverage existing streaming technologies and services rather than to build them your self. Some good places to look to get a feel for open source solutions:
https://gstreamer.freedesktop.org
http://www.videolan.org/vlc/streaming.html

How to get video thumbnail if i have the rtsp link of the video?

i am developing an android app for my ip camera, and the camera has some specific api commands that it can respond to. the problem i am stuck on is that i want to display a list of videos available on the memory card of the camera. I am getting the file list but i also want to get the thumbnails of those files.
The problem in getting the thumbnail is that i don't have any direct IP address of the video, the camera only provides me two things for accessing the video
1. RTSP URL of the video
2. Data stream of the video, so that i can download it in my code.
Can someone tell me how can i get the thumbnail of the videos if i have the above mentioned available options?
Note: there's also one API available in the camera for providing the thumbnail of the video, when i send that command it returns me one frame of the video, currently it is sending me the corrupt frame and this method is not working, that's why i am focusing on getting the thumbnail from the other two available options.
any help will be highly appreciated.
Thanks
You could open a socket and stream a few seconds from each video, saving the file locally on your Android device.
Once you have it there, so long as it is a recognisable video format, you should be able to create a thumbnail in the usual way (http://developer.android.com/reference/android/provider/MediaStore.Video.Thumbnails.html).
You would need to be careful to make sure that your app actually did not try to play these truncated videos, and went instead to the proper stream URL if someone wanted to view them. You could actually deleted the file after creating the thumbnail if you wanted to be sure.
Doing this may take a little time initially if your camera has a lot of videos, but you should be able to set it up to only create thumbnails for new videos once it has run once which should speed things up.
It is also possible to create thumbnails from streams directly using ffmpeg or VLC (e.g. https://superuser.com/q/592160) but I think you may find the above approach is simpler for your needs and it avoids you having to integrate ffmpeg etc with your app.

How to trim a video with regarding size/time in android?

I would like to create application like https://play.google.com/store/apps/details?id=in.shrthnd.cinedroid
what i tried is,
https://github.com/uday-rayala/video-trimmer through this url i have done video trimming with regarding to time limit.It just upload videos in sdcard and can trim it as much as we want.
what i need is,
While i am regarding the video,i can able to trim video with certain time limit.
Can i change bitrate and frame rate of a video recorder?

Android video recording in loop

I want to make an app, that will have an feature of recording in a loop. That means, app will continuously record video and when a user hits "end of recording" button, the video will have only the last 1 minute recorded. What is the best way to achieve this?
As far as I know, there is no simple way to achieve this. Some rough ideas, though, in order of increasing difficulty:
If you can safely assume that the total recording time will be fairly short (i.e., you won't run out of storage space on the device), you could record the entire video and then perform a post-processing step that trims the video to size.
Record the video in one-minute chunks. When the user stops recording, compute how much of the previous chunk you need to prepend to the current chunk. Stitch the chunks together.
Register as a PreviewCallback and store the video frames in your own file format. Periodically remove the frames that you don't care about because they're too old. You would need to store the audio separately, and then you would need to transcode the custom format into a standard format.
Each of these would probably require some NDK code to do the work efficiently.

Categories

Resources