Skip to content

Commit 77da6bc

Browse files
authored
Fix decode_video returning only the first frame (#1482)
* fix decode_video returning only the first frame * fix lint error
1 parent 014989a commit 77da6bc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tensorflow_io/core/kernels/ffmpeg_kernels.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,7 @@ class FFmpegVideoStream : public FFmpegStream {
669669
char* base = ((char*)(value->flat<uint8>().data()));
670670
int64 datasize = height_ * width_ * channels_;
671671
for (size_t i = 0; i < frames_.size(); i++) {
672-
memcpy(base, reinterpret_cast<char*>(frames_buffer_.front().get()),
673-
datasize);
672+
memcpy(base, reinterpret_cast<char*>(frames_buffer_[i].get()), datasize);
674673
base += datasize;
675674
}
676675
frames_.clear();

tests/test_ffmpeg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def test_ffmpeg_decode_video(video_path):
8484
video = tfio.experimental.ffmpeg.decode_video(content, 0)
8585
assert video.shape == [166, 320, 560, 3]
8686
assert video.dtype == tf.uint8
87+
assert np.abs(video[0] - video[-1]).sum() > 0
8788

8889

8990
def test_ffmpeg_decode_video_invalid_content():

0 commit comments

Comments
 (0)