> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/video/video/comparing-videos.md).

# Comparing videos

Compare videos side by side with WebViewer Video to easily identify differences. Follow our guide to integrate compare into your application seamlessly. The Apryse Web SDK streamlines secure, serverle

WebViewer Video allows you to compare two videos side by side to easily spot differences between the two videos.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-7c5c82d441630e7ceb994de14609e63387521efd%2F17d8bfdc205e82e93312406a620a2c71bd0867a6-2556x1344.png?alt=media)

## Sample compare page

The WebViewer-Video github [sample](https://github.com/ApryseSDK/webviewer-video-sample/) has a compare sample ready to go. We recommend running that sample directly. To do so, first clone repository and then run the following commands:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
# command line
npm i
npm run start-samples
```

{% endcode %}
{% endtab %}
{% endtabs %}

The steps below will recreate the sample. Use them to integrate compare into you application.

### Initial setup

Before you begin, make sure your development environment includes [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/get-npm/).

### How to use

To load your video in compare; we used the [`enableCompareMode`](https://sdk.apryse.com/api/video/UI.html#.enableCompareMode__anchor) API. WebViewer Video will automatically configure everything to be setup. See the following code below on how to call this API:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
import React, { useRef, useEffect } from 'react';
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer } from '@pdftron/webviewer-video';

const App = () => {
    const viewer = useRef(null);
    const videoUrl = 'https://pdftron.s3.amazonaws.com/downloads/pl/video/video.mp4';

    useEffect(() => {
      WebViewer(
        {
          path: '/webviewer/lib',
        },
        viewer.current,
      ).then(async instance => {
        // Extends WebViewer to allow loading media files (.mp3, .mp4, ogg, webm, etc.)
        const {
            loadVideo,
            UI,
        } = await initializeVideoViewer(
            instance,
            {
                license: '---- Insert commercial license key here after purchase ----',
            }
        );

        await UI.enableCompareMode();

        // Load a video at a specific url. Can be a local or public link
        // If local it needs to be relative to lib/ui/index.html.
        // Or at the root. (eg '/video.mp4')
        loadVideo(videoUrl, { fileId: 'testId' });
      });
    }, []);

    return (
        <div className="App">
            <div className="webviewer" ref={viewer} />
        </div>
    );
}

export default App;
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Programatically load videos

Video compare brings two new APIs that allow users to programatically load videos on either side of the comparison. In this example we used [`loadCompareVideoB`](https://sdk.apryse.com/api/video/UI.html#.loadCompareVideoB__anchor) to load a video on the right side of the comparison. If you wish to load a video on the left side of the comparison, you can use [`loadCompareVideoA`](https://sdk.apryse.com/api/video/UI.html#.loadCompareVideoA__anchor).

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
import React, { useRef, useEffect } from 'react';
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer } from '@pdftron/webviewer-video';

const App = () => {
    const viewer = useRef(null);
    const videoUrl = 'https://pdftron.s3.amazonaws.com/downloads/pl/video/video.mp4';

    useEffect(() => {
      WebViewer(
        {
          path: '/webviewer/lib',
        },
        viewer.current,
      ).then(async instance => {
        // Extends WebViewer to allow loading media files (.mp3, .mp4, ogg, webm, etc.)
        const {
            loadVideo,
            UI,
        } = await initializeVideoViewer(
            instance,
            {
                license: '---- Insert commercial license key here after purchase ----',
            }
        );

        await UI.enableCompareMode();

        // Load a video at a specific url. Can be a local or public link
        // If local it needs to be relative to lib/ui/index.html.
        // Or at the root. (eg '/video.mp4')
        loadVideo(videoUrl, { fileId: 'testId' });

        window.addEventListener(
          'documentViewer2Ready',
          () => {
            UI.loadCompareVideoB(videoUrl);
          },
          { once: true },
        );
      });
    }, []);

    return (
        <div className="App">
            <div className="webviewer" ref={viewer} />
        </div>
    );
}

export default App;
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/video/video/comparing-videos.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
