MPMoviePlayerViewController plays recorded portrait movie rotated - ios

I have a problem with the MPMoviePlayerViewController (I use the shortcut MPVC) playing recorded portrait movies right.
(Tested on iPhone 4S with iOS 6.0.1)
The app does this:
Record a movie (landscape or portrait)
Preview the movie in MPC (this time MPMoviePlayerController)
Upload the movie
There is a tableView of uploaded movies, where you can watch them
Watching the movie is done by MPVC
If I record a movie in portrait mode, the MPVC plays this video flipped to the right.
Something similar happens if I record the movie in landscape mode right (home button on the left), then the movie is played upside down in MPVC.
This only happens when playing the movie after uploading it! In the preview MPC, the movie just plays fine and not rotated!
I found some related SO questions involving rotated videos, but none are related explicitly to MPVC.
I used this and found out that the orientation stored in the movie is perfectly correct. So portrait movies really return UIInterfaceOrientationPortrait with this Method.
So now my question is, is there a way to tell the MPVC to rotate the movie or treat it right? Or do I have to write my own player based on AVFoundation?
Is this a MPVC bug, because the orientation information the movie provides seem to be correct?

I've recently stumbled upon similar issue where my videos were forced into landscape orientation after I uploaded them to 3rd party CDN. It turned out they were blindly "flipped" by 3rd party service to the landscape orientation and converted into iOS stream resource. There's probably nothing wrong with your videos, just make sure you understand what processes are in place after you've uploaded them because that might have been the case.
After having a long conversation with my CDN hosting provider, they confirmed an issue :
"The problem is that the trans-coding from the file in Cloud Files to an iOS stream seems to lose the EXIF information about orientation so it just displays as landscape."
The solution suggested was to rotate the video before uploading it.

Related

Displaying 360 Video from an iOS App to an AirPlay Device

A client's app displays two versions of a video in the app, one regular, one 360 view. The regular video is handled by AVPlayer. The 360 video is rendered by the open source package Swifty360Player (which works very well, btw). The app would like to be able to display either video on a big screen using AirPlay.
For the normal video, this is no problem. The 360 Video, however, is produced by a SceneKit view, so it's technically more akin to a 3D game than a video. I know that we can display game scenes on an AirPlay device if/when the user manually mirrors his iPhone/iPad to the AirPlay screen.
But I wonder, is there any way to generate a live video stream from the SceneKit view, and then transmit that video stream to the AirPlay device in real time? My wish is that the user could then use an AVRoutePickerView to select an AirPlay device from within the app.
ReplayKit does this for streaming services like Twitch but this app isn't looking to broadcast, just to share video with a single screen in the same room.
Is there anyway to accomplish this?

How to make a screen-record guiding video for iOS device

I'm creating an iOS app on recording screen by using ReplayKit.
I want to make a user operation video to guide user on how to use my app to record screen.
So I need to record a video on how to record screen and this approach is a bit awkward.
I tried several ways: Screen Mirroring such as AirPlayer and QuickTime, but the recording button on control-center is disabled whilst using Screen Mirroring.
The effect I want is as follows:
https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/ios13-iphone-xs-control-center-screen-record-animation.gif
How was this video made?
I think you could recreate that video by recording your screen showing every action you want, save the video and edit it on top of an iPhone image asset.

Add scroll playback controls to AVPlayer like in Photos app

I'm creating AVPlayer view to watch the stream from CCTV. And I want to make playback controls in a video like in Photos app at iPhone(open Photos, play some video, at the bottom, it will be UIScrollView with some screenshots of your video) like at image below.
May I ask you some help on how to create something like this?
And this is my first question here, so sorry if something wrong. =)
ScrollView playback
AVPlayer cannot do this for streaming. The suggestion made on snapshots would also not be close to your want of getting the same behaviour as on local preview of videos in the Photos App on iOS.
If you are looking for this kind of experience I would recommend heading over to movi.ai to get your hands on our cross platform solution with this ready out of the box.

How to implement screen recording with audio in iOS programmatically?

I have a requirement where I have screen recording with audio as well. I have done some Google and got to know about how can we implement screen recording but I am wondering how to save audio while screen recording.
Is there any possibility that we can merge the video and audio and then save the final data on disk?
But I am not sure that will it be feasible because there will be difference in syncing with audio and video frames.
For screen recording I got a link of ScreenCaptureView which actually lets you save the screen recording.
On iOS9 there is ReplayKit it's a framework that can be used to make screen recording on video games. It seems that you can use also for common screen capture.
For lower platforms it's a kind of big deal, video screen capturing exists but is a private framework ( I guess IOSurface). There are some work arounds as in this project , basically it starts to grab sigle screenshot and append them into a movie file, without audio

AVComposition breaks on Airplay

I have a video composition which I'd like to play over Airplay (without mirroring). The app works as expected when using normal Airplay mirroring, but I'd like to get the speed, reliability, and resolution bump you get from using Airplay video instead.
The problem is that when I set
player.usesAirPlayVideoWhileAirPlayScreenIsActive = YES;
...the player goes blank.
Notes:
Since I don't create separate windows for each display, they are both trying to use the same AVPlayer.
My AVVideoComposition contains different files and adds opacity ramps between them.
This unanswered question suggests that the problem is more likely due to the fact that I'm playing an AVComposition than the use of a shared player: AVComposition doesn't play via Airplay Video
Two questions:
Do I have to get rid of the player on the iPad?
Can an AVVideoComposition ever be played over AirPlay?
I can't make comments so I had to post this as an answer although it might not fully respond to the questions.
I had similar issue and at the end I found out that when AVPlayer plays AVComposition it simply doesn't display anything on the external display. That's why I had to do it myself by listening to UIScreen connection notifications.
I have to say that all worked pretty perfect. I'm checking first if there are more than one screen and if there are I simply move the AVPlayer on that screen while displaying a simple message on the device's screen that content is played on... plus the name of AirPlay device. This way I can put whatever I want on the external display and is not very complicated. Same thing is when I receive UIScreenDidConnectNotification.
That was fine until I noticed that the composition plays really choppy on the the external display. Even if it consists of only one video without any complex edits or overlays. Same video plays perfectly if I save it to the Camera Roll or if I use MPMoviePlayerController.
I've tried many things like lowering resolutions, lowering renderScale and so on but with no success.
One thing bothers me more is how actually Apple do this in iMovie - if you have AirPlay enabled and you play a project (note it's still not rendered so it must use a composition in order to display it) right after tapping play button it opens a player that plays content really smoothly on the external monitor. If you however activate AirPlay from the player it closes and start rendering the project. After that it plays it I thing by using MPMoviePlayerController.
I'm still trying to find a solution and will post back if I have any success.
So for the two questions:
I don't see why you have to get rid.
Yes it can be played but with different technique and obviously issues.
in the app .plist create a new item called:
required background modes
add a new array element called:
App plays audio or streams audio/video using AirPlay
Not sure if you have already tried this, but you don't mention it in your post.
Cheers!

Resources