# Playing a video using WebDev

**URL:** <https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622>\
**Category:** Ignition\
**Tags:** webdev\
**Created:** [September 30, 2024, 5:52pm UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622 "2024-09-30T17:52:11Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Alex\_Mulder](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alex\_Mulder](https://forum.inductiveautomation.com/u/Alex_Mulder)\
**Post date:** [November 7, 2024, 10:20pm UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/21 "2024-11-07T22:20:23Z")

</div>

I'm not getting any content header, the file is download straight without even opening a windows so I'm not able to use the inspection tool, that's why I'm saying that maybe is a problem about the playlist file  
the only content I'm able to play through the browser are .mp4 file and i get of course type:video/mp4  
I even tired intercepting the traffic usaing burpsuite but no traffic is created at all

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 8, 2024, 1:44am UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/22 "2024-11-08T01:44:51Z")

</div>

Try a tool like `wget` with verbose mode turned on.

---

<div class="post-metadata">

**Author:** ![Alex\_Mulder](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alex\_Mulder](https://forum.inductiveautomation.com/u/Alex_Mulder)\
**Post date:** [November 8, 2024, 2:16am UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/23 "2024-11-08T02:16:41Z")

</div>

I get [Content-Type, application/octet-stream] but for all type of file .ts .mp4 and .m3u8, anyway I tried to change all the file type in Ignition, booth keeping video/MP2T for .ts and application/octet-stream for .m3u8 or applying application/octet-stream for both .ts and .m3u8 and still getting the same result

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 8, 2024, 2:18am UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/24 "2024-11-08T02:18:52Z")

</div>

Then you cannot use a mounted folder. You will need to use jython doGet() script methods where you can explicitly control the content type for every response.

Also, go look at [comment 15](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/15) for the correct filetype for an m3u8 playlist.

---

<div class="post-metadata">

**Author:** ![Alex\_Mulder](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alex\_Mulder](https://forum.inductiveautomation.com/u/Alex_Mulder)\
**Post date:** [November 8, 2024, 2:52am UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/25 "2024-11-08T02:52:09Z")

</div>

ok I will try ,in the meantime I just compressed the videos enough to be uploaded with WebDev but now the resolution is quite bad so for sure I'll give a try with jython code, thanks a lot for your time

---

<div class="post-metadata">

**Author:** ![Curtis\_Stacy](https://avatars.discourse-cdn.com/v4/letter/c/ed8c4c/32.png) [@Curtis\_Stacy](https://forum.inductiveautomation.com/u/Curtis_Stacy)\
**Post date:** [November 13, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/26 "2024-11-13T15:08:39Z")

</div>

I also went down the path of trying to send a playlist.m3u8 file to the VideoPlayer, using the suggestions above. In my WebDev Python resource, I tried setting different contentTypes and response types. I also played with the tags and segment paths in the playlist file.

I had the same result, where the Perspective player didn't recognize it. I could download the file using the WebDev URL in the browser and other players such as VLC or Windows Media Player could play it.

I ended up using ffmpeg to compress the original mp4 files and sending the full compressed version to the VideoPlayer.

---

<div class="post-metadata">

**Author:** ![Alex\_Mulder](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alex\_Mulder](https://forum.inductiveautomation.com/u/Alex_Mulder)\
**Post date:** [November 14, 2024, 9:41pm UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/27 "2024-11-14T21:41:21Z")

</div>

I did the same, I'm going to make a script as soon as I finish some other jobs, and then I'll upload the code and maybe try again also with the playlist files with the help of a contact from Inductive team, anyway I'll upload any useful methods or code here

---

<div class="post-metadata">

**Author:** ![Alex\_Mulder](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alex\_Mulder](https://forum.inductiveautomation.com/u/Alex_Mulder)\
**Post date:** [November 19, 2024, 12:19am UTC](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622/28 "2024-11-19T00:19:30Z")

</div>

I created a web server using python that serve the video on localhost then from the video component i just put the exposed url  
this is the python server, i also created a service to run at every boot

```python
from flask import Flask, send_file
from os import listdir
from os.path import isfile, join
import os
from waitress import serve

app = Flask( __name__ )

VIDEO_DIRECTORY = 'videos/' # Replace with your actual video directory
#get all file in the video folder
onlyfiles = [f for f in listdir(VIDEO_DIRECTORY) if isfile(join(VIDEO_DIRECTORY, f))]

@app.route('/video/<filename>')
def serve_video(filename):
    #prevent traversal directory attack
    filename = os.path.basename(filename)
    #check that filename is compatible with available videos
    if filename not in onlyfiles:
        return 'Invalid file name.', 404    
    file_path = os.path.join(VIDEO_DIRECTORY, filename)
    allowed_extensions = {'mp4'} # Adjust as needed
    if '.' not in filename or filename.rsplit('.', 1)[1].lower() not in allowed_extensions:
        return 'Invalid file format.', 400
    
    return send_file(file_path, mimetype='video/mp4') # Adjust mimetype as needed

if __name__ == ' __main__':
    serve(app,host='0.0.0.0',port=xxxx)

```

then in the video component i just set as source [http://0.0.0.0](http://0.0.0.0):xxxx/video/videoname.mp4

of course the script might need some changes based on your requirements

[Previous page](https://forum.inductiveautomation.com/t/playing-a-video-using-webdev/96622.md?page=1)
