using ffmpeg to display video on iPhone - iphone

anyone can help me on this ?
I have this API
ret = avRecvFrameData(avIndex, buf, VIDEO_BUF_SIZE, (char *)&frameInfo, sizeof(FRAMEINFO_t), &frmNo);
the buffer will fill with the content from the video thread the codec is H264 frameInfo contains the related information. If I want to display on iPhone, how to do it with ffmpeg?
much appreciated with your help .

You should not be using ffmpeg in an iOS for a number of reasons. First, there are real license issues that put including ffmpeg in a legal grey area when it comes to iOS apps. Second, performance will be very very poor. Third, iOS already includes APIs that have access to the h.264 hardware on the device. You can find my example Xcode project at AVDecodeEncode, this is an example of using my library to decode from h.264 and then encode back to h.264.

Related

Raw H264 NALU hardware decode on iOS

I receive raw H.264 NALUs from an IP camera (via Live555) and I want to decode them using hardware because FFmpeg is great but it's too slow (the camera sensor is large).
The only solution I see is to write the NALUs to some movie container file such as MPEG-4, and then read and decode that file using an AVAssetReader.
Am I off in the weeds? Is anyone having success decoding H.264 NALUs from a stream? Does anyone have any tips for writing NALUs to an MPEG-4 file? Other ideas?
Like Matt mentioned, there is no direct access to Apple's H264 decoder.
However, I have had success with ffmpeg and h264 decoding. Like you mentioned, I have built ffmpeg with LGPL I was able to decode H264 streams all the way to real-time HD stream with no latency on both ipad and iphone. Nothing fancy is required from ffmpeg, you can find bunch of standard decoding c++ code that will work just fine on iOS. Also, in my case H264 NALUs were delivered via RTP/RTSP in real-time.
Also, if I was you I would run your app through xcode instruments to truly see where you bottleneck is, but I would be highly surprised it is in ffmpeg decoding step.. Hopefully this info helps.
Unfortunately, you cannot do this at present. Feel free to file a radar with Apple about wanting this sort of access to the hardware decoder. It'll certainly be resolved as a duplicate :-). I assume it is for licensing reasons why they can't give this sort of access to the hardware codec.
So, you're going to have to use a software decoder. Please be aware that if you're going to ship to the App Store then you need something with a non-GPL license (unless you want to open source your app as well).

what is the most optimised video format for iPhone: .3gp or .mp4?

I'm building an iPhone app for a mobile film festival.
The app will make it possible for the users to watch the submitted short films over wi-fi, 3g, and edge (really?)
The movies will have a duration between 30sec to 2minutes max. (ste
Would you recommend using .3gp format above .mp4 ? Any reason/advantage to prefer one format?
I will manually re-encode all the videos for the iphone app.
thanks
Louis
mp4 with the H.264 codec is very well supported at a hardware level
Sounds like a cool app. iOS devices prefer h.264 video. For video to play in an iOS app on 3g, you need to encode them for Apple's HTTP Live Streaming. That's their version of adaptive bit rate encoding. Every Mac shipped with Leopard or Snow Leopard includes a segmenter with their other utilities, but it can only handle one file at a time. There's a help article on Apple's video utilities here:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html
Encoding.com can also do the video encoding and segmenting for you. (Disclaimer: I work there. :) You can check out how to get this up and running using Amazon and Encoding.com on the site and if you'd like to talk to someone about it you can just schedule a free consultation with us. We're here to help.
mp4 (i think the extension has to be *.m4v if you want it to use with itunes) with h.264 as codec
reasons: standard iphone format, better quality, better compression

How to encode and stream a video from an iPhone

I'm capturing CGImageRef frames using UIGetScreenImage() on an iPhone 3GS 3.1.3 and want to stream this over the interwebs in any appropriate, well known format.
What video codec libraries are available that would allow me to encode the raw pixel data into a video? (i'm not too familiar with video codecs, but am familiar with network programming to actually send the data out)
I wouldn't recommend encoding on the client. Have the video available on the server already encoded and use MPMoviePlayerController to present it:
good tutorial on how to stream video:
http://buildmobilesoftware.com/2010/08/09/how-to-stream-videos-on-the-iphone-or-ipad/

Need to play flash videos on iphone

I am building this iphone app for a client and they have a large set of flash video files that they need to play/stream to the iphone. I understand that the iphone doesnt natively support flv playback but isnt there anything I can do to get around this problem?
In case it helps, they are using the akamai flash player on their website to play these video files.
Thanks in advance.
Yes! - You can convert all the videos to m4v format.
There's a javascript hack available, but it will only work if it's installed on the clients web server. It's also pretty clunky and slow and will likely murder battery life.
A workaround, since you're working with video, is to convert to mp4 format.
Short answer: no flash, but conversion will do what you need.
akamai actually supports "auto-packaging" of h.264 content which may be your best option here. By uploading 1 or more h.264 files you can use those to both serve your Flash player, and akamai will also auto-package them for iPhone (chunking them into .ts files and creating an .m3u8 reference file for dynamic mobile streaming).
This allows you to not have separate encodes for mobile and web, thus saving money and time so you can leverage your existing archive.

Create video in iPhone

I need to convert image sequences(ie,png) to video file in iPhone. How i can convert the images to video.
Regards,
Just ignore bad advice like "use ffmpeg". That would work on the desktop, but the license issue makes including ffmpeg source code in your iPhone app legally questionable. Apple provides a class named AVAssetWriter that you would use in your app to encode a series of images as h.264 stored in a .m4v quicktime container file. While the apple provided logic does work, it is not so easy to actually use and you will need to read quite a lot of documentation to get the code working. If you want to skip implementing it yourself (and likely save yourself 3 or 4 days of work), please consider using my AVAnimator library for iOS as the h.264 encoding logic is already implemented in the class AVAssetWriterConvertFromMaxvid. Once encoded as h.264, the video can be played with the standard player and it is small enough to upload to a remote server.
You are likely going to need something like FFMPEG