HTTPError: Timedout

so im trying to display a video on a part with frames, and to do that, i need to get the frames, and to do that i need to do some python stuff, and its god dam slow, how would i fix the error?

Can you be more specific about what doesn’t work? The error itself and the code

1 Like

heres the python function that im using to get the video pixels

def getVideoPixels(timestep):
    timestep = int(timestep)
    frame_count = int(vid.get(cv2.CAP_PROP_FRAME_COUNT))
    
    videoPixels = []
    timestamp = 1

    def getPixelsFromFrame():
        pixels = []
        vid.set(1, timestamp)
        res, frame = vid.read()

        # print(res)

        # print(timestamp)

        height, width, channels = frame.shape

        for x in range(0, width-1):
            for y in range(0, height-1):  
                color = []
                color.append(frame[y,x,2])
                color.append(frame[y,x,1])
                color.append(frame[y,x,0]) 

                pixels.append(color)

        return pixels
    
    frames_to_get = math.floor(int(frame_count / timestep))
    print(frames_to_get)
    for i in range(0, frames_to_get):
        timestamp = i
        videoPixels.append(getPixelsFromFrame())

    vid.release()

    print('request fulfilled')

    return videoPixels

full code:

from flask import Flask, render_template, request
import cv2
import math

vid = cv2.VideoCapture('videothing.mp4')

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')


@app.route('/get_pixels<timestep>', methods=['GET', 'POST'])
def get_pixels(timestep):
    if request.method == 'GET':
        return str(getVideoPixels(timestep))
    
    return render_template('index.html')


def getVideoPixels(timestep):
    timestep = int(timestep)
    frame_count = int(vid.get(cv2.CAP_PROP_FRAME_COUNT))
    
    videoPixels = []
    timestamp = 1

    def getPixelsFromFrame():
        pixels = []
        vid.set(1, timestamp)
        res, frame = vid.read()

        # print(res)

        # print(timestamp)

        height, width, channels = frame.shape

        for x in range(0, width-1):
            for y in range(0, height-1):  
                color = []
                color.append(frame[y,x,2])
                color.append(frame[y,x,1])
                color.append(frame[y,x,0]) 

                pixels.append(color)

        return pixels
    
    frames_to_get = math.floor(int(frame_count / timestep))
    print(frames_to_get)
    for i in range(0, frames_to_get):
        timestamp = i
        videoPixels.append(getPixelsFromFrame())

    vid.release()

    print('request fulfilled')

    return videoPixels

app.run(host='0.0.0.0', port=1111, debug=False)

(the function itself SHOULD work, but i think that it errors cause the function is tooslow)

python on devforum :exploding_head:

Not being a jerk, seriously, I don’t think this is a forum to help you on Python?? I think you might need to go to a python help forum for that kind of stuff…

1 Like

no i just want to know how do i fix the error??

Well, this isn’t a forum for helping users out on Python, so I think you should go to a python forum for this type of question

1 Like

its erroring on the roblox studio side, i just want someone that knows httpservice or smth

Then, the code is intended to do a Http request to get a specific frame of a video? On a pixel base in order to rebuild the data as a “image/frame”
By doing that, its possible to “play” frame by frame any video you want inside a roblox experience?..

My only concern its about if that is allowed by Roblox…

the http request is supposed to return all the frame’s pixels as a json string, i dont know what do you mean by image/frame

maybe not frame by frame (at least for me)

yes this is a private project

Yeah, thats obvious, I mean, you got the data per pixel as a “table” etc, and you have enough data to re-create a “frame” of a video.

So its “posible” to Play any video inside a roblox game, cause you have the pixels table of every frame.

Maybe Im just overthinking, but, what is the goal of your system?

yeah??? except the fact that it currently use local host so it wouldnt work on published games

bad apple in roblox

1 Like