Search Unity

Everyplay video upside down (again)

Discussion in 'Unity Everyplay' started by julleg15, Apr 11, 2017.

  1. julleg15

    julleg15

    Joined:
    Jul 27, 2015
    Posts:
    1
    Hi,

    I know, it's an old problem but I am facing it.
    I use the local file, created with Everyplay. Everything work well, the file is in the right orientation, except when I try to transcode the mp4 (Facebook post or Vimeo...). The result is flipped.

    I have already try the screen orientation (Left or Right).
    Unity 5.5.2&iOS 10.3

    Any news about this issue?
    Thanks in advance for any help!
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    How do you transcode to MP4? I thought the FB sharing just shared a link to Everyplay.
     
  3. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    245
    Everyplay adds rotation information to the video and it is mainly understood by iOS/Mac video players. So if you upload the local file (not officially supported) you will get a flipped video in most of the services because they don't understand the rotation data.
     
  4. YoungZheng

    YoungZheng

    Joined:
    Dec 16, 2016
    Posts:
    4
  5. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Are you guys OK with us taking the MP4 and doing stuff with it outside of Everyplay? Is this against your terms of service?
     
  6. ullatussimo

    ullatussimo

    Unity Technologies

    Joined:
    Jun 16, 2015
    Posts:
    108
    Hello @_Daniel_ ,

    Thanks for reaching out.

    You can access the video files produced by the Everyplay SDK, but please note that direct access to the files is not officially supported and thus we don't guarantee that the code will work in the future.

    We're looking to bring the option to use the local files in a more direct way in some form or another in the future.
    Unfortunately I do not yet have an exact ETA to give to you.

    We ask you to email us at support@everyplay.com before using local video files and sharing with us the reason why you need such access. This will help us to understand new use cases for Everyplay.

    Hopefully this answers your question.

    Cheers,
    Simo
     
  7. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Done
     
  8. YoungZheng

    YoungZheng

    Joined:
    Dec 16, 2016
    Posts:
    4
    Sorry, do not allow me to give you all the code, but to add the code is simple
    Hope to help you
    Code (CSharp):
    1. //Insert audio and video tracks
    2.  
    3.     AVMutableComposition *mutableComposition = [AVMutableComposition composition];
    4.  
    5.         // Insert the video and audio tracks from AVAsset
    6.         if (assetVideoTrack != nil) {
    7.             AVMutableCompositionTrack *compositionVideoTrack = [mutableComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
    8.             [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [asset duration]) ofTrack:assetVideoTrack atTime:insertionPoint error:&error];
    9.         }
    10.         if (assetAudioTrack != nil) {
    11.             AVMutableCompositionTrack *compositionAudioTrack = [mutableComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
    12.             [compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [asset duration]) ofTrack:assetAudioTrack atTime:insertionPoint error:&error];
    13.         }
    14.  
    15.     // Rotation transform
    16.         transform = CGAffineTransformMake(1, 0, 0, -1, 0, assetVideoTrack.naturalSize.height);
    17.  
    18.     // Set the relevant rendering parameters
    19.         AVMutableVideoComposition *mutableVideoComposition = [AVMutableVideoComposition videoComposition];
    20.         mutableVideoComposition.renderSize = CGSizeMake(assetVideoTrack.naturalSize.width,assetVideoTrack.naturalSize.height);
    21.         mutableVideoComposition.frameDuration = CMTimeMake(1, 30);
    22.  
    23.         // The rotate transform is set on a layer instruction
    24.         instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
    25.         instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [mutableComposition duration]);
    26.         layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:(mutableComposition.tracks)[0]];
    27.         [layerInstruction setTransform:transform atTime:kCMTimeZero];
    28.  
    29.     // Add a conversion instruction to the video
    30.     instruction.layerInstructions = @[layerInstruction];
    31.     mutableVideoComposition.instructions = @[instruction];
    32.  
    33. // Use AVAssetExportSession export video
     
  9. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    The video is not upside down for me, and does not need any modifications like this. Is Everyplay producing an upside down video for you?