代码之家  ›  专栏  ›  技术社区  ›  MaLKaV_eS

用C语言将MP4转换成Ogg#

  •  1
  • MaLKaV_eS  · 技术社区  · 15 年前

    我不得不这么做,但我对它了解不多,我能找到的只是程序,而不是示例或库。

    3 回复  |  直到 15 年前
        1
  •  6
  •   Chad    15 年前

    http://www.ffmpeg.org/ -使用 Process process.WaitForExit() 在你开始之后。你可以在后台线程上这样做( BackgroundWorker ThreadPool ,等等…)如果您不需要阻止UI。

        2
  •  4
  •   James Mundy    9 年前

    NReco.VideoConverter which is a helpful wrapper for FFMPEG

    1.将文件保存到本地存储的临时文件中。

    var path = Path.GetTempPath() + name;
    using (var file = File.Create(path))
    {
     stream.Seek(0, SeekOrigin.Begin);
     await stream.CopyToAsync(file);
     file.Close();
     return path;
    }
    

    var output = new MemoryStream();
    var ffMpeg = new FFMpegConverter();
    ffMpeg.ConvertMedia(filePath, output, Format.ogg);
    output.Seek(0, SeekOrigin.Begin);
    return output;
    
        3
  •  1
  •   Aleks    11 年前
    static void Mp4ToOgg(string fileName)
    {
        DsReader dr = new DsReader(fileName);
        if (dr.HasAudio)
        {
            string waveFile = fileName + ".wav";
            WaveWriter ww = new WaveWriter(File.Create(waveFile),
                AudioCompressionManager.FormatBytes(dr.ReadFormat()));
            ww.WriteData(dr.ReadData());
            ww.Close();
            dr.Close();
            try
            {
                Sox.Convert(@"sox.exe", waveFile, waveFile + ".ogg", SoxAudioFileType.Ogg);
            }
            catch (SoxException ex)
            {
                throw;
            }
    
        }
    }
    

    How to converts a mp4 file to an ogg file