• 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

    龙腾一族至尊龙骑
  • 相关阅读:
    Certificate、Provisioning Profile、App ID
    boundingRectWithSize
    IOS照片框架
    UIlabel 属性text
    UIMenuController的使用,对UILabel拷贝以及定制菜单
    iOS 自定义emoji表情键盘
    IOS第三方字体
    IOS 验证码
    网上收集的以及自己总结的iOS开发技巧
    给自己一个坚持下去的理由
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/15166823.html
Copyright © 2020-2023  润新知