FFMpeg for iPhone - iphone

I am trying to create an app that will allow me to stream video FROM the iPhone TO a server. my current theory as to how to do this is to create a series of FFMpeg files and send them to the server. as far as i can tell i have compiled the FFMpeg library correctly for the iPhone.
i followed these instructions here. a series of executable files appeared in the folder so i'm assuming it worked.
my question is now what? how do i get these into an app? how do i make calls to these executable files? and most importantly will this even work the way i want it to?

You have built the ffmpeg binary which can run on an iPhone. You cannot run executables from an app on a (non-jailbroken) phone. So you would have to compile the library, and link against that. Then, from your app, call the relevant functions directly, mimicing what the ffmpeg program does.

Althought this issue is quite old this could help to other users in the future:
Just take a look at the source code here http://dev.wunderground.com/support/wunderradio/wunderradio.1.9lgpl.zip
Good luck

Ok you said that you succesfully compiled FFMpeg for iPhone, right? As mvds said, you can't use them as executable files. So in order to use this libraries after compilation finishes you need to copy all the .a libs generated to your project (as when you add libraries or other frameworks). These libraries are:
libavcodec.a
libavfilter.a
libavutil.a
libswscale.a
libavdevice.a
libavformat.a
libswresample.a
Then you have to configure your project
Clic on your project -> build settings
Search "Header Search Paths" and add the folder location of your libraries (location can be absolute or relative)
Clic on build phases -> Link Binary With Libraries -> Add other, and add all .a files
Voila! Now you can import and use the libraries of FFmpeg for your project
#include <avcodec.h>
#include ...
// More C and/or Objective-C Code
To access individual uncompressed frames you can use captureOutput:didOutputSampleBuffer:fromConnection: delegate method from AVCaptureVideoDataOutput (there are plenty of examples), and somehow encoding them to h264 maybe using AVFrame? As far as I know FFmpeg also can stream using RTSP for live streaming, but it seems that documentation is close to zero :(
To answer your final question
and most importantly will this even work the way i want it to?
The answer is yes, it can work, I found 2 libraries that do just what you want to achieve
http://www.foxitsolutions.com/iphone_h264_sdk.html
http://ios-rtmp-library.com
Both uses FFmpeg the same way you are suggesting, this question is a little old but I have found many users trying to achieve this so so I have a question Do you had success on doing this? Can you share your experience or recomendations?

Related

Is it possible to hide the source codes of .m files and build project using xcodebuild

I have created a Mac app that can generate iphone ebook app project source codes.
I know I can using xcodebuild to build the project to get the release binary file.
Is it possible to hide the source codes of .m files(maybe store in memory) and build project using xcodebuild?
Welcome any comment
Thanks
Marc
It sounds to me like you are attempting to generate source code for others to use, but then hide it so they cannot see whats been generated. Basically not possible. You could generate obfuscated code which would make it harder to read, but not impossible.
Realistically what you are trying to do is generate template code for others to use. If you don't want them to be able to see it, then you presumably don't want them modifying it. The easiest answer is to simple not do it. Instead, create a compile static framework containing your code and IP, and then only generate templates which makes calls to your framework. Thus your code is protected.
Your question lives on the edge of being programming related, and I'm not exactly sure what problem you're trying to solve.
However, you can create a RAM disk, store your project there and run xcodebuild against that. Just be aware that you're not really protecting the .m files so much as limiting how long they are easily visible.

How would I include open source library in my iPhone application?

I have found an existing open source library that I would like to include in my iPhone project (the unrar source code found here: http://www.rarlab.com/rar_add.htm ).
I have compiled this source as a linked library on my Mac with "make lib" which creates the libunrar.so file just fine.
These are the makefile settings for that target:
lib: WHAT=RARDLL
lib: $(OBJECTS) $(LIB_OBJ)
#rm -f libunrar.so
$(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ)
Obviously I can't use this on iPhone but I imagine I should be able to compile with different options to make a static library that I can use.
Do I:
Compile it on the Mac with different make options then drag the resulting library (some kind of .a ?) into my xcode project?
or
Drag all of the source code into my xcode project and create special targets of some kind to create it?
or
Something else entirely different?
I've been working on solving my unrar problem for a couple of weeks now and I believe using this library will give me the best results but I just don't know the final steps to make use of it.
Thanks for all advice.
I think that you'll probably want to do the easiest thing first, create an empty iPhone project and bring all of the code into it, just to see if it will compile.
If so, you may want to use the empty project to aid in the development of an Objective-C wrapper, once that is complete you can bring the code into your existing project for integration and testing.
If it looks like this is code that you would like to use with other projects, or you are feeling giving and would like to provide an iPhone port of the code, go ahead and pull this together into a library.
Here is a site that documents the process.

SNMP Library for iPhone

Are there any open source libraries for doing SNMP GET/SETs using the Objective C/Cocoa Touch (for IPhone)?
Although there is no SNMP implementations in Objective-C (that i an aware of). There are in C & C++.
I've had success at using snmp++v2.8a. Just drop the .h and .cpp files required for the static libsnmp++.a into your x-code iphone project. And make the necessary tweaks for it to build. I had to add: "-D_XPG4_EXTENDED -DGCC -DLINUX" to Project Settings 'Other C++ Flags', and make some changes to the files. Then any file you are using the c++ objects from, rename from .m to .mm, to tell X-Code the file contains a mixture of objective-C and c++.
In my opinion, the C/C++ package called Net-SNMP (has nothing to do with .NET) is the best implementation of an SNMP library for both the manager (client) and the agent (server) sides. I've looked at a lot of them and used a lot of them, and Net-SNMP is the best of the lot. Open source.
I've spent some time working on building one of these for a project.
there's none for obj-c, or at least there weren't when I was looking last summer. there's a bunch of open source ones in c and c# that are a good starting spot for a port (or re-implementation).
I've never heard of one, and the only thing I'm finding on Google is "IP*Works!", but it seems to be a Mac framework (and might not work on iPhone if it's not compiled as a .a file).
Your best bet may be to roll your own. http://cocoabuilder.com has a couple emails in its archives about people asking for SNMP libraries, but no answers were ever received.

Considerations for including library as binary vs source

I'm trying to write an SSH client for the iPhone, and I'd like to use the libssh2 open source library to do so. It's written in C.
How should I include this C library for my iPhone app? Should I compile it into some binary that I include into the my app, or do I add all the source to my project and try to compile it along with the rest of my app?
I'm interpretting this question as:
"Should I compile the C library code once, and include the binary library in my project? Or should I include all the source and compile it every time I build my app?"
It depends. One of the projects I work one depends on several external libraries. Basically, we have a simple rule:
Do you think you will need to change code in the C library often?
If you will be changing the code, or updating versions often, include the source and build it with the rest of your project.
If you're not going to change the code often or at all, it might make sense to just include the pre-built binary in your project.
Depending on the size of the library, you may want to set it up as a distinct target in your project, or for even more flexibility, as a sub-project of your main project.
If I was in your place, I would build libssh2 ahead of time and just include the binary library in my iPhone project. I would still keep the libssh2 source around, of course, in case it does need to be re-built down the road.
I have an iPhone app that is 90% c. I have had no problem adding 3rd party sources to my project and compiling. I am using Lua, zLib, and libpng with no modifications. I've also included standard libraries like unistd and libgen and they just work™
The Three20 iPhone library has a great howto on adding their library to your xcode project. Give that a shot.
I think you will find in the long run you will be better off building it into a standalone library and linking it with your application. This makes it easier to integrate into future apps. Another benefit is that it encourages code separation. If you feel pretty confident with the library, you can link your debug exe to the release build of the library and get some extra performance.
I can't really think of any downsides to creating a library, after the initial cost of setting it up, and having an extra project to modify if you have some changes that need to be made to all your projects. Even if you don't know how to make a library for the iPhone, this is a good excuse to learn.
Just adding the source to you project should work fine as well.

Best way to share iphone and mac code between projects

I realise that the view/controller stuff will be different between Mac and IPhone apps but the model code may well be similar/the same. So whats the best way to organise a project(s) so that the model code is/can be shared?
Copy/paste - just duplicate it and manually keep it in sync
Have 2 xcode projects point at the same workarea - one for Mac and one for IPhone and share the code.
Common library - presumably you can't do this (or can you)
Thanks for any tips.
There are a few ways to do this. The first thing you can do is is create a project that builds as a framework on Mac OS X. Since you cannot use frameworks on iPhone, you can make static library target that contains the same code files. That basically works, but the header paths will be different. If you want the header paths to be the the same (i.e. <Myframework/MyFramework.h>) you will need to modify the the install path of the static library headers so that they are copied into "$SDK_ROOT/usr/local/include/MyFramework", and make sure /usr/local/include is an included header search path. You will then need to install the library and headers into each SDK_ROOT.
I started out doing the above, but I found it to be a royal pain. So I ended up doing something that is a variant of #2. Basically, I get the header paths to be equivalent by making a directory named "Externals" in my iPhone project root, then a directory named with the appropriate name ("MyFramework") in the externals folder. That is the folder I copy I drag the framework files into.Findally I add the Externals folder as a system header path (which is admittedly sort of a gross hack). You need to manually add new files to the iPhone project, but I have found that to be less of a pain the installing static libs into my build root.
I'm not sure if the suggestion from the previous answer would work. If you look at my previous question, you'll see that I've failed to load a custom framework on the iPhone even though the framework works fine on Mac.
I would go with method 2.
You could develop your application in JavaScript, CSS, and HTML. You would use the WebView and UIWebView objects on the Mac and the iPhone respectively. You can do pretty much anything you want in the WebView objects, even make calls down to Objective-C.
The QuickConnectiPhone installer, found here https://sourceforge.net/projects/quickconnect/, installs QuickConnectMac and QuickConnectiPhone templates into Xcode.
This way you can quickly create an application in one environment and then migrate the view to the other. In fact the QuickConnect framework is highly modular.
If you don't want to develop in JavaScript the same modular framework is found on the Objective-C side of the templates installed.
It should make it much easier for you to do what you are attempting.