• ffmpeg录音录像


    ffmpeg录音录像 ffmpeg,ffplay,ffprobe主要用来录音录像播放查看多媒体文件的信息。本文带领大家学习常用命令。常用参数比较多,可以使用ffprobe --help来查看详细的帮助信息

    #region ffmpeg录音录像 ffmpeg,ffplay,ffprobe主要用来录音录像播放查看多媒体文件的信息。本文带领大家学习常用命令。常用参数比较多,可以使用ffprobe --help来查看详细的帮助信息
            #region ffmpeg 录像
            Process process = null;
            private void btnFfmepgStart_Click(object sender, EventArgs e)
            {
                #region MyRegion
    
                //System.Diagnostics.Process.Start(@"C:UsersAdministratorDesktopDebugWindowsFormsTestVideo.exe","参数122");
    
                //Process process1 = new Process();
                //process1.StartInfo = new ProcessStartInfo(@"C:UsersAdministratorDesktopDebugWindowsFormsTestVideo.exe");
                //process1.StartInfo.Arguments = "参数12277777777777777";
                //process1.Start();
                ////process1.WaitForExit(10000);
                ////process1.Close();
                //process1.Dispose(); 
                #endregion
    
                //ProcessStartInfo StartInfo = new ProcessStartInfo(@"C:WindowsSystem32cmd.exe");
                process = new Process();
                process.StartInfo = new ProcessStartInfo(@"C:WindowsSystem32cmd.exe");
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.RedirectStandardInput = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                //process.StartInfo.WorkingDirectory = @"C:WindowsSystem32";// AppDomain.CurrentDomain.BaseDirectory;
                process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string a = "ffmpeg -rtbufsize 200M -f dshow  -i video="USB Camera" -f dshow -i audio="麦克风阵列 (Realtek High Definition Audio)" -pix_fmt yuv420p   -b:v 300k -r 10 -vcodec libx264 -tune zerolatency -acodec aac -b:a 32k -ar 16000 -af volume=10 -y  "123.mp4"";
                string at = @"ffmpeg -rtbufsize 200M -f dshow  -i video=""USB Camera"" -f dshow -i audio=""麦克风阵列 (Realtek High Definition Audio)"" -pix_fmt yuv420p   -b:v 300k -r 10 -vcodec libx264 -tune zerolatency -acodec aac -b:a 32k -ar 16000 -af volume=10 -y  ""123.mp4""";
                //Log(a, MessageType.info);
                //Log(at, MessageType.info);
                //process.StandardInput.WriteLine(a);
                process.OutputDataReceived += Process_OutputDataReceived;
                process.ErrorDataReceived += Process_ErrorDataReceived;
                //process.StartInfo.Arguments = a;
    
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                a = @"ffmpeg.exe -rtbufsize 200M  -f dshow  -i video=""USB Camera"" -f dshow -i audio=""麦克风阵列 (Realtek High Definition Audio)"" -pix_fmt yuv420p -tune zerolatency -af volume=5 -y 123.mp4";
                //噪音很大,去掉 -af volume=5,噪音会好很多
                //-ac 通道 声道 1,2;
                //-ar 8000 声音的采样率 psp 24000Hz
                //-ab 音频数据流,一般选择32,64,96,128 44100置成这个参数音频底噪会小,但是音色会有些发闷
                //-vol音量 放大倍数
                a = @"ffmpeg.exe -rtbufsize 200M  -f dshow  -i video=""USB Camera"" -f dshow -i audio=""麦克风阵列 (Realtek High Definition Audio)"" -pix_fmt yuv420p -tune zerolatency -ac 1 -ar 8000 -ab 44100 -vol 800 -y 123.mp4";
    
                process.StandardInput.WriteLine(a);
                //process.StandardInput.WriteLine(at/* + Environment.NewLine*/);
                //process.StandardInput.WriteLine("
    ");
                Log(a, MessageType.info);
                Log(at, MessageType.info);
                lblffmepg.ForeColor = Color.Green;
                lblffmepg.Text = "开始录音录像";
            }
    
            private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
            {
                Log(e.Data, MessageType.error);
            }
    
            private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
            {
                Log(e.Data, MessageType.info);
            }
    
            private void btnFfmpegStop_Click(object sender, EventArgs e)
            {
                string a = "q";
                process.StandardInput.WriteLine(a);
                process.StandardInput.WriteLine("exit");
                process.WaitForExit();
                process.Close();
                process.Dispose();
                Process.Start("123.mp4");
    
                lblffmepg.ForeColor = DefaultForeColor;
    
                lblffmepg.Text = null;
            }
            #endregion
    
            #region ffplay 播放
            // ffplay -autoexit ww.mp4
            #endregion
    
            #region ffprobe 查看信息
            // ffprobe -show_packets ww.mp4
            #endregion 
            #endregion

    注意:ffmpeg相关的类库拷贝到运行目录,下载地址:https://download.csdn.net/download/LongtengGensSupreme/21059889

    龙腾一族至尊龙骑
  • 相关阅读:
    Python学习笔记4—列表List
    Python学习笔记3—字符串
    电力项目十六--数据字典二
    电力项目十五--数据字典
    maven项目引入jar包
    电力项目十四--js添加highslider特效
    电力项目十三--js添加浮动框
    电力项目十二--运行监控中添加进度条
    panzer 电力项目十一--hibernate操作大文本字段Blob和Clob
    电力项目十--整合文本编辑器
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/15166823.html
Copyright © 2020-2023  润新知