C# FFmpeg 视频添加logo

1.代码解析

#region 视频添加Logo
/// <summary>
/// 视频添加Logo
/// </summary>
/// <param name="context"></param>
/// <param name="pathBefore"></param>
/// <param name="pathLater"></param>
/// <returns></returns>
public static bool VideoAppendLogo(string ffmpegPath, string ConvertBeforePath, string AppendLogoPath, string ConvertLaterPath, ref string returnmsg,
    int overlayX = 0, int overlayY = 0, bool openDebug = false, string LogName = "testlog")
{
    Init(openDebug, LogName);
    try
    {
    if (string.IsNullOrWhiteSpace(ffmpegPath) || string.IsNullOrWhiteSpace(ConvertBeforePath) || string.IsNullOrWhiteSpace(ConvertLaterPath))
    {
        returnmsg = "基础参数未传!";
        return false;
    }
    if (string.IsNullOrWhiteSpace(AppendLogoPath))
    {
        returnmsg = "请上传LOGO图片";
        return false;
    }
    #region 参数解析
    /*右上角:
    ./ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w output.mp4
    左下角:
    ./ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=0:H-h output.mp4
    右下角:
    ./ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w:H-h output.mp4
     */
    #endregion
    string strExeCmd = " -i " + ConvertBeforePath + " -i " + AppendLogoPath + " -filter_complex"
        + " overlay=" + overlayX + ":" + overlayY + " -y "
        + ConvertLaterPath;
    return RunCmd(ffmpegPath, strExeCmd, ConvertLaterPath, ref returnmsg, LogName);
    }
    catch (Exception ex)
    {
    T9.Util.LogUtil.WriteLog("catch VideoAppendLogo:" + ex.Message, LogName);
    returnmsg = "转换报错";
    return false;
    }
}
#endregion
2.更多ffmpeg操作请查看

C#FFmpeg通用方法集合类-C#文档类资源-优快云下载

3.有问题vx:GOD_T9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

可曾听闻丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值