ffmpeg视频拼接性能测试

视频拼接性能汇总

|----|------------|-------|-------|----|------|------------------------|-----------------|---------|-----|-----|-------|----------|----------|------|---|
| 编号 | 方案 | 并行任务数 | 视频分辨率 | 帧率 | 编码格式 | cpu | gpu | cpu使用率% | 线程数 | fps | 耗时秒 | 视频合并后fps | 视频合并总时长秒 | 备注 | |
| 1 | 纯cpu | 1 | 1080P | 25 | H264 | 4核 i5-7500 | | 100 | 1 | 36 | 51 | 1836 | 73 | | |
| 2 | 纯cpu | 1 | 1080P | 25 | H264 | 4核 i5-7500 | | 100 | 4 | 34 | 53 | 1836 | 73 | | |
| 3 | 纯cpu | 1 | 1080P | 25 | H264 | 4核 i5-7500 | | 100 | 8 | 34 | 50 | 1836 | 73 | | |
| 4 | 纯cpu | 1 | 1080P | 25 | H264 | 4核 i5-7500 | | 100 | 16 | 34 | 53 | 1836 | 73 | | |
| 5 | 核显编解 | 1 | 1080P | 25 | H264 | 4核 i5-7500 | HD Graphics 630 | 40 | 默认 | 82 | 22.4 | 1836 | 73 | | |
| 6 | cpu解 + 独显编 | 1 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 100 | 默认 | 192 | 9 | 1836 | 73 | | |
| 7 | 独显解+独显编 | 1 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 25 | 默认 | 185 | 10 | 1836 | 73 | | |
| 8 | cpu解 + 独显编 | 1 | 1080P | 25 | H264 | 24核 i7-13700K 3.40 GHz | nvidia 3090ti | 20 | 默认 | 447 | 4 | 1836 | 73 | | |
| 9 | 独显解+独显编 | 1 | 1080P | 25 | H264 | 24核 i7-13700K 3.40 GHz | nvidia 3090ti | 0 | 默认 | 424 | 4 | 1836 | 73 | | |
| 10 | cpu解 + 独显编 | 1 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 100 | 默认 | 407 | 11.22 | | 180 | | |
| 11 | cpu解 + 独显编 | 3 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 100 | 默认 | 416 | 32.96 | | 180 | | |
| 12 | cpu解 + 独显编 | 5 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 100 | 默认 | 424 | 53.75 | | 180 | | |
| 13 | cpu解 + 独显编 | 10 | 1080P | 25 | H264 | 4核 i5-7500 | nvidia 1050ti | 100 | 默认 | 416 | 87.6 | | 180 | 2路异常 | |
| | | | | | | | | | | | | | | | |

1.测试环境:

设备名称 DESKTOP-5REGCE3

处理器 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz 3.41 GHz 4核

机带 RAM 16.0 GB

设备 ID 4C08B4E2-53DE-42EC-A586-94C740F16A36

产品 ID 00331-10000-00001-AA715

系统类型 64 位操作系统, 基于 x64 的处理器

笔和触控 没有可用于此显示器的笔或触控输入

gpu卡:nvidia 1050ti

核数:4

视频文件:

src_1.mp4 1080P@25fps 30秒

src_2.mp4 1080P@25fps 44秒

拼接后视频总时长:74秒 总帧数(1836)

测试工具:

D:\test> ffmpeg -version

ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers

built with gcc 12.2.0 (Rev10, Built by MSYS2 project)

configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband

libavutil 58. 2.100 / 58. 2.100

libavcodec 60. 3.100 / 60. 3.100

libavformat 60. 3.100 / 60. 3.100

libavdevice 60. 1.100 / 60. 1.100

libavfilter 9. 3.100 / 9. 3.100

libswscale 7. 1.100 / 7. 1.100

libswresample 4. 10.100 / 4. 10.100

libpostproc 57. 1.100 / 57. 1.100

2.使用cpu拼接:

1)默认线程数cpu (线程数设置并无效果)

执行命令:

Measure-Command {ffmpeg -threads 1 -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c copy copy_7.mp4}

cpu:100%

执行结果:frame= 1836 fps= 36 q=-1.0 Lsize= 17465kB time=00:01:13.32 bitrate=1951.4kbits/s speed=1.42x

