I want to play video (.mp4 format) in background continuously(on loop). I tried using the MediaPlayer,AVFoundation but i didn't get the desired result.
I used another method after converting mp4 to gif, .gif worked for me but the quality was low. So please help me find the best method to solve my problem.
For what purpose is this? If you're trying to have a video background for a login screen or something of that sort, its better to stick with lower res GIFs. It will save you memory, infact you can get really high quality GIFs from .mp4 files using photoshop but the resolution and frames will eat up iPhone's memory.
You can create AVPlayer object in AppDelegate.
Then register its "MovieFinished" observer. In that notification, you can restart the video playing.
Hope this helps.
Related
is it possible to have a real-time preview of AVMutableComposition which has some layer instructions applied to its assets?
The only class I found that connects AVMutableComposition with AVVideoComposition (holding instructions) is AVExportSession. Does it mean I must export it first to play a preview?
If so, how does apps like Final Cut Pro serve real-time preview when I edit part of the video. Do they cut the whole video into multiple chunks, export what has changed and keep change of everything else?
This sounds like a difficult problem - is there any library that would help in cutting video into small chunks to export and keeping an eye on cache invalidation?
Cheers,
M.
I don't know if this is still relevant but you can always extract each frame from the video, manipulate it accordingly then render it to the screen.
If its from AVCaptureSession you can get CMSampleBuffer from the callbacks, if it's a file I think AVReader is your best bet then you can use either CoreImage or Metal to manipulate the frames and render them in real-time.
There is no real time preview with AVMutableComposition , they may create a time slot for every change and manage it's visibility when you change the slider below
I want to implement such a function that enable users to make GIF directly from their camera.
In detail, I want to show users a camera view, and a record button. When the button is tapped, the camera starts to record video. In fact, however, behind the scene the camera is actually taking photos at constant speed, say 1 shot per 0.5 second. When the record ends, we got an array of images and then connect them into a GIF.
I think there might be 2 approaches:
1、Directly taking images: Use AVCaptureStillImageOutput's -captureStillImageAsynchronouslyFromConnection method. But it will block UI every time it is called.
2、Take a video and extract several images from it. I have checked video taking libraries such as PBJVision and SCRecorder, and noticed that taking video is typically writing data to a mp4 file locally. I cannot figure out how to extract images at specific time intervals from a video file. Also, is there a way to store the video in memory?
Could anyone help?
Creating Gif
Create and and export an animated gif via iOS?
Convert Images to gif using ios
Extract Images from Video
Get a particular frame by time value using AVAssetReader
Similar here Creating a Movie from Images
How do I export UIImage array as a movie?
You can use a library called 'Regift' by Matthew Palmer, which will convert video to GIF.
Here it is: https://github.com/matthewpalmer/Regift
You can also check out the following answer here on SO:
https://stackoverflow.com/a/28150109/3288936
Hope this will help! :)
I am currently working on one application in which I am supposed to display the recording time while video recording is going on. Whats more interesting is that this recording time should also be there in the recorded video.
So I think I have two things to consider :
1.) Show recording time overlay while recording video
2.) Recording time should also be shown in the recorded video.
I know we can do the static text overlay while recording the video and then we add one text layer in recorded video. But in my case, this time value should be changed on every second.
I have searched a lot on google and stake overflow. Tried different solutions. By using GPUImage, By using AVMutableVideoComposition and CALayer. But they all are for static value.
May be I am nearer to my solution but not able to find it. So can anyone guide me on how can I achieve it?
Any help would be greatly appreciated.
Thanks
Use AVAssetReader for recorded video. Get the CMSampleBufferRef, get it timestamp, draw time on sample buffer, write buffer to AVAssetWriterInputPixelBufferAdaptor. Similar approach for video being recorded.
I'm using AVMutableComposition and AVAssetExportSession to composite several discrete audio clips/files together into a single file, similarly to this post but there will be no "video" track. I'd like to give the track some visual appeal using a still image so that when the user plays the clip they don't just see a generic quicktime icon, ideally I'd replace the image with branding or something relevant to the audio content. How would I go about doing it and is there a way to do it without dramatically increasing file size(ie some way to have a really slow framerate or just something so its not generating 30 fps for what is non moving art.) Appreciate any help on this.
AVAssetWriter will allow you to create video from a still image. This question provides a great example of how to do so.
How can I change the sound that plays when an image is captured with an iPhone? I am using AVCapture and I want to capture still images (rather than grabbing frames from video) for image quality sake.
Thanks in advance!
After researching it appears that the standard camera shutter sound is next to impossible to change via SDK.
This answer supports that. You can replace your own sound, but not in an app.
As for AVCapture, it also appears that you can't change the shutter sound as capturing images covertly is against the App Store policy. See this answer.
The only way to take a silent picture is to use a video screen grab, which you said you don't want to do for image quality reasons.
So AFAIK, there is no way to change the shutter sound not using video screen grabs.