# mp4 file input to detectnet-video

**URL:** <https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033>\
**Category:** Jetson Nano\
**Created:** [February 14, 2020, 3:12pm UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033 "2020-02-14T15:12:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shankarprasad\_hm](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shankarprasad\_hm](https://forums.developer.nvidia.com/u/shankarprasad_hm)\
**Post date:** [February 14, 2020, 3:12pm UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033/1 "2020-02-14T15:12:37Z")

</div>

Hi,

I am giving a video file as an input to detectnet-video.py.  
It works fine if I give an .avi file which has resolution of 320x240.  
But it is not working for the same file which is in .mp4 file format. I am getting the below error,

```
frame_rgba = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)

```

cv2.error: OpenCV(4.2.0-dev) /home/jetbot/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !\_src.empty() in function ‘cvtColor’

Let me know if there is a limitation to use only .avi file?  
What is the solution for the above error?

Below is my code.

cam= cv2.VideoCapture(“/home/jetbot/models/research/object\_detection/easy.mp4”)  
while display.IsOpen():

```
ret, frame = cam.read()
print('frame:',ret,frame)
frame_rgba = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
width = frame.shape[1]
height = frame.shape[0]
img = jetson.utils.cudaFromNumpy(frame_rgba)

    detections = net.Detect(img, width, height, opt.overlay)

```

---

<div class="post-metadata">

**Author:** ![shankarprasad\_hm](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shankarprasad\_hm](https://forums.developer.nvidia.com/u/shankarprasad_hm)\
**Post date:** [February 16, 2020, 2:44pm UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033/2 "2020-02-16T14:44:12Z")

</div>

Hi,

I found that the .avi file is having Mpeg1 video codec in it. Hence it is working.

Where as .mp4 file is having MPEG4 video codec in it and it is not working.

So far now, I did convert .mp4 to avi with MPEG-1 as video codec and with it is working.

Let me know how to make MPEG4 video codec to work with detecnet code for object detection.

Regards,  
Shankar

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [February 18, 2020, 2:45am UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033/3 "2020-02-18T02:45:55Z")

</div>

Hi,  
Looks like it does not use hardware decoders on Jetson Nano. Could you please try DeepStream SDK? It is optimal for running deep learning inference on Jetson platforms. You can install the package through SDKManager.

Release announcement:  
[https://devtalk.nvidia.com/default/topic/1068639/deepstream-sdk/announcing-deepstream-sdk-4-0-2/](https://devtalk.nvidia.com/default/topic/1068639/deepstream-sdk/announcing-deepstream-sdk-4-0-2/)

---

<div class="post-metadata">

**Author:** ![vamarc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@vamarc](https://forums.developer.nvidia.com/u/vamarc)\
**Post date:** [May 11, 2020, 11:34am UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033/4 "2020-05-11T11:34:44Z")

</div>

Many thanks for this post as I was struggling to find a way to get video files to work in general. All samples I have seen so far had either Camera or Image as inputs.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 14, 2021, 10:01pm UTC](https://forums.developer.nvidia.com/t/mp4-file-input-to-detectnet-video/112033/5 "2021-10-14T22:01:50Z")

</div>

Closed on October 14, 2021, 10:01pm UTC


