Missing sound in videos recorded with iOS 11

iOS 11 finally has screen recording capabilities. It can record audio too (force tap on record button to enable). However, while the recorded videos play fine on the iPhone without any problems, when they're uploaded to YouTube or played with VLC the sound is missing. How do I fix it?


Apparently, iOS 11 records a video with two audio tracks: the first one completely silent, while the second one is the real one. You can fix it with ffmpeg like this

ffmpeg -i input.mp4 -map 0:0 -map 0:2 -c:v copy -c:a copy output.mp4