{"id":1764,"date":"2012-05-21T09:52:26","date_gmt":"2012-05-21T07:52:26","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/wehr\/?p=1764"},"modified":"2012-06-04T16:33:43","modified_gmt":"2012-06-04T14:33:43","slug":"how-to-cross-compile-ffmpeg-for-ios-iphone-and-ipad","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/wehr\/2012\/05\/21\/how-to-cross-compile-ffmpeg-for-ios-iphone-and-ipad\/","title":{"rendered":"How to cross compile ffmpeg for iOS (iPhone and iPad)"},"content":{"rendered":"<p id=\"top\" \/>In one of my latest projects I needed some audio\/video streaming capabilities for <a href=\"http:\/\/en.wikipedia.org\/wiki\/Apple_iOS\">iOS<\/a> driven devices.<\/p>\n<p>The first App. which we implemented was a audio\/HDVideo low latency conference streaming application for smart phones.<\/p>\n<p>The second app was around\u00a0 <a href=\"http:\/\/de.wikipedia.org\/wiki\/Transportstrom\"><em>MPEG<\/em>&#8211;<em>TS<\/em><\/a>\u00a0to Elementary Stream <em>demuxer<\/em> for some dreambox streaming fun \ud83d\ude42<\/p>\n<p>The framework of choice is the swiss army knife for streaming stuff,.. <a href=\"http:\/\/ffmpeg.org\/\">ffmpeg<\/a>. To be more precise, ffmpeg consists of serveral libraries and the command line programs ffmpeg, ffplay, ffprobe.<\/p>\n<h3>What do you need:<\/h3>\n<ul>\n<li>Xcode4.3<\/li>\n<li>Apple&#8217;s command line tools (Xcode -&gt; Preferences -&gt; Components)<\/li>\n<li>pkg-config -&gt; <a href=\"http:\/\/code.google.com\/p\/rudix\/downloads\/detail?name=pkg-config-0.25-1.dmg&amp;can=2&amp;q=label%3ARudix-2011\">download<\/a><\/li>\n<li>gas-preprocessor -&gt; <a href=\"https:\/\/github.com\/yuvi\/gas-preprocessor\">download<\/a> (extract under your ffmpeg root dir .\/gas-preprocessor)<\/li>\n<li>build-essentials -&gt; you can <a href=\"https:\/\/gist.github.com\/1397146\">download<\/a> an install script<\/li>\n<\/ul>\n<blockquote>\n<ul>\n<li>m4<\/li>\n<li>autoconf<\/li>\n<li>automake<\/li>\n<li>libtool<\/li>\n<\/ul>\n<\/blockquote>\n<ul>\n<li>last but not least ffmpeg -&gt; <a href=\"http:\/\/ffmpeg.org\/download.html\">download<\/a><\/li>\n<\/ul>\n<p>I used the latest <a href=\"http:\/\/git.videolan.org\/?p=ffmpeg.git;a=snapshot;h=HEAD;sf=tgz\">snapshot<\/a> available at the the time of writing. Extract the snapshot .tar to a folder of our choice.<\/p>\n<p>Thanks Michael, the lead developer of ffmpeg, the ffmpeg source comes with the convenient <a href=\"http:\/\/de.wikipedia.org\/wiki\/GNU_Build_System\">autotools<\/a> facilities. So we only need to set the correct configure flags \ud83d\ude42<\/p>\n<p><strong><span style=\"text-decoration: underline;\">1.<\/span> Compiler flags:<\/strong><\/p>\n<p style=\"padding-left: 30px;\">As we need to do some cross-compiling we need to select the compiler\/assembler which comes with our XCode<\/p>\n<p style=\"padding-left: 30px;\">&#8211;cc=&#8217;\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/usr\/bin\/arm-apple-darwin10-llvm-gcc-4.2&#8242;.<\/p>\n<p style=\"padding-left: 30px;\">&#8211;as=&#8217;.\/gas-preprocessor\/gas-preprocessor.pl \/applications\/xcode.app\/contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/usr\/bin\/arm-apple-darwin10-gcc-4.2&#8242;<\/p>\n<p style=\"padding-left: 30px;\">&#8211;arch=arm<\/p>\n<p style=\"padding-left: 30px;\">&#8211;target-os=darwin<\/p>\n<p style=\"padding-left: 30px;\">&#8211;cpu=cortex-a8<\/p>\n<p style=\"padding-left: 30px;\">&#8211;enable-pic<\/p>\n<p style=\"padding-left: 30px;\">&#8211;disable-yasm<\/p>\n<p><strong><span style=\"text-decoration: underline;\">2<\/span>. iOs SDK path:<\/strong><\/p>\n<p style=\"padding-left: 30px;\">&#8211;sysroot=&#8217;\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk&#8217;<\/p>\n<p><strong><span style=\"text-decoration: underline;\">3.<\/span> extra flags:<\/strong><\/p>\n<p style=\"padding-left: 30px;\">&#8211;extra-cflags=&#8217;-mfpu=neon -pipe -Os -gdwarf-2 -miphoneos-version-min=5.0&#8242;<\/p>\n<p style=\"padding-left: 30px;\">&#8211;extra-ldflags=&#8217;-arch armv7 -isysroot \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk -miphoneos-version-min=5.0&#8242;<\/p>\n<p><strong><span style=\"text-decoration: underline;\">4.<\/span> configure ffmpeg library components:<\/strong><\/p>\n<p>for example:<\/p>\n<p style=\"padding-left: 30px;\">\u00a0&#8211;disable-ffmpeg<br \/>\n&#8211;disable-ffplay<br \/>\n&#8211;disable-ffprobe<br \/>\n&#8211;disable-ffserver<br \/>\n&#8211;disable-avdevice<br \/>\n&#8211;disable-avfilter<br \/>\n&#8211;disable-everything<\/p>\n<p>and then enable the\u00a0components you need<\/p>\n<p style=\"padding-left: 30px;\">&#8211;enable-decoder=xxx<br \/>\n&#8211;enable-parser=xxx<br \/>\n&#8211;enable-demuxer=xxx<\/p>\n<p>after successful completion of<em> .\/configure<\/em> run <em>make<\/em>&#8230; and voil\u00e0 \ud83d\ude42<\/p>\n<p>If you get some errors complaining about\u00a0 &#8220;error: invalid operand in inline asm: &#8221; try to disable assembler directives with<\/p>\n<p>&#8211;diasble-asm<\/p>\n<p>have fun<\/p>\n<p>Mario<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In one of my latest projects I needed some audio\/video streaming capabilities for iOS driven devices. The first App. which we implemented was a audio\/HDVideo low latency conference streaming application for smart phones. The second app was around\u00a0 MPEG&#8211;TS\u00a0to Elementary Stream demuxer for some dreambox streaming fun \ud83d\ude42 The framework of choice is the swiss &hellip; <a href=\"https:\/\/blog.fh-kaernten.at\/wehr\/2012\/05\/21\/how-to-cross-compile-ffmpeg-for-ios-iphone-and-ipad\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to cross compile ffmpeg for iOS (iPhone and iPad)<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[7,13,8],"tags":[],"class_list":["post-1764","post","type-post","status-publish","format-standard","hentry","category-cool-tools","category-iphone","category-projects"],"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/1764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/comments?post=1764"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/1764\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/media?parent=1764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/categories?post=1764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/tags?post=1764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}