public static void SaveSound(string path, byte[] data, int sampleCount, int targetSampleRate) { using (FFmpegContext ffContext = FFmpegContext.Write(path)) { ffContext.SetOutputFormat(AVCodecID.AV_CODEC_ID_NONE, targetSampleRate, sampleCount, AVSampleFormat.AV_SAMPLE_FMT_S16); ffContext.WriteHeader(); ffContext.WriteFrame(data); } }
// compression level [0-9] public static void SaveImagePNG(string path, byte[] data, int width, int height, int compression = 1) { using (FFmpegContext ffContext = FFmpegContext.Write(path)) { ffContext.SetOutputFormat(AVCodecID.AV_CODEC_ID_PNG, width, height, AVPixelFormat.AV_PIX_FMT_BGRA, compression); ffContext.WriteHeader(); ffContext.WriteFrame(data); } }