AVAssetWriter H264 encoding produces incorrect results on certain devices (at least iPhone5s, possibly all A7 devices), but not in simulator, under iOS 11.0 Beta 2, 3 (15A5318g) and 4 (15A5327g)

Submitted to bug reporter with abstracted Xcode project and assigned number 33132289 on July 5th. No response as of 26th July.


Description:


I have an app in production that uses an AVAssetWriter to append multiple images and encode them to produce H264 QuickTime .mov videos.


The same code that has been working correctly from iOS6 to iOS10.3.2 now produces incorrect results under iOS 11 Beta 2, 3 (15A5318g) and 4 (15A5327g) but only on certain hardware: notably the iPhone 5s (all A7 CPU devices?), but not in the equivalent simulator or in newer hardware like the iPhone 7.


On at least iPhone 5s, the final video always appears with a green cast, in some cases there is also garbling of the underlying image frames.


It seems like a bug in iOS 11 Beta, and my guess is it may be something specific to the hardware encoder on the iPhone 5s (or other affected devices). It would be very useful to see confirmation of this issue and to know if other devices are affected. If not, it would be good to know if I am doing something incorrectly under iOS 11.


Steps to Reproduce:


I have abstracted the code into a single view application for testing purposes and made it publicly available from the GitHub repo linked below. I have verified that this code produces the correct results on iOS 11 simulators (iPad and iPhone), but still produces incorrect results (green cast on video) on my iPhone 5s running iOS 11 Beta 2,3 or 4. Can anyone confirm this behaviour?


NB: This link is obfuscated as otherwise the post gets stuck in "waiting to be moderated" purgatory for days, and there don't seem to be too many moderators around these days.


github .com/AlexGingell/AVBugTest


Simply open this Xcode project and run it on

a) iOS 11.0 simulator

b) iPhone 5s running iOS 11.0 Beta 2, 3 or 4.


Navigate to the photos app and check the video that has been produced.


Expected Results:


Both simulator and device should produce an identical H264 video that adequately resembles the source image sequence.


Observed Results:

The simulator produces the expected result. An iPhone 5s running iOS 11 Beta 3 produces a video with a green cast that does not reflect the source images at all, indicating some kind of encoding error. I have included a video produced on my iPhone 5s under iOS 11.0 Beta 2 for reference - this reflects the incorrect observed result.


Version:


iOS 11.0 Beta 2, 3 (15A5318g) and 4 (15A5327g) on iPhone 5s.

I expect it may produce incorrect results on other A7 devices too (I have seen similar reports), but I have not been able to verify more than iPhone 5s myself.


Notes:


I wondered whether this was connected to HEIC/HEIF changes in iOS 11.0. I have checked the documentation, but have not been able to find any reason why the attached code should not work on hardware, as opposed to the simulator. I suspect different encoders are being used and there may be an issue with the encoder used on at least the iPhone 5s, if not other A7 devices too. This effectively kills the functionality of many video apps (at least mine!) which still need to support H264 encoded output under iOS11.0 on the affected device(s).


Thank you for your help.


Alex

Accepted Reply

This bug was confirmed, and now appears fixed as of Beta 5.

Replies

This bug was confirmed, and now appears fixed as of Beta 5.