Ejemplo n.º 1
0
 public void Flush()
 {
     if (!isFlush)
     {
         FF.av_write_trailer(formatContext).CheckFFmpegCode();
         isFlush = true;
     }
 }
Ejemplo n.º 2
0
        public void Flush()
        {
            if (readyEncoders == null)
            {
                return;
            }

            readyEncoders = new List <Encoder>(encoders);
            while (true)
            {
                var encoder = readyEncoders.Minimal(e => e.InputFrames * e.codecContext->TimeBase.Value);
                if (encoder == null)
                {
                    break;
                }

                var queue = fixedQueues[encoder.StreamIndex];
                if (queue != null)
                {
                    var frame = queue.Dequeue(false);
                    if (frame != null)
                    {
                        Encode(encoder, frame);
                        continue;
                    }
                }
                while (encoder.Encode(null, packet))
                {
                    InternalWrite(packet);
                }
                readyEncoders.Remove(encoder);
                formatContext->Streams[encoder.StreamIndex]->Duration = encoder.InputTimestamp.Ticks / 10;
            }

            int result = FF.av_write_trailer(formatContext);

            if (result < 0)
            {
                throw new FFmpegException(result);
            }
            readyEncoders = null;
        }