[MPlayer-users] MPlayer doesn't recognize I-Frames in MPEG-PS

Yaro Pollak slava at plris.com
Thu Jul 14 13:01:16 CEST 2005


Hello guys,

I use MPlayer-1.0pre7 and I have a strange problem when seeking in an MPEG-PS (MPEG4) file.
The general symptoms is that the seek is done to a general location of the requested point, but it can be off up to 5 seconds.
So I decided to study the phenomena, and I narrowed it down to this loop, which is located in demux_mpg.c in the function demux_seek_mpg():

while(1){
  int i;
  if(sh_audio && !d_audio->eof && d_video->pts && d_audio->pts){
    float a_pts=d_audio->pts;
    a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
    if(d_video->pts>a_pts){
      skip_audio_frame(sh_audio);  // sync audio
      continue;
    }
  }
  i=sync_video_packet(d_video);
  if(sh_video->format == 0x10000004) { //mpeg4
    if(i==0x1B6) {   //vop (frame) startcode
      int pos = videobuf_len;
      if(!read_video_packet(d_video)) break; // EOF
      if((videobuffer[pos+4] & 0x3F) == 0) break; //I-frame
    }
  } else if(sh_video->format == 0x10000005){ //h264
    if((i & ~0x60) == 0x101 || (i & ~0x60) == 0x102 || (i & ~0x60) == 0x105) break;
  } else {  //default mpeg1/2
    if(i==0x1B3 || i==0x1B8) break; // found it!
  }
  if(!i || !skip_video_packet(d_video)) break; // EOF?
}

It seems that the check if((videobuffer[pos+4] & 0x3F) == 0) break; //I-frame never works, then the precision of the search is decreased, the search is done again, and it ends up somewhere in the vicinity of where I seeked to, but that is of course not enough.
At first I thought maybe I have a somewhat broken file, but using ffmpeg directly (by ffplay) results in a seek to a correct location.

Any ideas on the subject? Perhaps this is a known bug? Then does anyone know how to fix it (I'm not that familiar with the MPEG-PS format to determine where does is frame discriptor located and what should it be for an I-frame)?

Thank you in advance
Yaro


More information about the MPlayer-users mailing list