Monday, 12 May 2025

How to read a mp4 video with h265 codec using python opencv gstreamer in jetson?

import cv2

import numpy as np

# Replace with your H.265 video file


gst_pipeline = (

    "filesrc location=/home/ninja/test1.mp4 ! "

    "qtdemux ! h265parse ! nvv4l2decoder ! "

    "nvvidconv ! video/x-raw,width=1920,height=1080,format=NV12 ! "

    "appsink"

)


cap = cv2.VideoCapture(gst_pipeline, cv2.CAP_GSTREAMER)

h = 1080

w = 1920

if not cap.isOpened():

    print("Failed to open video")

    exit()


while True:

    ret, frame = cap.read()

    if not ret:

        break

    frame = np.fromstring(frame, dtype=np.uint8).reshape((int(h*3/2),w,1))

    frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_NV12)    


    print(frame.shape)

    #cv2.imshow("Jetson H.265 Video", frame)

    #if cv2.waitKey(1) & 0xFF == ord("q"):

    #    break


cap.release()

cv2.destroyAllWindows()

Tuesday, 29 April 2025

Failed to initialize NVML: Unknown Error

 RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at ../aten/src/THC/THCGeneral.cpp:47

root@ninja:/data# 

root@ninja:/data# nvidia-smi

Failed to initialize NVML: Unknown Error

root@ninja:/data# exit


---

When entering the docker, try to add --privileged into the script

Thursday, 3 April 2025

Thursday, 16 January 2025

How to mount and umount the device in ubuntu?

to mount the device:

sudo lsblk

sudo mkdir /mnt

sudo mount /dev/sdc1 /mnt


to umount the device

sudo umount /mnt

or 

sudo umount /dev/sdc1

sudo udisksctl power-off -b /dev/sdc1