Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
dcu-codec-pipeline-py
Commits
8f056840
Commit
8f056840
authored
Mar 10, 2026
by
zhyh2010
Browse files
增加sample简单用例
parent
0cb40ca1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
2 deletions
+101
-2
codecbenchmark-py/__pycache__/benchmark_multi_inst.cpython-310.pyc
...hmark-py/__pycache__/benchmark_multi_inst.cpython-310.pyc
+0
-0
codecbenchmark-py/video_cuda_decode_benchmark.csv
codecbenchmark-py/video_cuda_decode_benchmark.csv
+1
-1
codecbenchmark-py/video_cuda_encode_benchmark.csv
codecbenchmark-py/video_cuda_encode_benchmark.csv
+1
-1
sample/readme.md
sample/readme.md
+47
-0
sample/sample_1920x1080_30fps_8bit.h264
sample/sample_1920x1080_30fps_8bit.h264
+0
-0
sample/test.py
sample/test.py
+52
-0
No files found.
codecbenchmark-py/__pycache__/benchmark_multi_inst.cpython-310.pyc
View file @
8f056840
No preview for this file type
codecbenchmark-py/video_cuda_decode_benchmark.csv
View file @
8f056840
Decode,Bit Depth,Resolution,Fps/(BMZ 1 Core),Fps/(BMZ 6 Processes)
H264,8,1920x1080,
506.87,2277.36
H264,8,1920x1080,
499.38,2056.14
codecbenchmark-py/video_cuda_encode_benchmark.csv
View file @
8f056840
Encode,Bit Depth,Resolution,Fps/(BMZ 1 Core)
H264,8,1920x1080,2
51.78
H264,8,1920x1080,2
30.31
sample/readme.md
0 → 100644
View file @
8f056840
# FFmpeg DCU python测试用例
这是一个简单的 DCU视频编解码Python demo用例。
## 环境要求
-
**驱动**
: 与MacCodecSDK版本一致
### 软件
-
**FFmpeg**
:
-
`MacCodecSDK`
-
**Python 依赖**
:
-
`ffmpeg-python`
-
**docker环境**
:
-
`基于DTK2504镜像即可,本sample使用harbor.sourcefind.cn:5443/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk26.04-0130-py3.10-20260202`
## 安装步骤
### 1. 安装系统级 MacCodecSDK
确保 FFmpeg 已安装,可通过ffmpeg指令验证
### 2. 安装 Python 依赖
```
bash
pip
install
ffmpeg-python
```
## 使用方法
运行脚本:
```
bash
python benchmark_cuda.py
```
## 输出示例
### 成功情况
```
text
--- Starting CUDA Benchmark for ./sample_1920x1080_30fps_8bit.h264 ---
[1] Testing CUDA Decode...
Decode Success
[2] Testing CUDA Encode (H264 NVENC)...
Encode Success
--- Benchmark Finished ---
```
\ No newline at end of file
sample/sample_1920x1080_30fps_8bit.h264
0 → 100644
View file @
8f056840
File added
sample/test.py
0 → 100644
View file @
8f056840
#!/usr/bin/env python3
import
ffmpeg
import
subprocess
import
sys
import
os
import
re
def
run_ffmpeg_command
(
cmd
):
"""运行命令并返回 stderr 日志"""
try
:
result
=
subprocess
.
run
(
cmd
,
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
PIPE
,
text
=
True
)
return
result
.
stderr
except
Exception
as
e
:
return
f
"Error:
{
e
}
"
def
main
():
input_file
=
"./sample_1920x1080_30fps_8bit.h264"
if
not
os
.
path
.
exists
(
input_file
):
print
(
f
"Error: File
{
input_file
}
not found"
)
sys
.
exit
(
1
)
print
(
f
"--- Starting CUDA Benchmark for
{
input_file
}
---
\n
"
)
# 1. CUDA 解码测试 (hwaccel cuda)
print
(
"[1] Testing CUDA Decode..."
)
try
:
stream
=
ffmpeg
.
input
(
input_file
,
hwaccel
=
'cuda'
)
cmd
=
ffmpeg
.
output
(
stream
,
'pipe:'
,
format
=
'null'
).
global_args
(
'-benchmark'
,
'-y'
).
compile
()
log_content
=
run_ffmpeg_command
(
cmd
)
print
(
f
" Decode Success
\n
"
)
except
Exception
as
e
:
print
(
f
" Decode Failed:
{
e
}
\n
"
)
# 2. CUDA 编码测试 (h264_nvenc)
print
(
"[2] Testing CUDA Encode (H264 NVENC)..."
)
output_file
=
"output_cuda_temp.mp4"
try
:
stream
=
ffmpeg
.
input
(
input_file
)
cmd
=
ffmpeg
.
output
(
stream
,
output_file
,
vcodec
=
'h264_nvenc'
).
global_args
(
'-benchmark'
,
'-y'
).
compile
()
log_content
=
run_ffmpeg_command
(
cmd
)
print
(
f
" Encode Success
\n
"
)
except
Exception
as
e
:
print
(
f
" Encode Failed:
{
e
}
\n
"
)
finally
:
# 清理临时文件
if
os
.
path
.
exists
(
output_file
):
os
.
remove
(
output_file
)
print
(
"--- Benchmark Finished ---"
)
if
__name__
==
"__main__"
:
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment