# Video views in Viktor

**URL:** <https://community.viktor.ai/t/video-views-in-viktor/2580>\
**Category:** Feature Requests\
**Tags:** frontend, status:in-discussion\
**Created:** [19 June 2025 07:34 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580 "2025-06-19T07:34:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vuquochuy](https://community.viktor.ai/letter_avatar_proxy/v4/letter/v/ed655f/32.png) [@vuquochuy](https://community.viktor.ai/u/vuquochuy)\
**Post date:** [19 June 2025 07:34 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580/1 "2025-06-19T07:34:20Z")

</div>

Hello,

I’d like to ask if it’s possible to insert a video and play it in Viktor? In case it’s not possible, what could be the alternatives?  
Thank you in advance.

Huy

---

<div class="post-metadata">

**Author:** ![rdejonge](https://community.viktor.ai/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@rdejonge](https://community.viktor.ai/u/rdejonge)\
**Post date:** [19 June 2025 12:51 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580/2 "2025-06-19T12:51:32Z")

</div>

Hi Huy,

You could use a webview with a video element as follows:

```python
import viktor as vkt

class Parametrization(vkt.Parametrization):
    # Video URL input
    video_url = vkt.TextField(
        "Video URL", 
        default="https://www.w3schools.com/html/mov_bbb.mp4",
        description="Enter the URL of your video file (MP4, WebM, OGV formats supported)"
    )

class Controller(vkt.Controller):
    parametrization = Parametrization

    @vkt.WebView("Video Player", duration_guess=1)
    def show_video(self, params, **kwargs):
        """
        Display a simple video player using HTML5 video element.
        """
        
        # Check if video URL is provided
        if not params.video_url:
            return vkt.WebResult(html="<p>Please enter a video URL.</p>")
        
        # Create minimal HTML content with video player
        html_content = f"""
        <video width="100%" height="400" controls>
            <source src="{params.video_url}" type="video/mp4">
            <source src="{params.video_url}" type="video/webm">
            <source src="{params.video_url}" type="video/ogg">
            Your browser does not support the video tag.
        </video>
        """
        
        return vkt.WebResult(html=html_content)

```

---

<div class="post-metadata">

**Author:** ![vuquochuy](https://community.viktor.ai/letter_avatar_proxy/v4/letter/v/ed655f/32.png) [@vuquochuy](https://community.viktor.ai/u/vuquochuy)\
**Post date:** [30 June 2025 08:50 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580/3 "2025-06-30T08:50:50Z")

</div>

Hello,

Thank you for your reply. If I do not want to put the video publicly on the web but store it either locally within my app or using a third-party bucket service, how to do? Actually I store the video in a folder within the app. When I provide the file path as url, only the video player is displayed but the video itself is not shown. When I try to read the video with Python, encode it and input as url, I got a message saying too much memory is using (the video size is about 100 MB).

Thanks again,  
Huy

---

<div class="post-metadata">

**Author:** ![rvandijk](https://community.viktor.ai/user_avatar/community.viktor.ai/rvandijk/32/866_2.png) [@rvandijk](https://community.viktor.ai/u/rvandijk)\
**Post date:** [2 July 2025 10:41 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580/4 "2025-07-02T10:41:53Z")

</div>

Hi Huy,

I’ve checked this out; and was only able to make it work as a URL (not locally from the app). Also, indeed, some URL don’t work due to permissions.

For me, what worked best was to:

- Add the file to the VIKTOR storage
- Load the file and get the URL (Storage is some online database, so `File.source` returns the URL)
- Use the video HTML to load it from URL.

See the following snippet, that’s not encoding the video:

```auto
@vkt.WebView("Video Player", duration_guess=1
def show_video(self, **kwargs):
    """
    Display a loaded video that is saved on VIKTOR Storage.
    """
        
    # If video is not on Storage yet, upload it
    if "video" not in vkt.Storage().list(scope="entity"):
        video_file = vkt.File.from_path(Path( __file__ ).parent / "vid.mp4")
        vkt.Storage().set("video", video_file, scope="entity")
    
    # Retrieve the video file from storage
    file_on_storage = vkt.Storage().get("video", scope="entity")
    
    # Generate HTML content to embed the video player
    html_content = f"""
<video width="100%" height="400" controls>
    <source src="{str(file_on_storage.source)}" type="video/mp4">
    <source src="{str(file_on_storage.source)}" type="video/webm">
    <source src="{str(file_on_storage.source)}" type="video/ogg">
    Your browser does not support the video tag.
</video>
    """
    return vkt.WebResult(html=html_content)

```

---

<div class="post-metadata">

**Author:** ![vuquochuy](https://community.viktor.ai/letter_avatar_proxy/v4/letter/v/ed655f/32.png) [@vuquochuy](https://community.viktor.ai/u/vuquochuy)\
**Post date:** [2 July 2025 11:26 UTC](https://community.viktor.ai/t/video-views-in-viktor/2580/5 "2025-07-02T11:26:59Z")

</div>

Hello Rvandijk,

Great, I’ll try it.

Thanks,  
Huy
