I have an h265 file that was recorded on the oak-d.  I am currently attempting to replay that file using the oak-d in order to run a custom model on each frame.  I want to run the model after the original recording has finished which is why I am attempting to use the replay feature.
  
I am attempting to roughly follow the example here, but I'm having a lot of difficulty pulling the frames from the video.  For my current test, I am simply trying to read the first few frames from the h265 file and save them to a new video file.
  
Here is my current code:
from depthai_sdk import OakCamera, RecordType
import depthai as dai
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--path', default="data", type=str, help="Path to the stored replay")
args = parser.parse_args()
with open('video2.h265', 'wb') as videoFile:
    with OakCamera(replay=args.path) as oak:
        color = oak.create_camera('color', encode='H265')
        nn = oak.create_nn('mobilenet-ssd', color)
        # oak.record([color.out.encoded], './', RecordType.VIDEO)
        oak.visualize([color.out.encoded], fps=True)
        
        pipeline = oak.build()
        oak.start()
        print(oak.device.getInputQueueNames())
        print(oak.device.getOutputQueueNames())
        q = oak.device.getOutputQueue('1_bitstream') # Create output queue after calling start()
        try:
            frame_count = 0
            while oak.running() and frame_count < 450:
                if q.has():
                    h265Packet = q.get()  # Blocking call, will wait until a new data has arrived
                    print(h265Packet)
                    h265Packet.getData().tofile(videoFile)  # Appends the packet data to the opened file
                    frame_count +=1 
                    print(frame_count)
                oak.poll()
        except KeyboardInterrupt:
            # Keyboard interrupt (Ctrl + C) detected
            pass
        # xout = pipeline.create(dai.node.XLinkOut)
        # xout.setStreamName('h265')
        # # color.node.video.link(xout.input)
        # videoEnc = pipeline.create(dai.node.VideoEncoder)
        # videoEnc.setDefaultProfilePreset(30, dai.VideoEncoderProperties.Profile.H265_MAIN)
        # oak.video.link(videoEnc.input)
        # videoEnc.bitstream.link(xout.input)
Here is the error I receive when running this code:
pi@oak2:~/jack $ python replay_example.py -p /home/pi/storage/2023-07-12/color.h265
[2023-07-19 15:24:19] INFO [root.__init__:111] Available streams from recording: ['color']
[18443010D1805B1200] [1.1] [2.671] [DetectionNetwork(3)] [warning] Network compiled for 6 shaves, maximum available 15, compiling for 7 shaves likely will yield in better performance
['color_in']
['1_bitstream']
[18443010D1805B1200] [1.1] [4.083] [VideoEncoder(1)] [critical] Out of memory while creating pool for 'bitstream' frames. Number of frames: 4 each with size: 12604928B
After printing this out, the code just hangs, with q.has() always being False.
*Note - working through the example it looks like I would be able to pull the model output without trouble, however I will need to rewrite some of the video file as the model I plan to use will act as a filter for which frames to save and which to not save for future use.  I would like to use the oak encoder to write the frames we want to save, as I am running the oak on a rasberry pi, and using cv2 to write those frames via the rasberry pi is too slow to be viable.