- 使用usb摄像机采集并显示视频。
gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, width=1280, height=1024, format=(string)YUY2" ! xvimagesink -e
使用gst-omx进行视频解码
H264解码
gst-launch-1.0 filesrc location=sample_1080p_h264.mp4 ! \
qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! \
nveglglessink -e
H265解码
gst-launch-1.0 filesrc location=sample_1080p_h265.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h265parse ! omxh265dec ! nveglglessink -e
使用gst-v4l2进行解码
gst-launch-1.0 filesrc location=sample_1080p_h264.mp4 ! \
qtdemux name=demux demux.video_0 ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e
使用硬件解码器到最大性能,可以加一个选项
gst-launch-1.0 filesrc location=sample_1080p_h264.mp4 ! \
qtdemux name=demux demux.video_0 ! queue ! h264parse ! nvv4l2decoder enable-max-performance=1 ! nv3dsink -e
H265解码
gst-launch-1.0 filesrc location=sample_1080p_h265.mp4 ! \
qtdemux ! queue ! h265parse ! nvv4l2decoder ! nv3dsink -e
使用gst-omx 进行H264硬件编码
gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, width=1280, height=1024, format=(string)YUY2" ! nvvidconv ! 'video/x-raw(memory:NVMM), format=(string)I420' ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 -e
上面这个过程有点麻烦,使用usb相机彩信的视频是YUY2格式,然后转换格式为I420的格式,因为omxH264enc只支持这个格式,然后再使用一个264的264的流工具输出到filesink也就输出到test.mp4中
使用nvivafilter
这个例子是使用cuda在图像左上角画了一个绿框
gst-launch-1.0 filesrc location=sample_1080p_h264.mp4 ! qtdemux ! \
h264parse ! omxh264dec ! nvivafilter cuda-process=true \
customer-lib-name="libnvsample_cudaprocess.so" ! \
'video/x-raw(memory:NVMM), format=(string)NV12' ! nvoverlaysink -e
以上这些都是自己记录并测试的,感觉使用起来很方便,如果想要自己去实现一个自己的gstreamer只需要按照接口自己去写一个即可。