执行时间:51秒

2)线程数cpu:4

执行命令:

Measure-Command {ffmpeg -threads 4 -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 outputVideo_8.mp4}

cpu:100%

执行结果:frame= 1836 fps= 34 q=-1.0 Lsize= 17465kB time=00:01:13.32 bitrate=1951.4kbits/s speed=1.37x

执行时间:53秒

3)线程数cpu:8

执行命令:

Measure-Command {ffmpeg -threads 8 -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 outputVideo_9.mp4}

cpu:100%

执行结果:frame= 1836 fps= 37 q=-1.0 Lsize= 17465kB time=00:01:13.32 bitrate=1951.4kbits/s speed=1.46x

执行时间:50秒

4)线程数cpu:16

执行命令:

Measure-Command {ffmpeg -threads 16 -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 outputVideo_9.mp4}

cpu:100%

执行结果:frame= 1836 fps= 34 q=-1.0 Lsize= 17465kB time=00:01:13.32 bitrate=1951.4kbits/s speed=1.37x

执行时间:53秒

5)cpu核显:核显(忠后工作机 i5-7500@3.4GHZ Intel(R) HD Graphics 630)

执行命令:

Measure-Command {ffmpeg -hwaccel qsv -i src_1.mp4 -hwaccel qsv -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c:v h264_qsv -preset fast qsv_01.mp4}

cpu:40%

执行结果:frame= 1836 fps= 82 q=26.0 Lsize= 11301kB time=00:01:13.32 bitrate=1262.7kbits/s speed=3.28x

video:11277kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.215376%

执行时间:22.4秒

6)默认命令(cpu解码 gpu编码 1050ti)

执行命令:

Measure-Command {ffmpeg -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c:v h264_nvenc -preset fast -profile:v high cuda_2.mp4}

cpu:100%

gpu encoder:50%

执行结果:frame= 1836 fps=192 q=22.0 Lsize= 16955kB time=00:01:13.40 bitrate=1892.3kbits/s speed=7.67x

执行时间:9秒

7)默认命令(gpu解码 gpu编码 1050ti)

执行命令:

Measure-Command {ffmpeg -hwaccel nvdec -i src_1.mp4 -hwaccel nvdec -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c:v h264_nvenc -preset fast -profile:v high cuda_2.mp4}

cpu:25%

gpu encoder:42%

gpu decoder:26%

执行结果:frame= 1836 fps=185 q=22.0 Lsize= 16955kB time=00:01:13.40 bitrate=1892.3kbits/s speed= 7.4x

执行时间:10秒

8)(cpu解码 gpu编码3090ti) 3090ti

账户:A 密码:125521 windows11:192.168.42.105

D:\test>nvidia-smi

Fri Apr 26 14:32:17 2024

+---------------------------------------------------------------------------------------+

| NVIDIA-SMI 546.33 Driver Version: 546.33 CUDA Version: 12.3 |

|-----------------------------------------+----------------------+----------------------+

| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |

| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |

| | | MIG M. |

|=========================================+======================+======================|

| 0 NVIDIA GeForce RTX 3090 WDDM | 00000000:01:00.0 On | N/A |

| 47% 53C P0 114W / 350W | 778MiB / 24576MiB | 0% Default |

| | | N/A |

+-----------------------------------------+----------------------+----------------------+

执行命令:

Measure-Command {ffmpeg -i src_1.mp4 -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c:v h264_nvenc -preset fast -profile:v high cuda_2.mp4}

cpu:20%

gpu encoder:100%

gpu decoder:0%

执行结果:frame= 1836 fps=447 q=22.0 Lsize= 16950kB time=00:01:13.40 bitrate=1891.7kbits/s speed=17.9x

执行时间:4秒

9)(gpu解码 gpu编码3090ti) 3090ti

账户:A 密码:125521 windows11:192.168.42.105

D:\test>nvidia-smi

Fri Apr 26 14:32:17 2024

+---------------------------------------------------------------------------------------+

| NVIDIA-SMI 546.33 Driver Version: 546.33 CUDA Version: 12.3 |

|-----------------------------------------+----------------------+----------------------+

| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |

| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |

| | | MIG M. |

|=========================================+======================+======================|

