Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
2804c122
Commit
2804c122
authored
Oct 21, 2019
by
Zhicheng Yan
Committed by
Francisco Massa
Oct 21, 2019
Browse files
fix a bug when video decoding fails and empty frames are returned (#1506)
parent
a711c80e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
torchvision/io/video.py
torchvision/io/video.py
+5
-3
No files found.
torchvision/io/video.py
View file @
2804c122
...
@@ -137,12 +137,14 @@ def _read_from_stream(container, start_offset, end_offset, pts_unit, stream, str
...
@@ -137,12 +137,14 @@ def _read_from_stream(container, start_offset, end_offset, pts_unit, stream, str
pass
pass
# ensure that the results are sorted wrt the pts
# ensure that the results are sorted wrt the pts
result
=
[
frames
[
i
]
for
i
in
sorted
(
frames
)
if
start_offset
<=
frames
[
i
].
pts
<=
end_offset
]
result
=
[
frames
[
i
]
for
i
in
sorted
(
frames
)
if
start_offset
<=
frames
[
i
].
pts
<=
end_offset
]
if
start_offset
>
0
and
start_offset
not
in
frames
:
if
len
(
frames
)
>
0
and
start_offset
>
0
and
start_offset
not
in
frames
:
# if there is no frame that exactly matches the pts of start_offset
# if there is no frame that exactly matches the pts of start_offset
# add the last frame smaller than start_offset, to guarantee that
# add the last frame smaller than start_offset, to guarantee that
# we will have all the necessary data. This is most useful for audio
# we will have all the necessary data. This is most useful for audio
first_frame_pts
=
max
(
i
for
i
in
frames
if
i
<
start_offset
)
preceding_frames
=
[
i
for
i
in
frames
if
i
<
start_offset
]
result
.
insert
(
0
,
frames
[
first_frame_pts
])
if
len
(
preceding_frames
)
>
0
:
first_frame_pts
=
max
(
preceding_frames
)
result
.
insert
(
0
,
frames
[
first_frame_pts
])
return
result
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment