Log in or register to post comments

VideoPlayback video moves a lot

October 17, 2013 - 3:54pm #1

Hey there,

So I’ve been working on a project that's using the VideoPlayback sample code, to play a video on a marker image when the marker is detected. The sample code consisted of 2 videos tracking 2 different markers, stones, and chips.

For my project, I only need to track 1 target, and play 1 video.

The sample code was set up to play the video when the “play” button was clicked. I had to do a lot of work to get the video playing automatically.

Before I get into my issue, I should probably put into context what I’ve done so far, to further help you answer the question.

First of all, I saw this URL, and made sure I covered all those steps (in reverse since I’m not adding a new target but taking one away)



Within the VideoPlayback.cpp native code


I changed the NUM_TARGETS to 1, and commented out the CHIPS variable.


Static const in NUM_TARGETS = 1;

static const int STONES = 0;

// static const in CHIPS = 1;


I then commented out the FLfloat videoQuadTextureCoordsTransformedChips[] variable.

In “LoadTrackerData”, I made sure my database name was correct

In “SetVideoDimensions”, I commented out the If and else statement, but left the body of the if statement alone.

uvMultMat4f(videoQuadTextureCoordsTransformedStones[0], videoQuadTextureCoordsTransformedStones[1], videoQuadTextureCoords[0], videoQuadTextureCoords[0], videoQuadTextureCoords[1], mtx);



Now for the biggest changes, in order to play the video only, and not display the thumbnail images at beginning and end of video.

Within “RenderFrame”, inside the for loop for having found trackables, I set currentTarget = 0; Then commented out the:

// if(strcmp(imageTarget.getName(), “stones”) == 0)

//          currentTarget = STONES

Then to eliminate the thumbnail stuff, I had to comment out the entire if statement

// If the movie is ready to start playing or it has reached the end of playback we render the keyframe

I left the else statements body

// In any other case, such as playing or paused, we render the actual contents

But I wrapped the body of it around:

If( (currentStatus[currentTarget] == PLAYING) || (currentStatus[currentTarget] == PAUSED) || (currentStatus[currentTarget] == STOPPED))

Within the body of that if, I commented out the strcmp(…) if statements surrounding the:

glVertextAttribPointer(…) function

but left the function call alone, and commented the else out fully, including the glVertextAttribPointer(…) function

Lastly, I commented out the entire last If statement

// The following section renders the icons. The actual textures used are loaded from the assets folder


Within the VideoPlaybackRenderer.java


In the constructor, under initializing the arrays, I changed mShouldPlayImmediately[i] to true, but that made no significant change

In the OnDraw function, under the native call to renderFrame, the for loop was changed to:

for(int I = 0; I < VideoPlayback.NUM_TARGETS; i++)




If(mVideoPlayerHelper[i] != null)


mVideoPlayerHelper[i].play(false, -1);





if(mVideoPlayerHelper[i] != null)






There is no significant changes to the VideoPlayback.java file though.


So now to my question. (Sorry this is long)

Can you see anything significant that would cause the video to play smoothly, but like, move around and jitter quite a bit? Even when I’m holding the phone over the marker very steady and not moving, it seems to jitter, flicker, move, etc.

I’ve taken a look at the near / far clipping solution and that doesn’t seem to do it. The sample code didn’t jitter, flicker, etc that significantly.

Please let me know if you can help!

Thank you!

PDF icon Post.pdf55.5 KB

VideoPlayback video moves a lot

October 28, 2013 - 11:04am #8

Sorry - I confused your question w/ another Unity post. Can you share your target image w/ Ale and me? - you can PM us.

VideoPlayback video moves a lot

October 28, 2013 - 10:32am #7

Thank you for your reply, however I apologize because I thought I mentioned it.

This isn't in Unity. It's on Android. So I can't capture an image or anything for you to see, unless I capture the image on the device, which I don't believe I can since the work is under NDA.

I can tell you though, that the videos pose calculation has not changed. It is still being calculated to center itself on top of the marker.

I am using a 570 x 570 image as the marker target, and the video is 570 x 570 so that it fits exactly with the marker.

"If the Field of View of the camera isn't capable of capturing an adequate area of the target, this can also introduce jitter." - This, I don't believe, is the issue because the nearPlane and farPlane haven't been modified, (2, and 2500), and whenever the marker is detected and the video plays, the marker is in full frame within the cameras view. Yet it still jitters quite a bit.

As for the direction of the jitter, I would say it depends (on what, I'm not sure), because sometimes the jitter is suttle, yet other times, it seems to jitter in 2, and sometimes all 3 axis'.

The video has alot of transparency in it, so it's extremely noticeable...however the transparency isn't the issue at all because this was happening and having the same effect before I figured out the transparency part.

VideoPlayback video moves a lot

October 25, 2013 - 4:04pm #6

A few more questions..

1. Is the video prefab instance parallel to the plane of the target?

2. Is it directly on top of the target - significantly offsetting the video vertically or laterally from the center of the target can introduce errors in pose estimation that will produce the jitter you're seeing. 

3. How large is the physical target you're using, and how large is the video relative to the target area - if the Field of View of the camera isn't capable of capturing an adequate area of the target, this can also introduce jitter. And the same can happen if the video is significantly larger than the target area. 

4. Is the jitter is 3 dimensions? - if it's only lateral, the video file may be the source of the jitter.

If none of this advice helps, please post a screen grab of your Unity scene showing the hierarchy - you can PM me if you'd prefer to do keep the scene private. 

VideoPlayback video moves a lot

October 25, 2013 - 3:48pm #5

Thank you, however that didn't address my issue.

I've got the video playing automatically when the marker is detected, and instead of pausing when it's not detected, I created a rewind function similiar to the stop function, but rewinds the video to start playback at the beginning again when the marker is detected again.

I also added transparency to the video I'm playing. However that was just some spice. It clearly wouldn't help the issue.

The issue at hand is the fact that the video seems to jitter quite a bit, even if the camera is steady. I did notice however, that when I pull the camera back from the marker more and more, the "jitterness" becomes less and less.

Can someone explain what they might think is wrong?


Also on another note, The camera is set to have a nearPlane of 2.0, and a farPlane of 2500, which causes the video to be occluded if outside this range.
If outside the range, but still over the marker, it still registers that the marker is detected and continues to play the video (Which at this point you'd only be able to hear the video.

Is there any way of fixing this?

VideoPlayback video moves a lot

October 21, 2013 - 12:41am #4

Hi ! I  am not sure that I directly respond to ur question, but to make the video call automatically you just need to add a few lines of code in side renderFrameQCAR () method after this comment:

        // --- INFORMATION ---

        // One could trigger automatic playback of a video at this point.  This

        // could be achieved by calling the play method of the VideoPlayerHelper

        // object if currentStatus is not PLAYING.  You should also call

        // getStatus again after making the call to play, in order to update the

        // value held in currentStatus.

        // --- END INFORMATION ---


        if (currentStatus !=PLAYING) {

               [videoPlayerHelper[playerIndex] play:NO fromPosition:VIDEO_PLAYBACK_CURRENT_POSITION];

            currentStatus=[videoPlayerHelper[playerIndex] getStatus];




- To pause it automatically after camera move away from target : renderFrameQCAR () method

renderFrameQCAR () method


    // --- INFORMATION ---

    // One could pause automatic playback of a video at this point.  Simply call

    // the pause method of the VideoPlayerHelper object without setting the

    // timer (as below).

    // --- END INFORMATION ---


    for (int i = 0; i < NUM_VIDEO_TARGETS; ++i) {

        if (nil == trackingLostTimer && NO == videoData[i].isActive && PLAYING == [videoPlayerHelper[i] getStatus]) {

            //[self performSelectorOnMainThread:@selector(createTrackingLostTimer) withObject:nil waitUntilDone:YES];


            [videoPlayerHelper[i] pause];

            trackingLostTimer = nil;





VideoPlayback video moves a lot

October 18, 2013 - 7:09am #3

Yes I did replace the target with my own. The target is a 5 star rating too. So something else must be going on.

VideoPlayback video moves a lot

October 18, 2013 - 12:25am #2

Have you replaced the stones target with your own Image target ? if so, what is the 'star rating' of your target?

If it is low (e.g. 1-2 stars) that could explain the jitter (with respect to the official sample).

see also:





Log in or register to post comments