Topic locked

Modifying the scale of the video plane in the Video Playback Sample app

July 24, 2012 - 10:56am #1

Hey all,

I was wondering if its possible to override the scale of the plane that the video plays back on in the Vuforia Video Playback sample app.

I tried simply scaling the "Video" child object of the "ImageTarget" in the example.  After scaling and positioning the video, i deploy to my droid and the video is resetting to the previous side (probably because its determining its size based on the 640x360 video file im passing in.

Can I override this so I can scale my video down?

Modifying the scale of the video plane in the Video Playback Sam

December 22, 2014 - 12:56am #15

JansenSensei,

some comments:

1. the VideoPlaybackBehaviour.cs script that is referred to in this thread is located in the VideoPlayback sample project, which you can download from:

https://developer.vuforia.com/resources/sample-apps/video-playback-sample-app

Another useful script to look at is the VideoPlayerHelper.cs, in the same sample project.   Note that all the sample scripts can be found under the Assets directory.

2. the topic in this thread is about how to resize the plane on which the video rectangle texture is applied to; as you can imagine, this is related to a piece of sample application logic, and not a Vuforia API or Vuforia -specific feature;  in fact, if you analyze the topic closely, the basic question here is essentially about "how to rescale a textured plane in Unity";   this is in fact a general Unity-programming and C# programming question, not a Vuforia-specific issue; in fact,  the plane on top of which the videoplayback texture is applied is a standard Unity plane, and you control its scale and size with Unity API and with geenral C# programming, as shown in the example snippet below, for instance:

transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f * aspect);

Also, the computation of the aspect ratio (the "aspect" variable) is also based on a width and height parameters of the loaded video file (again, this does not come from the Vuforia API or from a Vuforia feature, as you will realize by looking at the sample code that handles the video file width and height in the sample code, in particular, by looking at the VideoPlayerHelper.cs script).

See also Unity Transforms API reference:

http://docs.unity3d.com/ScriptReference/Transform.html

 

 

 

Modifying the scale of the video plane in the Video Playback Sam

December 20, 2014 - 2:55am #14

Why am I not seeing this file in my project???

Does it get installed with vuforia or with one of the demos?

It truly is frustrating asking for help on one single issue over and over on multiple threads for days on end and not getting any response from the admins at all...

Why does the output in the editor and the output on the target device not look the same? How do I make it work? Seems nobody knows... :( Seems the purpose of htis forum is to showcaseto the world how little anyone knows about Vuforia, rather than getting actual help :( A real shame cause I was becomming a really big fan of this kit... :(

Modifying the scale of the video plane in the Video Playback Sam

July 23, 2013 - 7:09am #13

I positioned the video prefab but it resets the position when I launch the app.

 

In that case you will need to set the position at runtime programatically.

Modifying the scale of the video plane in the Video Playback Sam

July 23, 2013 - 4:57am #12

I positioned the video prefab but it resets the position when I launch the app.

Modifying the scale of the video plane in the Video Playback Sam

July 22, 2013 - 1:01pm #11

You can reference the game object with the script attached and set its position programatically - or you can position the video prefab in the editor.

Modifying the scale of the video plane in the Video Playback Sam

July 22, 2013 - 5:20am #10

Thanks for the information on this topic. But I need one more thing. If I wanted to change the position of the video how can I achieve that?

Modifying the scale of the video plane in the Video Playback Sam

April 2, 2013 - 6:54am #9

I was also having this problem, and this thread has help me a lot (thanks!)

My two cents: This hack will allow to enable/disable free-aspect from the Inspector panel.

Edit the VideoPlaybackBehaviour.cs, and add the following within the PUBLIC_MEMBER_VARIABLES #region:

#region PUBLIC_MEMBER_VARIABLES

/// <summary>
/// keep aspect ratio.
/// </summary>

public bool KeepAspectRatio = true;

Then edit line that reads if (videoWidth > 0 && videoHeight > 0) and change it to read as below:

                    // Get the video width and height
                    int videoWidth = mVideoPlayer.GetVideoWidth();
                    int videoHeight = mVideoPlayer.GetVideoHeight();

                    if (KeepAspectRatio && videoWidth > 0 && videoHeight > 0) // <-- Edit this line
                    {
                        // Scale the video plane to match the video aspect ratio
                        float aspect = videoHeight / (float) videoWidth;

                        // Flip the plane as the video texture is mirrored on the horizontal
                        transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f * aspect);
                    }

This way, a check box "Keep Aspect Ratio" will appear in the Video Prefab and one can enable/disable the Video aspect ratio. :)

Modifying the scale of the video plane in the Video Playback Sam

November 19, 2012 - 12:30pm #8

my video format is m4v and http://s15.postimage.org/6pb3ce7vv/ssssss.jpg how can i fix screen ? 

Modifying the scale of the video plane in the Video Playback Sam

November 19, 2012 - 11:34am #7

What format of video are you using -- and can you post a screen grab of your video?

 

* I've replied to your other post on this question, please respond to that post rather than this one.

Modifying the scale of the video plane in the Video Playback Sam

November 19, 2012 - 10:52am #6

Hi david my video is vertical  and it is not playing on full screen. 

how can i fix that ? 

or any1 help ?

That worked perfectly, thanks

August 7, 2012 - 11:52am #5

Makes total sense.  Now it behaves the way I need for my use case.  Thanks again.

Modifying the scale of the video plane

August 3, 2012 - 6:45pm #4

This is the section that VinceKilian is referring to, it starts on line 186 in the current release ..

 

                    // Get the video width and height
                    int videoWidth = mVideoPlayer.GetVideoWidth();
                    int videoHeight = mVideoPlayer.GetVideoHeight();

                    if (videoWidth > 0 && videoHeight > 0)
                    {
                        // Scale the video plane to match the video aspect ratio
                        float aspect = videoHeight / (float) videoWidth;

                        // Flip the plane as the video texture is mirrored on the horizontal
                        transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f * aspect);
                    }

This issue is affecting me as well

August 3, 2012 - 5:49pm #3

It's causing me trouble too.  I think my version of the script must be slightly different, as line 200 is:

if (mSeekPosition > 0)

I may figure it out myself shortly... but what was the content of the line you commented out?  Thanks in advance!

Solved

July 24, 2012 - 12:01pm #2

I figured it out.  I commented out the code on line 200 of the VideoPlaybackBehaviour script and I've acheived the functionality I was after.

Topic locked