Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoTexture: Doesn't handle file rotation. #13671

Closed
4 of 7 tasks
MarcRibguth opened this issue Mar 23, 2018 · 16 comments
Closed
4 of 7 tasks

VideoTexture: Doesn't handle file rotation. #13671

MarcRibguth opened this issue Mar 23, 2018 · 16 comments

Comments

@MarcRibguth
Copy link

MarcRibguth commented Mar 23, 2018

Hallo,
It seems that the video from some mobile devices are not rotating correctly. I used the same video element for the right view and the left plain and the rotation is not the same. Other videos are working.

bildschirmfoto vom 2018-03-23 11-10-49

video.zip

Three.js version
  • r91
  • r89
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • Linux
@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 23, 2018

Um, it's not clear to me what's your issue. Can you please provide a live example that demonstrates the problem?

@MarcRibguth
Copy link
Author

MarcRibguth commented Mar 23, 2018

I can try to do thet, but I'm not shoure when I will have the time for that.
The probelm is, that I use the loaded video data to create the geometry of the mesh on the left side. That part is working fine. But when I load the video on to the plain, the video has not the right rotation like in the video element on the right side.

function loadedmetadataFunk(event) {

    if (event && event.path.length > 0 && event.path[0]) {

          mesh.geometry.dispose();
          mesh.geometry = new THREE.PlaneGeometry(event.path[0].videoWidth / 50, 
          event.path[0].videoHeight / 50);

    }

    showProgressSpinnerInEditor(false);
}

let vid = document.createElement("Video")
vid.src = url;
vid.load();
vid.addEventListener('loadedmetadata', loadedmetadataFunk);

let texture = new THREE.VideoTexture(vid);
texture.generateMipmaps = false;
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearFilter;
mesh.material = new THREE.MeshBasicMaterial({ map: texture });

I will try to create an example in the next days.

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 23, 2018

Please try your video with this live demo and test if the orientation is correct.

@MarcRibguth
Copy link
Author

MarcRibguth commented Mar 23, 2018

I checked it and the rotation is wrong. I also noticed, that Windows Media-Player is also not rotating the file correctly. In VLC-Player is the rotation right.

test
https://jsfiddle.net/wt77a5ug/#&togetherjs=KFlkmPq6A8

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 23, 2018

I don't think that's a three.js related issue. Or do you have a suggestion what the library should make different?

@MarcRibguth
Copy link
Author

I would expect that the texture has the same rotation like the video element I putted in. Or do you know a way to detract the rotation?

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 23, 2018

Or do you know a way to detract the rotation?

No. And i don't think that's the task of a 3D library.

You should first investigate why Windows Media-Player shows the same behavior.

@calrk
Copy link
Contributor

calrk commented Mar 25, 2018

The reason for this is most likely the video rotation metadata that has been saved in the video when filming on a mobile device. The mobile will record the video with whatever its default rotation is, then add in the rotation metadata for video players to use when playing back. The reason I believe is to reduce any video processing needed during recording.

Modern browsers will use this to rotate the videos in playback when using

I think the solution is to transcode the video without the rotation metadata.

@MarcRibguth
Copy link
Author

Thanks for the replies, then I have to close this issue and try to convert the files on the server.

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 26, 2018

@calrk Thanks for your explanation!

@mrdoob
Copy link
Owner

mrdoob commented Mar 27, 2018

@kenrussell what do you think about this? the browser applies the rotation specified in the video metadata when displaying it with <video> but the rotation gets lost when using it as a texture.

@MarcRibguth
Copy link
Author

I will reopen this and maybe you could make a feature out of this.

@MarcRibguth MarcRibguth reopened this Apr 9, 2018
@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 9, 2018

This rotation metadata is not available to Javascript, so can't be used by ThreeJS to rotate the video.

That's the reason why three.js can't do anything here. So reopening this issue makes no sense to me.

@calrk
Copy link
Contributor

calrk commented Apr 9, 2018

Yes I agree with @Mugen87 . Given my research into the problem I don't believe the solution can be implemented in three.js without updates to the browser video spec.

@Mugen87 Mugen87 closed this as completed Apr 9, 2018
@MarcRibguth
Copy link
Author

Maybe the video texture could load the video as file resource and read the file rotation direct?

@mrdoob
Copy link
Owner

mrdoob commented Apr 9, 2018

I think the browser is going to handle this (at least chrome).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants