GPU視頻編解碼:Jetson VPI+multimedia_api視頻編解碼入門(一)

目錄

一.Pipline與工具棧

二.硬件設備概況

三.GPU視頻編解碼框架

四.VPI編譯使用實例

五.?jetson_multimedia_api編譯使用實例

一.Pipline與工具棧

二.硬件設備概況

三.GPU視頻編解碼框架

  1. jetson設備目前不支持VPF框架,關于VPF的使用我在下節PC段使用X86進行安裝與演示
  2. jetson目前支持的GPU編解碼框架為VPI和jetson_multimedia_api
    #1.主機端
    agx@ubuntu:~$ ls /usr/src/jetson_multimedia_api/
    argus  data  include  LEGAL  LICENSE  Makefile  README  samples  tools
    agx@ubuntu:~$ ls /opt/
    containerd/  genymobile/  nvidia/      ota_package/ todesk/
    agx@ubuntu:~$ ls /opt/nvidia/vpi2/
    bin  doc  etc  include  lib  lib64  samples  share#2.docker端
    agx@ubuntu:~$ docker images
    REPOSITORY                   TAG                  IMAGE ID       CREATED       SIZE
    nvcr.io/nvidia/l4t-pytorch   r35.2.1-pth2.0-py3   853b58c1dce6   2 years ago   11.7GB
    agx@ubuntu:~$ docker exec  -it nvpy bash
    root@7666a2ca87d3:/# ls /usr/src/jetson_multimedia_api/
    LEGAL  LICENSE  Makefile  README  argus  data  include  samples  tools
    root@7666a2ca87d3:/# ls /opt/nvidia/vpi2/
    bin  doc  etc  include  lib  lib64  samples  share
    

四.VPI編譯使用實例

? ? ? ? 1.運行結果

root@7666a2ca87d3:/opt/nvidia/vpi2# cd s
samples/ share/   
root@7666a2ca87d3:/opt/nvidia/vpi2# cd samples/
01-convolve_2d/           03-harris_corners/        05-benchmark/             07-fft/                   09-tnr/                   11-fisheye/               13-optflow_dense/         15-image_view/            17-template_matching/     assets/                   
02-stereo_disparity/      04-rescale/               06-klt_tracker/           08-cross_aarch64_l4t/     10-perspwarp/             12-optflow_lk/            14-background_subtractor/ 16-vpi_pytorch/           18-orb_feature_detector/  tutorial_blur/            
root@7666a2ca87d3:/opt/nvidia/vpi2# cd samples/01-convolve_2d/
root@7666a2ca87d3:/opt/nvidia/vpi2/samples/01-convolve_2d# python3 main.py --backend=cuda --input "/opt/nvidia/vpi2/share/backgrounds/NVIDIA_icon.png"
root@7666a2ca87d3:/opt/nvidia/vpi2/samples/01-convolve_2d# 

? ? ? ? 2.源碼?

import sys
import vpi
import numpy as np
from PIL import Image
from argparse import ArgumentParser# Parse command line arguments
parser = ArgumentParser()
parser.add_argument('--backend', choices=['cpu','cuda','pva'],default="cuda",help='Backend to be used for processing')parser.add_argument('--input',default="/opt/nvidia/vpi2/share/backgrounds/NVIDIA_icon.png",help='Image to be used as input')args = parser.parse_args();if args.backend == 'cpu':backend = vpi.Backend.CPU
elif args.backend == 'cuda':backend = vpi.Backend.CUDA
else:assert args.backend == 'pva'backend = vpi.Backend.PVA# Load input into a vpi.Image
try:input = vpi.asimage(np.asarray(Image.open(args.input)))
except IOError:sys.exit("Input file not found")
except:sys.exit("Error with input file")# Convert it to grayscale
input = input.convert(vpi.Format.U8, backend=vpi.Backend.CUDA)# Define a simple edge detection kernel
kernel = [[ 1, 0, -1],[ 0, 0,  0],[-1, 0, 1]]# Using the chosen backend,
with backend:# Run input through the convolution filteroutput = input.convolution(kernel, border=vpi.Border.ZERO)# Save result to disk
Image.fromarray(output.cpu()).save('edges_python'+str(sys.version_info[0])+'_'+args.backend+'.png')

? ? ? ? ?3.結果展示(上面用的是一個濾波)

五.?jetson_multimedia_api編譯使用實例

????????1.cuda h264編碼(bug警告,能編譯通過·但是無法OSD,后續兩個實驗直接在jetson-dektop上面實驗的,就行了)

root@ubuntu:/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc# make clean
root@ubuntu:/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc# make
Compiling: video_cuda_enc_csvparser.cpp
Compiling: video_cuda_enc_main.cpp
make[1]: 進入目錄“/usr/src/jetson_multimedia_api/samples/common/classes”
Compiling: NvElementProfiler.cpp
Compiling: NvElement.cpp
Compiling: NvApplicationProfiler.cpp
Compiling: NvVideoDecoder.cpp
Compiling: NvJpegEncoder.cpp
Compiling: NvBuffer.cpp
Compiling: NvLogging.cpp
Compiling: NvEglRenderer.cpp
Compiling: NvUtils.cpp
Compiling: NvDrmRenderer.cpp
Compiling: NvJpegDecoder.cpp
Compiling: NvVideoEncoder.cpp
Compiling: NvV4l2ElementPlane.cpp
Compiling: NvBufSurface.cpp
Compiling: NvV4l2Element.cpp
make[1]: 離開目錄“/usr/src/jetson_multimedia_api/samples/common/classes”
make[1]: 進入目錄“/usr/src/jetson_multimedia_api/samples/common/algorithm/cuda”
Compiling: NvAnalysis.cu
Compiling: NvCudaProc.cpp
make[1]: 離開目錄“/usr/src/jetson_multimedia_api/samples/common/algorithm/cuda”
Linking: video_cuda_enc
root@ubuntu:/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc# ./video_cuda_enc ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 H264 test.h264
段錯誤 (核心已轉儲)

? ? ? ? 2. cuda h264解碼

root@ubuntu:/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda# ./video_dec_cuda ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Starting decoder capture loop thread
Input file read complete
Video Resolution: 1920x1080
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1920 height 1080
Query and set capture successful
Exiting decoder capture loop thread
App run was successful

? ? ? ? 3.cuda h264解碼+tensorrt目標檢測:

? ? ? ? GPU算法檢測與結果緩存

root@ubuntu:/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda# cd ../04_video_dec_trt/
root@ubuntu:/usr/src/jetson_multimedia_api/samples/04_video_dec_trt# ./video_dec_trt 2 ../../data/Video/sample_outdoor_car_1080p_10fps.h264  ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --trt-onnxmodel  ../../data/Model/resnet10/resnet10_dynamic_batch.onnx --trt-mode 0
set onnx modefile: ../../data/Model/resnet10/resnet10_dynamic_batch.onnx
Using cached TRT model
Deserialization required 13048 microseconds.
Total per-runner device persistent memory is 5632
Total per-runner host persistent memory is 45440
Allocated activation device memory of size 22138880
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Starting decoder capture loop thread
Input file read complete
Video Resolution: 1920x1080
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Resolution change successful
Starting decoder capture loop thread
Input file read complete
Video Resolution: 1920x1080
Resolution change successful
Time elapsed:1 ms per frame in past 100 frames
Time elapsed:1 ms per frame in past 100 frames
Time elapsed:1 ms per frame in past 100 frames
Time elapsed:1 ms per frame in past 100 frames
Time elapsed:1 ms per frame in past 100 frames
Time elapsed:1 ms per frame in past 100 frames

? ? ? ? ?CUDA-H264視頻解碼+OSD

root@ubuntu:/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda# ./video_dec_cuda ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --bbox-file result0.txt 
ctx.osd_file_path:result0.txt
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Starting decoder capture loop thread
Input file read complete
Video Resolution: 1920x1080
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1920 height 1080
Query and set capture successful
Exiting decoder capture loop thread
App run was successful
root@ubuntu:/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda# ls
Makefile  resuilt.txt  result0.txt  result1.txt  result.txt  videodec_csvparser.cpp  videodec_csvparser.o  video_dec_cuda  videodec.h  videodec_main.cpp  videodec_main.o
root@ubuntu:/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda# ./video_dec_cuda ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Starting decoder capture loop thread
Input file read complete
Video Resolution: 1920x1080
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1920 height 1080
Query and set capture successful

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/73830.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/73830.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/73830.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

《深入理解AOP編程:從基礎概念到Spring實現》

