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;
    
                }
            }
  • 相关阅读:
    dfa最小化,终于完成了。
    nfa转dfa,正式完成
    正则转nfa:完成
    正则转nfa:bug消除
    myeclipse集成jad反编译步骤
    CSS声明 列表样式 显示方式 鼠标形状
    CSS声明2 定位
    CSS声明1
    CSS基础知识简介
    lol简介/html
  • 原文地址:https://www.cnblogs.com/chenyishi/p/12302053.html
Copyright © 2011-2022 走看看