public static extern AVError av_read_play(ref AVFormatContext pAVFormatContext);
public static extern AVError av_seek_frame(ref AVFormatContext pAVFormatContext, int stream_index, long timestamp, AVSEEK_FLAG flags);
private static extern AVError av_open_input_stream(out AVFormatContext* ic_ptr, ref ByteIOContext pb, string filename, ref AVInputFormat fmt, ref AVFormatParameters ap);
public static extern AVError avformat_find_stream_info(ref AVFormatContext pAVFormatContext, AVDictionary** options);
public static extern AVError av_write_header(ref AVFormatContext pAVFormatContext);
public static extern void dump_format(ref AVFormatContext pAVFormatContext, int index, string url, int is_output);
public static extern AVError av_find_stream_info(ref AVFormatContext pAVFormatContext);
public static extern void av_update_cur_dts(ref AVFormatContext pAVFormatContext, ref AVStream pAVStream, long timestamp);
public static extern void av_close_input_file(ref AVFormatContext pAVFormatContext);
public static extern AVError av_find_default_stream_index(ref AVFormatContext pAVFormatContext);
public static extern AVError avf_sdp_create(AVFormatContext** ac, int n_files, [In,Out]StringBuilder buff, int size);
public static unsafe void avformat_close_input(ref AVFormatContext s) { fixed (AVFormatContext* avc = &s) { IntPtr ptr = (IntPtr)avc; avformat_close_input(ref ptr); } }
public static extern AVError avformat_write_header(ref AVFormatContext pAVFormatContext, AVDictionary** options);
public static extern AVError av_seek_frame_binary(ref AVFormatContext pAVFormatContext, int stream_index, long target_ts, AVSEEK_FLAG flags);
public static extern int av_interleave_packet_per_dts(ref AVFormatContext pAVFormatContext, ref AVPacket p_out_AVPacket, ref AVPacket pAVPacket, [MarshalAs(UnmanagedType.Bool)]bool flush);
public static extern AVError av_set_parameters(ref AVFormatContext pAVFormatContext, AVFormatParameters* pAVFormatParameters);
public static extern AVStream* av_new_stream(ref AVFormatContext pAVFormatContext, int id);
public static extern int av_write_frame(ref AVFormatContext pAVFormatContext, ref AVPacket pAVPacket);
/// <summary> /// Opens a media file as input. The codecs are not opened. Only the file /// header (if present) is read. /// </summary> /// <param name="pFormatContext">the opened media file handle is put here</param> /// <param name="filename">filename to open</param> /// <returns>AVError</returns> public static AVError av_open_input_file(out AVFormatContext pFormatContext, string filename) { IntPtr ptr; AVError err = av_open_input_file(out ptr, filename, null, 0, null); if (ptr == IntPtr.Zero) { pFormatContext = new AVFormatContext(); return err; } pFormatContext = *(AVFormatContext*)ptr.ToPointer(); FFmpeg.av_freep(ref ptr); return err; }
public static extern int av_write_trailer(ref AVFormatContext pAVFormatContext);
/// <summary> /// Opens a media file as input. The codecs are not opened. Only the file /// header (if present) is read. /// </summary> /// <param name="pFormatContext">the opened media file handle is put here</param> /// <param name="filename">filename to open</param> /// <param name="pAVInputFormat">if non null, force the file format to use</param> /// <param name="buf_size">optional buffer size (zero as default is OK)</param> /// <param name="pAVFormatParameters">Additional parameters needed when open the file (Null if default)</param> /// <returns>AVError</returns> public static AVError av_open_input_file(out AVFormatContext pFormatContext, string filename, ref AVInputFormat fmt, int buf_size, ref AVFormatParameters ap) { IntPtr ptr; AVError err = av_open_input_file(out ptr, filename, ref fmt, 0, ref ap); if (ptr == IntPtr.Zero) { pFormatContext = new AVFormatContext(); return err; } pFormatContext = *(AVFormatContext*)ptr.ToPointer(); FFmpeg.av_freep(ref ptr); return err; }
public static extern void ffm_set_write_index(ref AVFormatContext pAVFormatContext, long pos, long file_size);
public static extern AVError av_read_packet(ref AVFormatContext pAVFormatContext, ref AVPacket pAVPacket);
/// <summary> /// Allocates all the structures needed to read an input stream. /// This does not open the needed codecs for decoding the stream[s]. /// </summary> private static AVError av_open_input_stream(out AVFormatContext ctx, ref ByteIOContext pb, string filename, ref AVInputFormat fmt, ref AVFormatParameters ap) { AVFormatContext* ptr; AVError err = av_open_input_stream(out ptr, ref pb, filename, ref fmt, ref ap); ctx = *ptr; FFmpeg.av_free(ptr); return err; }
public AudioEncoderStream(string Filename, EncoderInformation EncoderInfo) { // Initialize instance variables m_filename = Filename; m_disposed = m_fileOpen = false; m_buffer = new FifoMemoryStream(); // Open FFmpeg FFmpeg.av_register_all(); // Initialize the output format context m_avFormatCtx = FFmpeg.av_alloc_format_context(); // Get output format m_avFormatCtx.oformat = FFmpeg.guess_format(EncoderInfo.Codec.ShortName, null, null); if (m_avFormatCtx.oformat != null) throw new EncoderException("Could not find output format."); FFmpeg.av_set_parameters(ref m_avFormatCtx, null); // Initialize the new output stream AVStream* stream = FFmpeg.av_new_stream(ref m_avFormatCtx, 1); if (stream == null) throw new EncoderException("Could not alloc output audio stream"); m_avStream = *stream; // Initialize output codec context m_avCodecCtx = *m_avStream.codec; m_avCodecCtx.codec_id = EncoderInfo.Codec.CodecID; m_avCodecCtx.codec_type = CodecType.CODEC_TYPE_AUDIO; m_avCodecCtx.sample_rate = EncoderInfo.SampleRate; m_avCodecCtx.channels = EncoderInfo.Channels; m_avCodecCtx.bits_per_sample = EncoderInfo.SampleSize; m_avCodecCtx.bit_rate = EncoderInfo.Bitrate; if (EncoderInfo.VBR) { m_avCodecCtx.flags |= FFmpeg.CODEC_FLAG_QSCALE; m_avCodecCtx.global_quality = EncoderInfo.FFmpegQualityScale; } // Open codec AVCodec* outCodec = FFmpeg.avcodec_find_encoder(m_avCodecCtx.codec_id); if (outCodec == null) throw new EncoderException("Could not find encoder"); if (FFmpeg.avcodec_open(ref m_avCodecCtx, outCodec) < 0) throw new EncoderException("Could not open codec."); // Open and prep file if (FFmpeg.url_fopen(ref m_avFormatCtx.pb, m_filename, FFmpeg.URL_WRONLY) < 0) throw new EncoderException("Could not open output file."); m_fileOpen = true; FFmpeg.av_write_header(ref m_avFormatCtx); }