Corrupted video from USB camera after reboot


I am using a Jetson Nano for an autonomous vehicle application which involves compositing video from 4 USB cameras and VP8 encoding the stream. The cameras that I’m using (ELP-USBFHD06H-L36) support streaming h264 encoded video and my gstreamer pipeline is essentially v4l2src -> nvv4l2decoder -> nvcompositor -> nvvidconv -> nvv4l2vp8enc -> appsink. The pipeline works well most of the time, however I am having issues whenever I reboot the Jetson Nano. The first time the pipeline is launched following a reboot, one or two of the cameras will have bad visual artifacts which will persist until the pipeline is destroyed and recreated. After the process has been restarted, the error will not occur again until the next reboot. Here is an image of the artifacts that I am seeing.

Screenshot from artifacts.mkv

I have a found a minimal pipeline capable of reproducing this issue:

GST_DEBUG=2 gst-launch-1.0 -ev v4l2src device=/dev/tinymile/video_usb2.1_1 ! video/x-h264,width=640,height=360 ! nvv4l2decoder ! nvv4l2vp8enc ! matroskamux ! filesink location=test.mkv

Here are logs from running this command: logs.txt (9.0 KB)

I have noticed a few things while experimenting:

  • This command can replicate the issue nearly 100% of the time, even if I wait a while after reboot
  • Changing the caps to video/x-h264,width=1920,height=1080 will eliminate the problem and will even temporarily prevent the issue from reoccuring with video/x-h264,width=640,height=360 following reboot, however the issue always comes back eventually
  • The actual video is vaguely visible (especially around the edges)
  • The negotiated caps seem to be same in both the corrupted and uncorrupted cases
  • The composited video can contain both corrupted and uncorrupted video streams which suggests that encoding is not the issue

Any ideas on what could be the cause of this or recommendations on how to debug this? I believe I could work around this issue by streaming 1920x1080 video and downscaling, however I would prefer if I could stream the video directly in 640x360.



Please run the pipeline to dump the h264 stream:

gst-launch-1.0  v4l2src device=/dev/tinymile/video_usb2.1_1 ! video/x-h264,width=640,height=360 ! h264parse ! video/x-h264,strea-format=byte-stream ! filesink location=dump.h264

And check if the h264 stream is good or corrupted. It is very likely the h264 stream is corrupted in this case.

I dumped the h264 stream and can confirm that I am still seeing the issue.

It is more like an issue that the source is not stable. Probably the power supply is not stable in first launch after reboot. The nvv4l2decoder and nvv4l2vp8enc plugins should work fine. Are you able to connect Jetson Nano to USB hub with external power supply and connect the camera to the hub? See if the source is more stable in this setup.

Thanks, I will experiment with a hub and power supply to see if this resolves the issue.