Checking if iOS mirrored a video on the server

Does anyone happen to know how to tell if an ios recorded video with the front camera was mirrored by looking at the actual file? I’ve been inspecting the metadata and all I can see is the rotation params which does not tell me if the video needs to be horizontally mirrored or not.

I’ve used ffmpeg to inspect the video and could not find any flag for orientation or mirroring, only for rotation.

Anybody have experience with this?

Managed 39

Sorry, I don’t have experience with this myself, but the following page and related pages imply that there is metadata for mirroring/rotation, although it does not give the details of what the metadata actually looks like:

This post has some useful looking info. It talks mostly about rotation rather than flipping/mirroring, but the article it refers to does mention flipping, even though the author doesn’t see when they would be used:

There’s also a JS library that might help. See also the othe answers/comments. Although they’re talking about client-side solutions, some of them seem like they should be applicable to the server-side or could possibly point you in the right direction:

Searching for "exif" "orientation" brings up lots of other things to look into if the above isn’t enough.

Good luck :slight_smile:

EDIT: I also just found this summary of the Orientation values:

From exiftool documentation

1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW

Thanks for the reply @wodin. I’ll take a look but the issue seems to be that all this documentation is for images.

For a video, for example, exiftool does not show “Orientation” values, just the rotation (but not if it needs to be mirrored).

Same thing when I parse the metadata with ffmpeg…when I put it side-by-side with a video that does not need mirroring…I cannot find a consistent marker.

There is this thing called “Display Matrix” in the meta data and I thought that was it, but then I tried on a few phones with a few videos and there is nothing about the matrix that consistently changes when it needs mirroring (that I know of). In addition when you google “display matrix ios developer” you get basically no documentation.

I’d be surprised if no one else had encountered this issue.

Ah sorry, I missed the video requirement.

No worries… I “think” I found the flag for horizontal flipping in case anyone is interested…

 # @aryk - After some experimenting on iphone 6, iphone X, and Android phone...when using front facing
            # camera, the display matrix will have 00000001:        65536 and when using the normal camera
            # will have 00000001:        -65536, so detecting the positive number means we need to mirror horizontally (I hope)
            if begin
                detect {|s| s[:side_data_list]}[:side_data_list].
                detect{|sdl| sdl[:side_data_type] == "Display Matrix"}[:displaymatrix].
            rescue Exception => e
              transcode_options[:custom] = %w{-vf hflip}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.