Exemplo n.º 1
0
 public static extern AVError av_read_play(ref AVFormatContext pAVFormatContext);
Exemplo n.º 2
0
 public static extern AVError av_seek_frame(ref AVFormatContext pAVFormatContext, int stream_index, long timestamp, AVSEEK_FLAG flags);
Exemplo n.º 3
0
 private static extern AVError av_open_input_stream(out AVFormatContext* ic_ptr, ref ByteIOContext pb,
     string filename, ref AVInputFormat fmt, ref AVFormatParameters ap);
Exemplo n.º 4
0
 public static extern AVError avformat_find_stream_info(ref AVFormatContext pAVFormatContext, AVDictionary** options);
Exemplo n.º 5
0
 public static extern AVError av_write_header(ref AVFormatContext pAVFormatContext);
Exemplo n.º 6
0
 public static extern void dump_format(ref AVFormatContext pAVFormatContext, int index, string url, int is_output);
Exemplo n.º 7
0
 public static extern AVError av_find_stream_info(ref AVFormatContext pAVFormatContext);
Exemplo n.º 8
0
 public static extern void av_update_cur_dts(ref AVFormatContext pAVFormatContext, ref AVStream pAVStream, long timestamp);
Exemplo n.º 9
0
 public static extern void av_close_input_file(ref AVFormatContext pAVFormatContext);
Exemplo n.º 10
0
 public static extern AVError av_find_default_stream_index(ref AVFormatContext pAVFormatContext);
Exemplo n.º 11
0
 public static extern AVError avf_sdp_create(AVFormatContext** ac, int n_files, [In,Out]StringBuilder buff, int size);
Exemplo n.º 12
0
 public static unsafe void avformat_close_input(ref AVFormatContext s)
 {
     fixed (AVFormatContext* avc = &s)
     {
         IntPtr ptr = (IntPtr)avc;
         avformat_close_input(ref ptr);
     }
 }
Exemplo n.º 13
0
 public static extern AVError avformat_write_header(ref AVFormatContext pAVFormatContext, AVDictionary** options);
Exemplo n.º 14
0
 public static extern AVError av_seek_frame_binary(ref AVFormatContext pAVFormatContext, int stream_index, long target_ts, AVSEEK_FLAG flags);
Exemplo n.º 15
0
 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);
Exemplo n.º 16
0
 public static extern AVError av_set_parameters(ref AVFormatContext pAVFormatContext, AVFormatParameters* pAVFormatParameters);
Exemplo n.º 17
0
 public static extern AVStream* av_new_stream(ref AVFormatContext pAVFormatContext, int id);
Exemplo n.º 18
0
 public static extern int av_write_frame(ref AVFormatContext pAVFormatContext, ref AVPacket pAVPacket);
Exemplo n.º 19
0
        /// <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;
        }
Exemplo n.º 20
0
 public static extern int av_write_trailer(ref AVFormatContext pAVFormatContext);
Exemplo n.º 21
0
        /// <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;
        }
Exemplo n.º 22
0
 public static extern void ffm_set_write_index(ref AVFormatContext pAVFormatContext, long pos, long file_size);
Exemplo n.º 23
0
 public static extern AVError av_read_packet(ref AVFormatContext pAVFormatContext, ref AVPacket pAVPacket);
Exemplo n.º 24
0
        /// <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;
        }
Exemplo n.º 25
0
        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);
        }