sumodhkrishna / ffmpeg-sharp

ffmpeg-sharp
1 stars 0 forks source link

Open, Seek + ReadFrame => decoding error (current packet not a key frame) #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
context: I'm tying to create a thumbnailer using ffmpeg-sharp

What steps will reproduce the problem?
1. open MediaFile
2. get VideoDecoderStream
3. create VideoScalingStream
4. Seek (100ms)
5. ReadFrame (out frame)

What is the expected output? What do you see instead?
expected: decoded frame bytes
instead: crash

What version of the product are you using? On what operating system?
latest

Please provide any additional information below.

as a workaround I added a loop, forcing a key frame to be returned (i'm only 
interested in single frame decoding -> creating thumbnails)

MediaFile.cs:120
internal void EnqueueNextPacket()
{
  AVPacket packet = new AVPacket();
  FFmpeg.av_init_packet(ref packet);

+  while (packet.flags != PacketFlags.Key)
+  {
    if (FFmpeg.av_read_frame(ref FormatContext, ref packet) < 0)
      throw new System.IO.EndOfStreamException();
+  }

Original issue reported on code.google.com by l.ordelm...@gmail.com on 29 Feb 2012 at 10:53