AOP編程 AOP(Aspect Oriented Programing) 面向切面編程 Spring動態代理開發 以切面為基本單位的程序開發&#xff0c;通過切脈你間的彼此協同&#xff0c;相互調用&#xff0c;完成程序構建 切面切入點額外功能 OOP(Object Oriented Programing)面向對象編程 java 以對象為基本…

C# 零基礎入門篇(19.DateTime 使用指南)

## 一、概述 DateTime 是 C# 中用于表示日期和時間的結構&#xff0c;位于 System 命名空間中。它提供了豐富的屬性和方法&#xff0c;用于處理日期和時間的創建、格式化、比較和計算。 ## 二、創建 DateTime 對象 ### &#xff08;一&#xff09;使用默認構造函數 DateTime…

Docker 實踐與應用舉例

一、引言 在當今快速發展的信息技術領域&#xff0c;容器化技術已成為推動軟件開發、部署和運維變革的關鍵力量。Docker 作為容器化技術的領軍者&#xff0c;以其高效、便捷、可移植等特性&#xff0c;被廣泛應用于各種場景。它能夠將應用程序及其依賴項打包成一個獨立的容器&…

C++初階——類和對象(一)

C初階——類和對象&#xff08;一&#xff09; 一、面向過程和面向對象 1.面向過程 面向過程的程序設計&#xff08;Procedure-Oriented Programming&#xff09;&#xff0c;簡稱POP&#xff0c;是一種是以程序執行流程為核心的編程范式。它是先分析出解決問題所需要的的步…

Skyeye 云智能制造辦公系統 VUE 版本 v3.15.13 發布

Skyeye 云智能制造&#xff0c;采用 Springboot winUI 的低代碼平臺、移動端采用 UNI-APP。包含 30 多個應用模塊、50 多種電子流程&#xff0c;CRM、PM、ERP、MES、ADM、EHR、筆記、知識庫、項目、門店、商城、財務、多班次考勤、薪資、招聘、云售后、論壇、公告、問卷、報表…

Obsidian Copilot:打造你的專屬 AI 筆記助手

Obsidian Copilot作為一款非常受歡迎的Obsidian插件&#xff0c;不僅極大地提升了用戶的筆記管理和信息檢索效率&#xff0c;還通過其多樣化的AI功能為用戶帶來了前所未有的便捷體驗。本文將詳細介紹Obsidian Copilot的核心特點、使用方法及個人體驗分享。 核心特點 Obsidian…

每日一題--計算機網絡

一、基礎概念類問題 1. TCP 和 UDP 的區別是什么&#xff1f; 回答示例&#xff1a; TCP&#xff1a;面向連接、可靠傳輸&#xff08;通過三次握手建立連接&#xff0c;丟包重傳&#xff09;、保證數據順序&#xff08;如文件傳輸、網頁訪問&#xff09;。 UDP&#xff1a;無…

使用 Spring 的 FactoryBean 創建和獲取 Bean 對象

在Spring框架中&#xff0c;FactoryBean接口提供了一種強大的機制來創建復雜的bean實例。本文將基于提供的代碼示例&#xff0c;詳細介紹如何通過FactoryBean創建bean對象&#xff0c;并展示如何獲取這些bean實例以及它們所屬的FactoryBean實例。 示例代碼類 定義 MyBean 接口…

制造業數字化轉型,汽車裝備制造企業數字化轉型案例,智能制造數字化傳統制造業數字化制造業數字化轉型案例

《某制造業企業信息化整體解決方案》PPT展示了一個汽車裝備企業的整體信息化解決方案&#xff0c;闡述了該企業的業務特點和現狀&#xff0c;主要包括按訂單生產、多級計劃和產品跟蹤等&#xff0c;分析了信息化建設的主要困難&#xff0c;如信息管理手工化、過程數據追溯困難、…

軟鏈接 使用筆記 linux命令 if判斷

目錄 1>0判斷怎么寫&#xff1a; 1. 使用 [ ] 進行數值比較&#xff1a; 2. 使用 (( )) 進行數學運算&#xff1a; 3. 使用 [[ ]]&#xff08;主要用于字符串比較&#xff0c;不推薦用于數學運算&#xff09;&#xff1a; 軟鏈接 使用筆記 1>0判斷怎么寫&#xff1a…

pycharm-python國際象棋遊戲代碼

