0

ffmpegを使用して、データチャンクが受信されたときにmp3ビットレートを変換できるかどうか知りたいですか?

つまり、別のビットレートでmp3を出力するように、ゆっくりとチャンクをffmpegに送信します。

したがって、非常に擬似コードでは、次のようになります。

  1. ユーザーからのMP3リクエスト

  2. デフォルトのmp3をffmpegに送信し、パラメータを指定して目的のビットレートに変換します。

  3. 新しいファイルを書き込んでいるので、これまでに書き込まれたものをResponse出力ストリームに書き込みます(私はASP.Netにいます)

それは実現可能ですか、それとも別のテクノロジーに切り替える必要がありますか?

[編集]

今のところ、私は次のような解決策を試しています:C#とffmpegを使用してwmaストリームをmp3ストリームに変換します

[編集2]

私は私の質問に答えました、そしてそれは入力としてURLと出力として標準出力で実行可能です。URLを使用すると、ファイルをチャンクごとに処理できます。stdoutを使用すると、処理中にデータにアクセスできます。

4

1 に答える 1

1

これがC#のメソッドで、http://jesal.us/2008/04/how-to-manipulate-video-in-net-using-ffmpeg-updated/で読み、ストリームからストリームへと機能するように変更されています。これは、ffmpegを使用したスト​​リームの「ライブ」変換を意味します。

コマンドの最後にある「-」は「標準出力」を表すため、これが宛先になります。

    private void ConvertVideo(string srcURL)
    {
        string ffmpegURL = @"C:\ffmpeg.exe";
        DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\");

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = ffmpegURL;
        startInfo.Arguments = string.Format("-i \"{0}\" -ar 44100 -f mp3 -", srcURL);
        startInfo.WorkingDirectory = directoryInfo.FullName;
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.RedirectStandardInput = true;
        startInfo.RedirectStandardError = true;
        startInfo.CreateNoWindow = false;
        startInfo.WindowStyle = ProcessWindowStyle.Normal;

        using (Process process = new Process())
        {
            process.StartInfo = startInfo;
            process.EnableRaisingEvents = true;
            process.ErrorDataReceived += new DataReceivedEventHandler(process_ErrorDataReceived);
            process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
            process.Exited += new EventHandler(process_Exited);

            try
            {
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                process.ErrorDataReceived -= new DataReceivedEventHandler(process_ErrorDataReceived);
                process.OutputDataReceived -= new DataReceivedEventHandler(process_OutputDataReceived);
                process.Exited -= new EventHandler(process_Exited);

            }
        }
    }

    void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
    {
        if (e.Data != null)
        {
            byte[] b = System.Text.Encoding.Unicode.GetBytes(e.Data);
            // If you are in ASP.Net, you do a 
            // Response.OutputStream.Write(b)
            // to send the converted stream as a response
        }
    }


    void process_Exited(object sender, EventArgs e)
    {
        // Conversion is finished.
        // In ASP.Net, do a Response.End() here.
    }
于 2012-09-24T03:43:35.547 に答える