decord icon indicating copy to clipboard operation
decord copied to clipboard

VideoReader not taking into account specified frame indices

Open francoisruty opened this issue 5 years ago • 9 comments

hello, I'm using decord VideoReader. I used it on a 50min video, and whatever frame index I use, it always extract a frame from the first 30s of the video, I have no idea why. Whether I use vr[index] or vr.get_batch([index]), whatever index (from 50 to 65000), it always returns a frame from the beginning of the video. All indices I try are lower than frame count.

Using decord latest pypi version, on CPU, on linux

francoisruty avatar Aug 17 '20 13:08 francoisruty

I'm having the same issue too, it seems the frames I'm getting are exactly from the same start point in a video regardless of what frame idx I request (via VideoReader.get_batch). This is on vp8 encoded video in a webm container.

willprice avatar Aug 18 '20 14:08 willprice

It seems when I use decord to load frames from a re-encoding of the VP8 source to H264 then seeking works correctly.

willprice avatar Aug 18 '20 14:08 willprice

thanks, that's interesting

francoisruty avatar Aug 18 '20 15:08 francoisruty

@willprice what did you use to re-encode your video? Can it work on linux?

francoisruty avatar Aug 19 '20 17:08 francoisruty

I used ffmpeg, something like ffmpeg -i input-video.webm -c:v libx265 -b:v 1M output.mp4 (vary -b:v to change quality)

willprice avatar Aug 19 '20 17:08 willprice

Thanks, I re-encoded my video and now the frames I get seem to span all the video, however the mode shuffle=2 does not seem to work, all the batches seem to contain consecutive frames

Did you encounter the same issue?

francoisruty avatar Aug 19 '20 21:08 francoisruty

If you encounter any seeking issue, it's helpful to attach a small piece of the video and provide the ffmpeg diagnose info for example

Input #0, matroska,webm, from 'Javelin_standing_throw_drill.mkv':
  Metadata:
    COMPATIBLE_BRANDS: iso6avc1mp41
    MAJOR_BRAND     : dash
    MINOR_VERSION   : 0
    ENCODER         : Lavf58.12.100
  Duration: 00:00:10.14, start: -0.007000, bitrate: 4226 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      HANDLER_NAME    : VideoHandler
      DURATION        : 00:00:10.110000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:10.141000000

The correctness of frame decoding is rather difficult to check given that there are so many video formats with correct/incorrect metadata laying around

zhreshold avatar Aug 19 '20 21:08 zhreshold

Hello, thanks for your reply, here is the diagnose info:

Input #0, matroska,webm, from 'GOTS07E01.mkv':
  Metadata:
    COMPATIBLE_BRANDS: isomiso2avc1mp41
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 512
    ENCODER         : Lavf57.76.100
  Duration: 01:01:27.99, start: 0.000000, bitrate: 1161 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      HANDLER_NAME    : VideoHandler
      DURATION        : 01:01:27.976000000
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      HANDLER_NAME    : SoundHandler
      DURATION        : 01:01:27.991000000

extract.mkv.zip

francoisruty avatar Aug 19 '20 21:08 francoisruty