Animated overlay for videos on iOS - ios

What's the common modern standard for animated video overlays? (e.g. if you want to add an animated logo to video recorded from the camera)
During research, I've found the following options:
GIF - seems to be pretty outdated technology
FLV - supports alpha-channel, but no longer supported by Adobe.
Requires FFMPEG.
PNG sequence - the downside of this is having multiple files for each
frame.
What's the right format/technology to use?
Ideally, what is natively supported on iOS (doesn't require FFMPEG)?

If you want to overlay your custom video animation over video which user will be recorded I suggest to use GPUImage framework which allow a lot video/photo customization's and different graphic effects. For example how to mix two videos: nice article. Also I suggest you to read article about Chroma key which are something like standard of video/photo mixing. (because as I understand you just want make something like watermark?). GPUImage also has Chroma key filter which you can use in your purpose.
By default Apple supports h264 codec in mp4 container. So your video should be in this codec.
Hope I fully answered on your question

The best way to add overlays using the AVFoundation framework supplied by apple itself. Speaking about the other ways such as GIF, FLV, they are not supported natively by APPLE which puts you out of luck.
Apple suggests various tools such as AVVideoCompositionCoreAnimationTool that lets you stitch the Core Animations and the videos together.
Here is a link that explains how to add various effects such as
Colored borders with custom sizes.
Multiple overlays.
Text for subtitles or captions.
Tilt effects.
Twinkle, rotate, and fade animation effects!
I am not sure how much of this is application for the application that wanted to add animations while recording. May be some one else could help in it. I hope this helps you about the native way to add animations in recorded videos in iOS.

Related

What's the best way to composite frame-based animated stickers over recorded video?

We want to allow the user to place animated "stickers" over video that they record in the app and are considering different ways to composite these stickers.
Create a video in code from the frame-based animated stickers (which can be rotated, and have translations applied to them) using AVAssetWriter. The problem is that AVAssetWriter only writes to a file and doesn't keep transparency. This would prevent us from being able to overly it over the video using AVMutableComposition.
Create .mov files ahead of time for our frame based stickers and composite them using AVMutableComposition and layer instructions with transformations. The problem with this is that there are no tools for easily converting our PNG based frames to a .mov while maintaining an alpha channel and we'd have to write our own.
Creating separate CALayers for each frame in the sticker animations. This could potentially create a very large number of layers per frame rate of the video.
Or any better ideas?
Thanks.
I would suggest that you take a look at my blog post on this specific subject. Basically, this example shows how RGBA video data can be loaded from a file attached to the app resources. This is imported from a .mov that contains Animation RGBA data on the desktop. A conversion step is required to get the data from the Desktop into iOS, since plain H.264 cannot support an Alpha channel directly (as you have discovered). Note that older hardware may have issues decoding a H.264 user recorded video and then another one on top of that, so this approach of using the CPU instead of the H.264 hardware for the sticker is actually better.

Play video using GPUimage

In my app I have to play an alpha channel video as an overlay over the current view (I'm planning to achieve this alpha channel video using GPUImageAlphaBlendFilter or GPUImageChromaKeyBlendFilter), so I wanted to know if the output video after applying these filters can be played using GPUImage? If we can, then can I get some sample code for the same.
I know AVAnimator is an option but I want to apply filters to these overlay videos i.e.brightness,saturation etc which has to be visible while video is being played because of which I can't use AVAnimator. But this being the next step for now I want to know how to play video using GPUImage.
Thanks in advance! :]
Well, even though I like telling people about AVAnimator, Brad Larson's GPUImage is specifically designed to be a GPU based filtering framework for iOS apps. Application of real time effects like the ones you describe is exactly what GPUImage was designed for. See GPUImage Chroma Key filter

iOS AVfoundation overlay video with video

I have main video and I want to overlay it with another animated video with alpha channel like "Action Movie FX" application. How can I do it with AVfoundation, or can you suggest third-party framework?
Thanks
GPUImage by Brad Larson is a great third-party framework for this kind of thing. It has many different blending algorithms you can choose from. This thread has code similar to what you want to do.
I would suggest that you take a look at my 3rd party framework to do this sort of task under iOS. You can find example Xcode projects named AVRender and Fireworks that show the exact kind of composition you describe. The compositions could be done either offline or online and can be implemented fully lossless or with a lossy encoding to h.264 as the final output. That main thing is that you will want to use a technology with a full alpha channel as h.264 does not support an alpha channel by default.

Play the transparent video on top of UIView

I want to play the transparent video on top of UIView. Can it be possible?
There are few resources on this like AVAnimator and GPUIMage. But I want to develop this with native iOS libraries. I don't want to use any 3rd party library. So please help me on this regard.
What approach should I follow?
You should use SpriteKit, it's a native library and very easy to use.
You can do some truly amazing stuff with minimal code.
You can play a video over a UIView transparently and even add physics and weight to it!
Documentation here: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40013043-CH1-SW1
In the WWDC Developer videos from 2013, there is a demo showing exactly what you want to do, so check them out,
https://developer.apple.com/wwdc/videos/
It's called Designing Games with Sprite Kit (all you care about is the Video type sprite, SKVideoNode)

Animation in iOS - what format should graphics be?

I have written a specification for an iOS app that will include a character on the screen that guides the user through a series of steps. I've had images of the character drawn in Illustrator however they're currently flat drawings only.
In the final app I'd like the character to be animated with a more 3D appearance, similar to the Tommy Cat character seen in this video
http://www.youtube.com/watch?v=BgLMdBh4-eQ
While I don't envisage the animation to be as extensive I'd like the character to make small gestures (hand waving, tail wagging) and facial expressions (happy, sad, etc)
I don't expect the app developer will also do the character animation so I need to know what format (type/dimensions) I should be requesting the animations to be created in so they will be suitable for inclusion in the finished app.
Longer term it would be useful if the same animations could also be used in an Android version of the app - not sure if the one format would be ok across both platforms.
The most simple and straightforward thing to do is hire an animator and have them export a Quicktime video that makes use of the lossless Animation codec. Typically, a 24BPP video is used. But, if you need an alpha channel then have the artist export a 32BPP video with an alpha channel included. Your developer will then have to deal with importing the video content, the most simple means would be to export a series of PNG images (this is not optimal but works just fine for a prototype).

Resources