I saved a video in FCP as h.264
. I dragged the video into the Project Navigator section of Xcode and Selected Copy Items if Needed. It's a .mov
that plays in the background of the Login page when it's presented.
This is how I access and play the video:
let url = Bundle.main.url(forResource: "SampleVideo", withExtension: ".mov")
player = AVPlayer.init(url: url!)
playerLayer = AVPlayerLayer(player: player!)
playerLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
playerLayer?.frame = view.layer.frame
player?.actionAtItemEnd = AVPlayerActionAtItemEnd.none
player?.play()
view.layer.insertSublayer(playerLayer!, at: 0)
The problem is when the video is included inside my project and I upload the app to TestFlight the file size is 304 MB
. I get a warning about the app's max size exceeding the 150 MB limit.
I know the user can still download it but I notice if the connection is slow it takes quite a while for the app to download.
If I delete the video from my project and upload the app to TestFlight the compressed file size is greatly reduced to 38.2 MB
How can I keep the video inside my app and reduce the file size of my app?
I would assume compressing the video inside Xcode would achieve that?
I recorded my app's background video on an iPhone 7+ using FilmicPro. Everything was recorded in 4K. As the question states the file size was very high after it was uploaded to iTunesConnect. What I did to get around the issue was convert my 4K video to 1080P. I used FCPX and the conversion took a few minutes. The quality looked exactly the same.
Here's the YouTube video I followed on how to create the conversion. It's very easy to follow and is less then 5 minutes: