Skip to content

Commit

Permalink
Fix decode_video returning only the first frame (tensorflow#1482)
Browse files Browse the repository at this point in the history
* fix decode_video returning only the first frame

* fix lint error
  • Loading branch information
kyamagu authored Jul 26, 2021
1 parent 1af508b commit 21b706c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tensorflow_io/core/kernels/ffmpeg_kernels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,7 @@ class FFmpegVideoStream : public FFmpegStream {
char* base = ((char*)(value->flat<uint8>().data()));
int64 datasize = height_ * width_ * channels_;
for (size_t i = 0; i < frames_.size(); i++) {
memcpy(base, reinterpret_cast<char*>(frames_buffer_.front().get()),
datasize);
memcpy(base, reinterpret_cast<char*>(frames_buffer_[i].get()), datasize);
base += datasize;
}
frames_.clear();
Expand Down
1 change: 1 addition & 0 deletions tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def test_ffmpeg_decode_video(video_path):
video = tfio.experimental.ffmpeg.decode_video(content, 0)
assert video.shape == [166, 320, 560, 3]
assert video.dtype == tf.uint8
assert np.abs(video[0] - video[-1]).sum() > 0


def test_ffmpeg_decode_video_invalid_content():
Expand Down

0 comments on commit 21b706c

Please sign in to comment.