How to repeat video track using AVMutableComposition - iphone

I want to repeat 1s video to 10 seconds. I used AVMutableComposition and attached the code below.
When I try with a video recorded by apple default camera app, it works as well.
But I need to have specified video so that I made a customized camera. I made 1s video(frame rate : 5fps, H264 codec).
I am getting black frames with this video.
I am not sure whats the problem. Please help.

I solved it by myself so I did not translate target view's coordinator when apply transform to video track so that it doesn't show up properly.

Related

Flutter - show video length while recording video

I am using the camera package to record video in my app, via the
CameraController.startVideoRecording() method.
I would like to display the increasing value for the length of the video while recording.
My initial thought was to create a timer. But, I wonder if there is a better solution that is more integrated with the video recording itself, such a a callback/event that I can listen to for the current length of the video or some property related to the video that I can interrogate?
Any suggestions/recommendations or examples are appreciated.
Thanks

flutter: record a video that has same duration as animated webp

what I'd like to do:
I would like to record a video using Flutter's CameraController that has the same duration as an animated webp. On top of my screen, the animated webp is playing and below there is a CameraPreview() widget that records whatever my camera catches. This recorded video's duration should be exact as long as the animated webp's duration.
what I've tried so far:
Since Giphy offers not only a webp-version, but also an mp4-version, I downloaded the mp4 version and used ffmpeg to get the duration of that file.
I then used a timer and called VideoController.stopVideoRecording() after this duration automatically after VideoController.startVideoRecording().
what I'd expect to happen:
I'd expect this recorded video to be as long as the animated webp. Unfortunately, it's not.
So, my question is:
Do you guys have any idea how I could manage to record a video with same duration as an animated webp?
Thanks :)
Ok, sort of found what the issue is: Webp (and also Gifs) in Flutter are played slower than in browsers. Dont know if that is the case for all webps and gifs, but the ones I tested are all animated faster in a desktop-browser than in flutter. So, animation time of those webp is not the same as playing-time of the respective .mp4 file.
I use those mp4-versions now instead and that does the job.

How do I pause video at the exact moment I capture a photo?

I am using AVFoundation to display a Video in my UIView via an AVCaptureVideoPreviewOverlay.
I then use AVStillImageOutput's -captureStillImageAsynchronouslyFromConnection: to capture a still Image from the Video with the AVCaptureSessionPresetPhoto preset.
I am freezing the video using AVCaptureSession's -stopRunning in the -captureStillImageAsynchronouslyFromConnection completion block mentioned earlier. However, it's too late and the video has continued running while the still image is taken, so the freeze is a second or two later. When I display the image there is a jump.
How can I freeze the video at the exact moment the photo is taken?
Almost a year later...Your approach is all wrong. Instead of trying to pause the video at the precise moment that the image is captured why don't you pause the video and then capture that paused image. To a user it makes no difference, to a developer you don't have to worry about exact precision.
To reiterate my idea, if you pause a video and flash white visual and play a click the user will think you have just captured that frame regardless if you are or not. Actually, you could consider pausing video the same as capturing an image without saving it.

How to play a video slowly for marking

I am Creating application for coaching. I struck with the marking on video. So I choose ffmpeg for converting video to image frame. That make me time delay as well as memory issues. I need to provide the user play the video slowly as frame by frame. Is there any other way to do that with out image conversion. V1 Golf did that process very quick manner. Please help me.
I would try converting video frame in separate thread and I would extract a few frames ahead as images in the background when user gets into 'slow motion mode'.
Here is example for one frame, so you should be quick with others: Video frame capture by NSOperation.
This should reduce delays and frames could be converted while user is eye-consuming subsequent frames.

Play mp3 file smoothly upon dragging a scroll using AVToolbox or openAL

I have been facing this since so many days but I have not reach to any conclusion.
My problem is : I want to play an mp3 file but not simply by clicking on a play button.
It is this way I want to play it.
*There is a slider that I can drag using finger, I want that the mp3 should play with the frequency with which I am dragging the finger (or speed with which I am dragging my finger, so that it will give an effect of fast forwarding (funny type of voice)) or if I drag slider slowyly the output will be slow *
The problem is the output of the sound is not coming out smooth. its very distorted and disturbed voice.
I want the outuput to be smoother.
Please help. Any suggestions please. Presently I am using AVAudioPlayer and passing the time value based upon slider input to play the file. (It does not seems to be feasible though).
I feel that it is possible using openAL only and no other way. Because using openAL we can modify the frequency of the sound file (pitch)
CAN SOME ONE PLEASE REFER ME A LINK TO openAL implementation for iPhone . I have never played a sound file using openAL
Help!!
You won't be able to do it with AVAudioPlayer, as it does not support pitch operations.
You can load and decode the entire track into memory for playback with OpenAL (which supports pitch), or you can do realtime loading/decoding and pitch changing using Audio Units (MUCH lower level, and more complicated, though).