Unity C# Mp3 Mp4 音频 视频 合成

需求

将声音文件合并到视频中

限制

暂时只支持Windows使用

准备

下载ffmpeg.exe

解压后得到exe

https://ffmpeg.org/download.html#releases

注意事项:

目录要在一起

代码

cs 复制代码
 public void StartExe()
    {
        if (File.Exists(ffmpegExe))
        {    
            string mp4;
            string mp3;
   
            //volume=3 这个参数代表 把输入的MP3合成音量
            string commad = $"-i {mp4} -i {mp3} -filter_complex \"[1:a]volume=10[a1];[0:a][a1]amix=inputs=2:duration=first[a]\" -map 0:v -map \"[a]\" -c:v copy -c:a aac -y {outPut}";

            Process process = new Process();   // params 为 string 类型的参数,多个参数以空格分隔,如果某个参数为空,可以传入""
            ProcessStartInfo startInfo = new ProcessStartInfo(ffmpegExe);
            process.StartInfo = startInfo;
            process.StartInfo.Arguments = commad;
            process.Start();
            process.WaitForExit();
        }
    }

小笨蛋快去试试吧

相关推荐
临床数据科学和人工智能兴趣组3 小时前
在R语言中, 使用 as.factor() 函数转换数值型变量
开发语言·r语言
allnlei6 小时前
Opus In-Band FEC 详解:原理、实现与开源方案
ffmpeg·音视频·gstreamer
andyweike6 小时前
php笔记
开发语言·笔记·php
爱吃提升7 小时前
文生视频模型发展趋势(2026)
人工智能·音视频
Circ.7 小时前
Python 调试 Litellm 本地大模型接口:模型列表与对话接口实操踩坑记录
开发语言·python
可乐鸡翅yeah_8 小时前
新手梳理:M3U8 线上问题,哪些是前端锅,哪些是后端锅
前端·ios·音视频·实时音视频·m3u8·音视频在线播放
波力海苔夹心脆6758 小时前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
现任明教教主~9 小时前
Thinkphp站群蜘蛛池SaaS系统YanyvSEO含多用户/积分/六大引擎计费/易支付对接
java·开发语言·spring
Zhou1411369 小时前
SpringSecurity_02_授权与高级功能
开发语言·python
apple_6926588510 小时前
最新ComfyUI 0.37.1使用教程:画图、3D、音频都有改动 ComfyUI升级到0.37.1啦,新增或改进五大功能
音视频