Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d4f6687
[video reader] inception commit
Sep 6, 2019
e8b2aed
add method save_metadata to class VideoClips in video_utils.py
Sep 8, 2019
5da3c20
add load_metadata() method to VideoClips class
Sep 8, 2019
c067796
add Exception to not catch unexpected events such as memory erros, in…
Sep 9, 2019
97ece7f
fix bugs in video_plus.py
Sep 9, 2019
3e3afbe
[video reader]remove logging. update setup.py
Sep 10, 2019
86e444d
remove time measurement in test_video_reader.py
Sep 10, 2019
f94d747
Remove glog and try making ffmpeg finding more robust
fmassa Sep 13, 2019
bdd2c5a
Add ffmpeg to conda build
fmassa Sep 13, 2019
3747d08
Add ffmpeg to conda build [again]
fmassa Sep 13, 2019
3664075
Make library path finding more robust
fmassa Sep 13, 2019
45d96d2
Missing import
fmassa Sep 13, 2019
eeeac12
One more missing fix for import
fmassa Sep 13, 2019
6d71938
Py2 compatibility and change package to av to avoid version conflict …
fmassa Sep 13, 2019
1063a72
Fix for python2
fmassa Sep 13, 2019
ecbbea5
[video reader] support to decode one stream only (e.g. video/audio st…
Sep 16, 2019
8877673
remove argument _precomputed_metadata_filepath
Sep 17, 2019
3a147b8
remove save_metadata method
Sep 17, 2019
8e6c5dc
add get_metadata method
Sep 17, 2019
cf067c3
expose _precomputed_metadata and frame_rate arguments in video datase…
Sep 17, 2019
33b2ab5
remove ssize_t
Sep 18, 2019
4071e8f
remove size_t to pass CI check on Windows
Sep 18, 2019
9184f37
add PyInit__video_reader function to pass CI check on Windows
Sep 18, 2019
6b8df4a
minor fix to define PyInit_video_reader symbol
Sep 18, 2019
7edcb6b
Make c++ video reader optional
fmassa Sep 19, 2019
d2981bd
Temporarily revert changes to test_io
fmassa Sep 19, 2019
4ea0440
Revert changes to python files
fmassa Sep 19, 2019
83c78e9
Rename files to make it private
fmassa Sep 19, 2019
37a2874
Fix python lint
fmassa Sep 19, 2019
906348c
Fix C++ lint
fmassa Sep 19, 2019
be42248
add a functor object EnumClassHash to make Enum class instances usabl…
Sep 19, 2019
5ecbd6a
fix cpp format check
Sep 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packaging/torchvision/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ requirements:
host:
- python
- setuptools
- av
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
Expand All @@ -21,6 +22,7 @@ requirements:
- pillow >=4.1.1
- numpy >=1.11
- six
- av
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}

Expand Down
41 changes: 38 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from pkg_resources import get_distribution, DistributionNotFound
import subprocess
import distutils.command.clean
import distutils.spawn
import glob
import shutil

import torch
from torch.utils.cpp_extension import CppExtension, CUDAExtension, CUDA_HOME
from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME


def read(*names, **kwargs):
Expand Down Expand Up @@ -124,6 +125,17 @@ def get_extensions():
include_dirs = [extensions_dir]
tests_include_dirs = [test_dir, models_dir]

ffmpeg_exe = distutils.spawn.find_executable('ffmpeg')
has_ffmpeg = ffmpeg_exe is not None
if has_ffmpeg:
ffmpeg_bin = os.path.dirname(ffmpeg_exe)
ffmpeg_root = os.path.dirname(ffmpeg_bin)
ffmpeg_include_dir = os.path.join(ffmpeg_root, 'include')

# TorchVision video reader
video_reader_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'cpu', 'video_reader')
video_reader_src = glob.glob(os.path.join(video_reader_src_dir, "*.cpp"))

ext_modules = [
extension(
'torchvision._C',
Expand All @@ -140,6 +152,27 @@ def get_extensions():
extra_compile_args=extra_compile_args,
),
]
if has_ffmpeg:
ext_modules.append(
CppExtension(
'torchvision.video_reader',
video_reader_src,
include_dirs=[
video_reader_src_dir,
ffmpeg_include_dir,
extensions_dir,
],
libraries=[
'avcodec',
'avformat',
'avutil',
'swresample',
'swscale',
],
extra_compile_args=["-std=c++14"],
extra_link_args=["-std=c++14"],
)
)

return ext_modules

Expand Down Expand Up @@ -179,6 +212,8 @@ def run(self):
"scipy": ["scipy"],
},
ext_modules=get_extensions(),
cmdclass={'build_ext': torch.utils.cpp_extension.BuildExtension,
'clean': clean}
cmdclass={
'build_ext': BuildExtension.with_options(no_python_abi_suffix=True),
'clean': clean,
}
)
Binary file added test/assets/videos/R6llTwEh07w.mp4
Binary file not shown.
Binary file not shown.
59 changes: 59 additions & 0 deletions test/assets/videos/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Video meta-information Notation

Video File Name
video: codec, fps
audio: codec, bits per sample, sample rate

Test videos are listed below.
--------------------------------

- RATRACE_wave_f_nm_np1_fr_goo_37.avi
- source: hmdb51
- video: DivX MPEG-4
- fps: 30
- audio: N/A

- SchoolRulesHowTheyHelpUs_wave_f_nm_np1_ba_med_0.avi
- source: hmdb51
- video: DivX MPEG-4
- fps: 30
- audio: N/A

- TrumanShow_wave_f_nm_np1_fr_med_26.avi
- source: hmdb51
- video: DivX MPEG-4
- fps: 30
- audio: N/A

- v_SoccerJuggling_g23_c01.avi
- source: ucf101
- video: Xvid MPEG-4
- fps: 29.97
- audio: N/A

- v_SoccerJuggling_g24_c01.avi
- source: ucf101
- video: Xvid MPEG-4
- fps: 29.97
- audio: N/A

- R6llTwEh07w.mp4
- source: kinetics-400
- video: H-264 - MPEG-4 AVC (part 10) (avc1)
- fps: 30
- audio: MPEG AAC audio (mp4a)
- sample rate: 44.1K Hz

- SOX5yA1l24A.mp4
- source: kinetics-400
- video: H-264 - MPEG-4 AVC (part 10) (avc1)
- fps: 29.97
- audio: MPEG AAC audio (mp4a)
- sample rate: 48K Hz

- WUzgd7C1pWA.mp4
- source: kinetics-400
- video: H-264 - MPEG-4 AVC (part 10) (avc1)
- fps: 29.97
- audio: MPEG AAC audio (mp4a)
- sample rate: 48K Hz
Binary file added test/assets/videos/SOX5yA1l24A.mp4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/assets/videos/WUzgd7C1pWA.mp4
Binary file not shown.
Binary file added test/assets/videos/v_SoccerJuggling_g23_c01.avi
Binary file not shown.
Binary file added test/assets/videos/v_SoccerJuggling_g24_c01.avi
Binary file not shown.
Loading