嗯&#xff0c;用戶的問題是“pycharm寫關於python國際象棋遊戲代碼”&#xff0c;也就是要用PyCharm來寫一個Python的國際象棋游戲代碼。我需要先整理一下用戶提供的搜索結果&#xff0c;看看有什么相關的信息可以利用。 首先看搜索結果中的各個網頁內容。網頁1主要講的是象棋…

【Film】MovieAgent:自動化電影生成通過多智能體CoT規劃

論文概覽 自動化電影生成根據劇本概要和角色庫創建具有一 致角色、同步字幕和音頻的長篇視頻。它涉及自動化敘 事規劃、場景結構化, 和鏡頭構圖,復制現實世界電影制作的層次推理。 核心貢獻 提出MovieAgent,通過多智能體鏈式思維(CoT)規劃實現自動化電影生成。首次探索并…

數據結構——最短路(BFS,Dijkstra,Floyd)

完整版可以看我的最短路問題模版總結_稠密圖最短路-CSDN博客 考研數據結構只考BFS,Dijkstra和Floyd 下面代碼以Acwing模板題為例 BFS代碼 適用類型&#xff1a; 1.單源最短路徑 2.無權圖 3.不適用于帶權圖和負權回路圖 //Acwing走迷宮bfs #include<bits/stdc.h>usi…

ftp替代品,如何提升數據交換的安全性與高效性?

文件傳輸協議&#xff08;FTP&#xff09;是一個跨平臺的、簡單且易于實現的協議&#xff0c;用于在網絡上的服務器和客戶端之間傳輸文件&#xff0c;也是企業會經常選擇的一種傳輸方式。 業務場景一&#xff1a; 基于信息相關安全要求&#xff0c;醫院會采用防火墻、網閘等將…

單片機開發資源分析的實戰——以STM32G431RBT6為例子的單片機資源分析

目錄 第一點&#xff1a;為什么叫STM32G431RBT6 從資源手冊拿到我們的對STM32G431RBT6的資源描述 第二件事情&#xff0c;關心我們的GPIO引腳輸出 第三件事情&#xff1a;去找對應外設的說明部分 第一點&#xff1a;為什么叫STM32G431RBT6 對于命名規則不太熟悉的朋友看這里…

Android PC 要來了?Android 16 Beta3 出現 Enable desktop experience features 選項

在之前的 《Android 桌面窗口新功能推進》 我們就聊過&#xff0c;Google 就一直在努力改進 Android 的內置桌面模式&#xff0c;例如添加了適當的窗口標題、捕捉窗口的能力、懸停選項、窗口大小調整、最小化支持、app-to-web 等。 比如在搭載 Android 15 QPR 1 Beta 2 的 Pix…

IP關聯是什么?怎么避免?

在跨境電商的道路上&#xff0c;大家好&#xff01;今天想和大家聊一聊一個非常重要的話題&#xff0c;那就是IP關聯的問題。在商業活動中&#xff0c;了解如何避免IP關聯對保護我們寶貴的商鋪至關重要。接下來&#xff0c;我們將深入探討IP關聯的概念、影響及如何有效防止這一…

行為模式---狀態模式

概念 狀態模式是一種行為模式&#xff0c;用于在內部狀態改變的時候改變其行為。它的核心思想就是允許一個對象在其內部狀態改變的時候改變它的行為。狀態模式通過將對象的狀態封裝成獨立的類&#xff0c;并將其行為委托給當前的狀態對象&#xff0c;從而使得對象行為隨著狀態…

目標檢測中衡量模型速度和精度的指標:FPS和mAP

“FPS”和“mAP”分別衡量了模型的速度和精度。 FPS&#xff08;Frames Per Second&#xff09; 定義&#xff1a;FPS是“每秒傳輸幀數”的縮寫&#xff0c;用于衡量計算機視覺系統&#xff08;如目標檢測、圖像識別等&#xff09;的實時性能。它表示系統每秒鐘能夠處理的圖像…

網頁復印機:只需一個網址,一鍵克隆任何網站!(可根據需求生成/優化相關代碼)

文章目錄 ?? 介紹 ???? 演示環境 ???? 網頁代碼克隆神器:一鍵復刻精美設計,提升前端開發效率 ????? 使用?? 相關鏈接 ???? 介紹 ?? 每天對著別人的精美網站漏出羨慕的眼神,卻苦于自己的前端技術不夠硬,難以完美復刻?或者為了趕項目進度,不得不重復…