| 0 NVIDIA GeForce RTX 3090 WDDM | 00000000:01:00.0 On | N/A |

| 47% 53C P0 114W / 350W | 778MiB / 24576MiB | 0% Default |

| | | N/A |

+-----------------------------------------+----------------------+----------------------+

执行命令:

Measure-Command {ffmpeg -hwaccel nvdec -i src_1.mp4 -hwaccel nvdec -i src_2.mp4 -filter_complex xfade=transition=fade:duration=1:offset=29 -c:v h264_nvenc -preset fast -profile:v high cuda_2.mp4}

gpu encoder:100%

gpu decoder:100%

执行结果:frame= 1836 fps=424 q=22.0 Lsize= 16950kB time=00:01:13.40 bitrate=1891.7kbits/s speed=16.9x

执行时间:4秒

并行运行测试代码:

python 复制代码
import subprocess
import time

# 定义要执行的命令列表
commands = [
    ['ffmpeg', '-hwaccel', 'nvdec', '-i', 'src_90_3.mp4', '-hwaccel', 'nvdec', '-i', 'src_90_4.mp4', '-filter_complex', 'xfade=transition=fade:duration=1:offset=89', '-c:v', 'h264_nvenc', '-preset', 'fast', '-profile:v', 'high', '3_1.mp4'],
    ['ffmpeg', '-hwaccel', 'nvdec', '-i', 'src_90_5.mp4', '-hwaccel', 'nvdec', '-i', 'src_90_6.mp4', '-filter_complex', 'xfade=transition=fade:duration=1:offset=89', '-c:v', 'h264_nvenc', '-preset', 'fast', '-profile:v', 'high', '3_2.mp4'],
    ['ffmpeg', '-hwaccel', 'nvdec', '-i', 'src_90_7.mp4', '-hwaccel', 'nvdec', '-i', 'src_90_8.mp4', '-filter_complex', 'xfade=transition=fade:duration=1:offset=89', '-c:v', 'h264_nvenc', '-preset', 'fast', '-profile:v', 'high', '3_3.mp4']
]

# 启动并行进程
processes = []
start_times = []
for i, command in enumerate(commands):
    start_time = time.time()  # 记录开始时间
    stdout_file = f"process_{i+1}_stdout.log"
    stderr_file = f"process_{i+1}_stderr.log"
    print(" ".join(command))
    with open(stdout_file, 'w') as stdout, open(stderr_file, 'w') as stderr:
        process = subprocess.Popen(command, stdout=stdout, stderr=stderr)
    processes.append(process)
    start_times.append(start_time)

# 等待所有进程完成并打印执行时间
for i, process in enumerate(processes):
    process.wait()
    end_time = time.time()  # 记录结束时间
    execution_time = end_time - start_times[i]  # 计算执行时间
    print(f"进程 {i+1} 执行时间: {execution_time:.2f} 秒")

print("所有进程已完成.")
相关推荐
奇客软件13 分钟前
如何使用工具删除 iPhone 上的图片背景
windows·ios·智能手机·excel·音视频·cocoa·iphone
szqcloud2 小时前
腾讯云SDK产品功能
云计算·音视频·腾讯云
Tracy9733 小时前
交互式低延迟音频解码器
人工智能·音视频·音频·语音识别·实时音视频
寻找09之夏3 小时前
【FFmpeg 深度解析】:全方位视频合成
ffmpeg·音视频
zanglengyu4 小时前
ffmpeg取rtsp流音频数据保存声音为wav文件
ffmpeg·音视频
Byron07075 小时前
videojs 播放mp4视频只有声音没有画面问题
音视频
cuijiecheng20186 小时前
音视频入门基础:FLV专题(11)——FFmpeg源码中,解析SCRIPTDATASTRING类型的ScriptDataValue的实现
ffmpeg·音视频
快手技术9 小时前
ECCV 2024 | 融合跨模态先验与扩散模型,快手处理大模型让视频画面更清晰!
音视频
奇客软件9 小时前
如何从 Windows 11/10/8.1/8/7 中恢复已删除的视频
windows·macos·智能手机·手机·笔记本电脑·excel·音视频
Java搬砖组长10 小时前
Bilibili视频如何保存到本地
python·音视频