Ejemplo n.º 1
0
 public static extern int av_picture_pad(AVPicture* dst, AVPicture* src, int height, int width, AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int* color);
Ejemplo n.º 2
0
 public static extern void av_picture_copy(AVPicture* dst, AVPicture* src, AVPixelFormat pix_fmt, int width, int height);
Ejemplo n.º 3
0
 public static extern int av_picture_crop(AVPicture* dst, AVPicture* src, AVPixelFormat pix_fmt, int top_band, int left_band);
Ejemplo n.º 4
0
 public static extern int avpicture_layout(AVPicture* src, AVPixelFormat pix_fmt, int width, int height, sbyte* dest, int dest_size);
Ejemplo n.º 5
0
 public static extern int avpicture_deinterlace(AVPicture* dst, AVPicture* src, AVPixelFormat pix_fmt, int width, int height);
Ejemplo n.º 6
0
 public static extern void avpicture_free(AVPicture* picture);
Ejemplo n.º 7
0
 public static extern int avpicture_fill(AVPicture* picture, byte* ptr, AVPixelFormat pix_fmt, int width, int height);
Ejemplo n.º 8
0
        private unsafe static Bitmap ExtractNextImage(AVFormatContext* pFormatContext, AVCodecContext* pCodecContext, AVPacket* pPacket, AVStream* vidStream, SwsContext* pConvertContext, AVFrame* pDecodedFrame, AVPicture* pConvertedFrame, int width, int height, bool createCopy, double timeBase, out TimeSpan pos)
        {
            pos = new TimeSpan();
            Bitmap result = null;

            int gotPicture = 0;

            while (gotPicture != 1)
            {
                if (ffmpeg.av_read_frame(pFormatContext, pPacket) < 0)
                {
                    result = null;
                    break;
                }

                if (pPacket->stream_index != vidStream->index)
                    continue;

                gotPicture = 0;
                int size = ffmpeg.avcodec_decode_video2(pCodecContext, pDecodedFrame, &gotPicture, pPacket);
                if (size < 0)
                    throw new Exception("Error while decoding frame!");

                if (gotPicture == 1)
                {
                    // Get current position from frame
                    pos = ToTimeSpan(ffmpeg.av_frame_get_best_effort_timestamp(pDecodedFrame), timeBase);

                    // Extract image
                    sbyte** src = &pDecodedFrame->data0;
                    sbyte** dst = &pConvertedFrame->data0;
                    ffmpeg.sws_scale(pConvertContext, src, pDecodedFrame->linesize, 0, height, dst, pConvertedFrame->linesize);
                    var imageBufferPtr = new IntPtr(pConvertedFrame->data0);
                    int linesize = pConvertedFrame->linesize[0];
                    Bitmap img = new Bitmap(width, height, linesize, PixelFormat.Format24bppRgb, imageBufferPtr);

                    result = createCopy ? new Bitmap(img) : img;
                }

            }

            return result;
        }
Ejemplo n.º 9
0
 public static extern int avpicture_alloc(AVPicture* picture, AVPixelFormat pix_fmt, int width, int height);
Ejemplo n.º 10
0
 public static extern int av_picture_crop(AVPicture* @dst, AVPicture* @src, AVPixelFormat @pix_fmt, int @top_band, int @left_band);
Ejemplo n.º 11
0
 public static extern int av_picture_pad(AVPicture* @dst, AVPicture* @src, int @height, int @width, AVPixelFormat @pix_fmt, int @padtop, int @padbottom, int @padleft, int @padright, int* @color);
Ejemplo n.º 12
0
 public static extern void av_picture_copy(AVPicture* @dst, AVPicture* @src, AVPixelFormat @pix_fmt, int @width, int @height);
Ejemplo n.º 13
0
 public static extern int avpicture_layout(AVPicture* @src, AVPixelFormat @pix_fmt, int @width, int @height, sbyte* @dest, int @dest_size);
Ejemplo n.º 14
0
 public static extern int avpicture_fill(AVPicture* @picture, sbyte* @ptr, AVPixelFormat @pix_fmt, int @width, int @height);
Ejemplo n.º 15
0
        private unsafe Bitmap ExtractNextImage2(AVCodecContext* pCodecContext, AVPacket* pPacket, AVStream* vidStream, SwsContext* pConvertContext, AVFrame* pDecodedFrame, AVPicture* pConvertedFrame, int width, int height, bool createCopy, double timeBase, int? delay, TimeSpan prev, out TimeSpan pos, out bool end)
        {
            pos = new TimeSpan();
            end = false;
            Bitmap result = null;

            int gotPicture = 0;

            while (gotPicture != 1)
            {
                if (ffmpeg.av_read_frame(this.AVFormatContext, pPacket) < 0)
                {
                    end = true;
                    result = null;
                    break;
                }

                if (pPacket->stream_index != vidStream->index)
                    continue;

                gotPicture = 0;
                int size = ffmpeg.avcodec_decode_video2(pCodecContext, pDecodedFrame, &gotPicture, pPacket);
                if (size < 0)
                    throw new Exception("Error while decoding frame!");

                if (gotPicture == 1)
                {
                    // Get current position from frame
                    pos = ToTimeSpan(ffmpeg.av_frame_get_best_effort_timestamp(pDecodedFrame), timeBase);

                    if (delay.HasValue && prev != TimeSpan.Zero && (pos - prev).TotalMilliseconds < delay)
                    {
                        return null;
                    }

                    // Extract image
                    sbyte** src = &pDecodedFrame->data0;
                    sbyte** dst = &pConvertedFrame->data0;
                    int src_height = pCodecContext->height;
                    ffmpeg.sws_scale(pConvertContext, src, pDecodedFrame->linesize, 0, src_height, dst, pConvertedFrame->linesize);
                    var imageBufferPtr = new IntPtr(pConvertedFrame->data0);
                    int linesize = pConvertedFrame->linesize[0];
                    result = new Bitmap(width, height, linesize, PixelFormat.Format24bppRgb, imageBufferPtr);
                }

            }

            return result;
        }
Ejemplo n.º 16
0
 public static extern int avpicture_deinterlace(AVPicture* @dst, AVPicture* @src, AVPixelFormat @pix_fmt, int @width, int @height);