Boaz
Boaz

Reputation: 5084

Video orientation is incorrect on FireFox

I have html5 video tags of videos. On chrome all is good, on firefox the orientation of landscape videos is wrong...

Even tried using video.js, no change.

I read that this is a problem because the videos originated in iOS.

so 2 questions: 1. How can I still overcome this issue. Really there is no solution? 2. (out of curiosity) - how does chrome manage to overcome this?

Example of a URL (scroll down a bit in the chapters to see a vertical video):
http://www.letsfeedme.com/moments/55802f142f2dad3c008b4575-Balsamic-Vinegar-%22Caviar%22

Upvotes: 10

Views: 11539

Answers (4)

octavn
octavn

Reputation: 3285

I read that this is a problem because the videos originated in iOS.

All videos recorded using mobile devices will contain rotation metadata including those from iOS and Android devices. It can take 4 values: 0 (tilted left), 90 (portrait), 180 and 270:

enter image description here

On chrome all is good, on firefox the orientation of landscape videos is wrong...

Firefox and IE 10 are the only major browsers not supporting the rotation metadata. Here's Firefox compared with Chrome:

enter image description here

The latest version, Firefox 42 as of today, still does not support it. IE11 and Edge 12,13 do support it.

List of mobile/desktop players that support the rotation info: https://blog.addpipe.com/mp4-rotation-metadata-in-mobile-video-files/

How can I still overcome this issue. Really there is no solution?

See this answer for the solution, basically you need to :

  1. rotate videos using FFmpeg (so Firefox and other browsers that do not support the rotation metadata show the video properly)
  2. remove the rotation metadata (so that other players don't rotate the video since it's already been rotated by FFmepg)

Images courtesy of: https://blog.addpipe.com/mp4-rotation-metadata-in-mobile-video-files/

Upvotes: 4

Foaster
Foaster

Reputation: 656

Since the problem is with some iOS specific encoding options, which many NOT-Apple Players can't read, the easiest solution I can think of is to trancode and rotate the video.

Which was already discussed in oh so many posts on the web and here at SO... e.g.:

Video orientation using video.js

HTML5 mp4 video with firefox resizing video

Chrome HTML5 Video Flipping Portrait Sideways

http://help.videojs.com/discussions/problems/1508-video-orientation-for-iphone-wrong

Upvotes: 3

Jimadine
Jimadine

Reputation: 1064

Probably not really a viable solution but adding a CSS rule such as

video {
 -moz-transform: rotate(90deg);
}

would at least make the videos play back in the correct orientation in Firefox. Problems with this:

  • videos that play back in the correct orientation without the rule will play back in the wrong orientation with the rule

  • the video controls also get rotated

  • the posters will display in the wrong orientation

I see your site uses video.js. It might be worth looking at https://github.com/xbgmsharp/videojs-rotatezoom ?

Upvotes: 1

Jimadine
Jimadine

Reputation: 1064

I am guessing that Chrome is respecting the width="360" and height="640" attributes of your <video> tags, while Firefox is not. If I download one of your videos and play it back in Media Player Classic, again the orientation is incorrect. But just like in web browsers, there are inconsistencies: the same video opened in VLC player plays back with the correct orientation.

I would recommend that, if you can, you re-encode the videos using a (free) program called AVIdemux. I just tried it on one of your videos, and it worked well with minimal effort. As a bonus it shrunk your video down considerably, with only minimal quality loss.

Here are the steps:

  1. Download AVIdemux from http://www.fosshub.com/Avidemux.html
  2. Install and run AVIdemux
  3. Go to File menu and choose Open. Pick the video to re-encode.
  4. Go to Video menu and choose Filters
  5. Choose Transform > Rotate (double-click) > Rotate by 270 degrees (OK)
  6. Click the Preview button to check the output
  7. Click the Close button
  8. In the main window, under Video Output, choose MPEG4-AVC (x264)
  9. Under Output Format, choose MP4 Muxer
  10. Click the Save Video icon, and in the resulting window type a filename and click the Save button.

Then you will need to re-upload your video.

Upvotes: 3

Related Questions