dmlc / decord

An efficient video loader for deep learning with smart shuffling that's super easy to digest
Apache License 2.0
1.86k stars 160 forks source link

VideoReader not taking into account specified frame indices #91

Open francoisruty opened 4 years ago

francoisruty commented 4 years ago

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

willprice commented 4 years ago

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 commented 4 years ago

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

francoisruty commented 4 years ago

thanks, that's interesting

francoisruty commented 4 years ago

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

willprice commented 4 years ago

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

francoisruty commented 4 years ago

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?

zhreshold commented 4 years ago

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

francoisruty commented 4 years ago

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