How to add trick play to custom iOS video player build on top of AVPlayer to play .m3u8 files? - ios

Goal:
To add youtube like preview feature when user seeks manually using the player seek bar.
From what I understand so far is that I will have to add "I-Frame only playlist" to my stream to enable trick play but I am not able to figure out how I will be using this to show the preview view on the video player?
Other solutions I considered:
AVAssetImageGenerator: It does not work on streams. Explained here.
This says if my .m3u8 file contains "I-Frame only playlist", AVAssetImageGenerator will start returning the snapshot, but even if it does, generating thumbnails of a complete 1 hour video upfront is just not optimal.
AVPlayerItemVideoOutput This also seems like a very brut force way to approach the problem as I need thumbnails of almost complete video.
Current player implementation:
I have added AVPlayerLayer as a sublayer to my view controller's view and added custom controls on top of it.
I am thinking of using something like this https://github.com/pbs/iframe-playlist-generator to add the I-Frame playlist.
PS: I am new to this, so if I have made any wrong assumption, please let me know.
Also, any links or references to some reading material I can use to dive in deeper are appreciated. Thanks.

Related

Add scroll playback controls to AVPlayer like in Photos app

I'm creating AVPlayer view to watch the stream from CCTV. And I want to make playback controls in a video like in Photos app at iPhone(open Photos, play some video, at the bottom, it will be UIScrollView with some screenshots of your video) like at image below.
May I ask you some help on how to create something like this?
And this is my first question here, so sorry if something wrong. =)
ScrollView playback
AVPlayer cannot do this for streaming. The suggestion made on snapshots would also not be close to your want of getting the same behaviour as on local preview of videos in the Photos App on iOS.
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.

AVPlayerLayer Vs AVPlayerViewController

I am new to iOS app developing field. I am trying to capture video using AVFoundation. I am successful in this. But when I tried to play the video back using MPMoviePlayerController, I got too many issues. So I am trying to play using AVPlayer.
But in AVPlayer there are two approaches AVPlayerLayer and AVPlayerViewController.
I tried searching about those, but I didn't get any particular reason to choose one.
Can anyone suggest me which is better to use?
AVPlayerViewController is an all in one solution. You setup your AVPlayer with a video and present the player controller. It handles all the playing and has its own controls baked in (I'm sure you've used seen this in other apps). It is the simplest way to show a video.
AVPlayerLayer is for when you want to add some customization, like adding your own controls or extra views, or not making the video full screen.

How to play a video in uiview Xcode obj C

I Need to play a video when the view load but, other code i have try to do the video player comes up. I want to play the video in the UIVIEW. Can someone please help!
You will need to use an AVPlayer, specifying an AVPlayerItem. This should allow you to use multiple AV items within a single view.
Basically, everything is explained here:
https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html

What can be done to make a Youtube video play properly upon the first attempt to view it?

What can be done to make a Youtube video play properly upon the first attempt to view it?
Most of the time I get dark areas as shown for example in the attached:
https://www.imageupload.co.uk/images/2015/05/28/ytquestion.png
Update your flash player. That is probably corrupt.

How to capture screen video in iphone?

I want to capture video from screen.
I am unable to capture video from avplayer layer. But, can record from other viewes.
Do I need to search code for OpenGLES?
You can have look at the blog.
I think it covers what you want.
Actually this blog does not use AVPlayer, but rather it uses AVAssetWriter.
Look into the comments there you can get hint using AVPlayer.
Or you can have this project, which is for recording of screen.
These two libraries are the best possible options that you can use to record video of your application screen.
https://github.com/wess/Glimpse
https://everyplay.com/about
Yes I'm working with the same job it comes black screen because of high frameDuration of video .But I've solved this
Don't add AVPlayer to that view. Add to another view and note the time at play and then crop the video of time that has played and after all merge with the recorded video.
I've stated it shortly but I hope you will understand.
You need to work on OpenGLES to render video layer, otherwise it will look black
I would suggest using the GPUImage framework, for a number of reasons:
It IS OpenGL but is wrapped in Objective-C, so there's no need to learn OpenGL to implement it
It is 100% App Store vetted - I have an app in the store that uses it now, as do dozens of others
There is a class named GPUImageMovie that wraps AVAssetReader for playback and another named GPUImageMovieWriter that allows you to write textures to file - these can be the same file, or separate.
There are quite a few examples available within the repository that should be pretty easy to understand...
Source Code / Git Repo
* https://github.com/BradLarson/GPUImage
Blog
* http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
Hope that helps !
This is good for you testing you achieve that goal through this framework
https://github.com/gabriel/CaptureRecord for screen capture. But, it can be used to record simulator only. You can't submit app to appstore using this code as it use private api.

Resources