Ejemplo n.º 1
0
        public TimeSpan Seek(TimeSpan offset, SeekOrigin origin)
        {
            TimeSpan newPosition = TimeSpan.Zero;

            switch (origin)
            {
            case SeekOrigin.Begin:
                newPosition = offset;
                break;

            case SeekOrigin.Current:
                newPosition = offset + Timestamp;
                break;

            case SeekOrigin.End:
                newPosition = Duration - Timestamp;
                break;
            }

            if (newPosition < TimeSpan.Zero)
            {
                newPosition = TimeSpan.Zero;
            }
            else if (newPosition > Duration)
            {
                newPosition = Duration;
            }

            bool backward = newPosition > Timestamp;

            AVSEEK_FLAG flags    = AVSEEK_FLAG.Any | (backward ? AVSEEK_FLAG.Backward: 0);
            long        position = (long)(newPosition.TotalSeconds * FFmpeg.AV_TIME_BASE);

            if (FFmpeg.av_seek_frame(ref m_file.FormatContext, -1, position, flags) < 0)
            {
                m_position  = Length;
                m_timestamp = Duration;
                return(Duration);
            }

            FFmpeg.avcodec_flush_buffers(ref m_avCodecCtx);

            m_timestamp = offset;
            m_position  = (long)(m_timestamp.TotalSeconds * UncompressedBytesPerSecond);

            return(m_timestamp);
        }
Ejemplo n.º 2
0
 public static extern AVError av_seek_frame_binary(ref AVFormatContext pAVFormatContext, int stream_index, long target_ts, AVSEEK_FLAG flags);
Ejemplo n.º 3
0
 public static extern AVError av_index_search_timestamp(ref AVStream pAVStream, long timestamp, AVSEEK_FLAG flags);
Ejemplo n.º 4
0
 public static extern AVError av_seek_frame(ref AVFormatContext pAVFormatContext, int stream_index, long timestamp, AVSEEK_FLAG flags);
Ejemplo n.º 5
0
 public static extern AVError av_add_index_entry(ref AVStream pAVStream, long pos, long timestamp, int size, int distance, AVSEEK_FLAG flags);
Ejemplo n.º 6
0
 public static extern AVError av_add_index_entry(ref AVStream pAVStream, long pos, long timestamp, int size, int distance, AVSEEK_FLAG flags);
Ejemplo n.º 7
0
 public static extern AVError av_index_search_timestamp(ref AVStream pAVStream, long timestamp, AVSEEK_FLAG flags);
Ejemplo n.º 8
0
 public static extern AVError av_seek_frame(ref AVFormatContext pAVFormatContext, int stream_index, long timestamp, AVSEEK_FLAG flags);
Ejemplo n.º 9
0
 public static extern AVError av_seek_frame_binary(ref AVFormatContext pAVFormatContext, int stream_index, long target_ts, AVSEEK_FLAG flags);