{"id":4957,"date":"2014-03-30T17:12:19","date_gmt":"2014-03-30T17:12:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-doesnt-this-video-play-on-ios-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:12:19","modified_gmt":"2014-03-30T17:12:19","slug":"why-doesnt-this-video-play-on-ios-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-doesnt-this-video-play-on-ios-collection-of-common-programming-errors\/","title":{"rendered":"Why doesn&#39;t this video play on iOS?-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/636bec3398ab7aa3d5c6eeaee1a1350a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDominic P<\/p>\n<p>I&#8217;m having trouble getting my mp4 video to play on any iOS device. I&#8217;m testing on an iPhone with iOS 6 and an iPad running iOS 7. When I upload the video to my server and enter the URL directly on the device I get a black screen and an alert that says &#8220;The operation could not be completed.&#8221; The same problem happens when I try to play the video on a web page using a tag.<\/p>\n<p>The video plays fine on Android and Windows. You can find an example video here. Here are my ffmpeg settings.<\/p>\n<pre><code>ffmpeg -i uncompressed.avi -s 854x480 -c:v libx264 -pix_fmt yuv420p\n    -preset:v veryslow -profile:v baseline -crf 23\n    -c:a libfdk_aac -flags +qscale -global_quality 3 -afterburner 1\n    -ar 48000 -cutoff 19000\n    output.mp4\n<\/code><\/pre>\n<p>And here is the output from ffmpeg when encoding a video.<\/p>\n<pre><code>ffmpeg version N-55064-g3cd8aaa Copyright (c) 2000-2013 the FFmpeg developers\n  built on Jul 29 2013 12:59:12 with gcc 4.8.0 (GCC)\n  configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=\/home\/dominic\/\nGitHub\/ffmpeg-windows-build-helpers\/sandbox\/mingw-w64-x86_64\/bin\/x86_64-w64-ming\nw32- --pkg-config=pkg-config --enable-gpl --enable-libsoxr --enable-libx264 --en\nable-avisynth --enable-libxvid --enable-libmp3lame --enable-version3 --enable-zl\nib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --en\nable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-f\nontconfig --enable-libass --enable-libutvideo --enable-libopus --disable-w32thre\nads --enable-frei0r --enable-filter=frei0r --enable-libvo-aacenc --enable-bzlib\n--enable-libxavs --extra-cflags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb --\nenable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroedinger --enab\nle-libbluray --enable-libvpx --enable-libilbc --enable-static --disable-shared -\n-enable-nonfree --enable-libfdk-aac --enable-runtime-cpudetect\n  libavutil      52. 40.100 \/ 52. 40.100\n  libavcodec     55. 19.100 \/ 55. 19.100\n  libavformat    55. 12.102 \/ 55. 12.102\n  libavdevice    55.  3.100 \/ 55.  3.100\n  libavfilter     3. 81.103 \/  3. 81.103\n  libswscale      2.  4.100 \/  2.  4.100\n  libswresample   0. 17.103 \/  0. 17.103\n  libpostproc    52.  3.100 \/ 52.  3.100\nInput #0, avi, from 'cure.avi':\n  Metadata:\n    date            : 2013-10-12T21:16:56.00708-07:00\n  Duration: 00:00:30.07, start: 0.000000, bitrate: 88517 kb\/s\n    Stream #0:0: Video: lagarith (LAGS \/ 0x5347414C), rgb24, 854x480, 23.98 tbr,\n 23.98 tbn, 23.98 tbc\n    Stream #0:1: Audio: pcm_s32le ([1][0][0][0] \/ 0x0001), 96000 Hz, stereo, s32\n, 6144 kb\/s\n\n[libx264 @ 000000000209f620] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2\n[libx264 @ 000000000209f620] profile Constrained Baseline, level 4.0\n[libx264 @ 000000000209f620] 264 - core 133 r2339 585324f - H.264\/MPEG-4 AVC cod\nec - Copyleft 2003-2013 - http:\/\/www.videolan.org\/x264.html - options: cabac=0 r\nef=16 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mix\ned_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_ps\nkip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=1 sliced_threads=0 nr=0 d\necimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 k\neyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtre\ne=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\n\n[libfdk_aac @ 00000000020d8f80] Note, the VBR setting is unsupported and only wo\nrks with some parameter combinations\nOutput #0, mp4, to 'cure-baseline.mp4':\n  Metadata:\n    date            : 2013-10-12T21:16:56.00708-07:00\n    encoder         : Lavf55.12.102\n    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] \/ 0x0021), yuv420p, 854x48\n0, q=-1--1, 24k tbn, 23.98 tbc\n    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] \/ 0x0040), 48000 Hz, ste\nreo, s16\nStream mapping:\n  Stream #0:0 -&gt; #0:0 (lagarith -&gt; libx264)\n  Stream #0:1 -&gt; #0:1 (pcm_s32le -&gt; libfdk_aac)\n\nvideo:4373kB audio:442kB subtitle:0 global headers:0kB muxing overhead 0.333461%\n\n[libx264 @ 000000000209f620] frame I:16    Avg QP:22.72  size: 46151\n[libx264 @ 000000000209f620] frame P:705   Avg QP:27.08  size:  5303\n[libx264 @ 000000000209f620] mb I  I16..4: 42.7%  0.0% 57.3%\n[libx264 @ 000000000209f620] mb P  I16..4:  1.9%  0.0%  1.6%  P16..4: 32.1%  9.7\n%  4.8%  0.6%  0.2%    skip:48.9%\n[libx264 @ 000000000209f620] coded y,uvDC,uvAC intra: 47.7% 59.1% 19.9% inter: 1\n2.9% 9.2% 0.9%\n[libx264 @ 000000000209f620] i16 v,h,dc,p: 31% 21%  7% 41%\n[libx264 @ 000000000209f620] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 13%  6% 11% 15%\n13% 14% 10%  9%\n[libx264 @ 000000000209f620] i8c dc,h,v,p: 48% 21% 18% 13%\n[libx264 @ 000000000209f620] ref P L0: 74.5% 10.1%  6.1%  2.0%  1.6%  1.4%  1.2%\n  0.5%  0.4%  0.4%  0.4%  0.4%  0.3%  0.3%  0.3%  0.2%\n[libx264 @ 000000000209f620] kb\/s:1191.01\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/636bec3398ab7aa3d5c6eeaee1a1350a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDominic P<\/p>\n<p>Ok, after banging my head against the wall on this one for some time, it seems the answer was the H.264 level. It looks like ffmpeg defaulted to level 4.0 and that does not seem to be supported by iOS.<\/p>\n<p>When I set the level down to 3.1, I got an error about the DPB size from ffmpeg. So, I added a <code>-refs 11<\/code> flag and now the video plays. I was even able to get the main profile to work as long as the level was still set at 3.1 and I didn&#8217;t exceed the DPB size specified for that level.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Dominic P I&#8217;m having trouble getting my mp4 video to play on any iOS device. I&#8217;m testing on an iPhone with iOS 6 and an iPad running iOS 7. When I upload the video to my server and enter the URL directly on the device I get a black screen and an alert that says [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4957","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4957"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4957\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}