zoukankan      html  css  js  c++  java
  • netcore linux ffmpeg 首帧图

    第一步  
    On CentOS/RHEL 6.*:   $ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm On CentOS/RHEL 7:   $ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm   $ yum repolist 第二步:yum install ffmpeg
    安装后,查看版本,来进行是否安装成功判断;(用whereis ffmpeg可以查看其安装路径;)
    
    /usr/bin/ffmpeg -version
     /// <summary>
            /// 获取视频首帧图
            /// </summary>
            /// <param name="vediofilepath"></param>
            /// <param name="directImagedirectory"></param>
            /// <param name="ffmpegpath"></param>
            /// <returns></returns>
            public static string GetVedioFirstImage(string vediofilepath, string directImagedirectory, string ffmpegpath)
            {
                if (string.IsNullOrEmpty(vediofilepath))
                {
                    return string.Empty;
                }
                string str_CommandArgs = "";
                var file1 = new FileInfo(vediofilepath);
                if (file1.Exists)
                {
                    try
                    {
                        //string save_folder = file1.FullName.Replace(file1.Name, "");
                        //string image_file = "video_" + file1.Name.Replace(file1.Extension, ".jpg");
                        var basepath = directImagedirectory + DateTime.Now.ToString("yyyyMMdd") + "/";
                        if (!Directory.Exists(directImagedirectory))
                        {
                            Directory.CreateDirectory(directImagedirectory);
                        }
                        if (!Directory.Exists(basepath))
                        {
                            Directory.CreateDirectory(basepath);
                        }
                        //string image_file = "video_" + file1.Name.Replace(file1.Extension, ".jpg");
                        string image_file = basepath + Guid.NewGuid().ToString("N") + ".jpg";
                        //#设置参数以直接输出图像序列(帧),第2秒
                        //str_CommandArgs = "-i " + vediofilepath + " -ss 00:00:02 -vframes 1 -an -y  -f mjpeg " + image_file;
                        str_CommandArgs = "-i " + vediofilepath + "  -y -f   image2  -ss 1 -vframes 1   " + image_file;
                        System.Diagnostics.ProcessStartInfo cmd_StartInfo = new System.Diagnostics.ProcessStartInfo(ffmpegpath, str_CommandArgs);
                        cmd_StartInfo.RedirectStandardError = false; //set false
                        cmd_StartInfo.RedirectStandardOutput = false; //set false
                        cmd_StartInfo.UseShellExecute = false; //set true
                        cmd_StartInfo.CreateNoWindow = true;  //don't need the black window
                                                              //创建一个进程,分配它的ProcessStartInfo并启动它
                        System.Diagnostics.Process cmd = new System.Diagnostics.Process();
                        cmd.StartInfo = cmd_StartInfo;
                        cmd.Start();
                        cmd.WaitForExit();
                        //System.Threading.Thread.Sleep(1000);
    
    
                        return image_file;
                    }
                    catch (Exception ee)
                    {
                        throw new Exception(ee.StackTrace + ee.Message + " for: " + vediofilepath + " " + str_CommandArgs);
                    }
                }
                else
                {
                    return string.Empty;
    
                }
            }
  • 相关阅读:
    Tomcat6 一些调优设置内存和连接数
    【原创】使用c3p0数据库连接池时出现com.mchange.v2.resourcepool.TimeoutException
    JVM内存的设置
    JBOSS以及tomcat最大连接数配置和jvm内存配置
    摘抄python __init__
    Python中__init__方法介绍
    Python 绝对简明手册
    python中eval, exec, execfile,和compile [转载]
    extern、static、auto、register 定义变量的不同用法
    Python 网络编程说明
  • 原文地址:https://www.cnblogs.com/chenyishi/p/12302053.html
Copyright © 2011-2022 走看看