Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue #2470 (some windows support for ffmpeg calls) #3175

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file added __init__.py
Empty file.
19 changes: 3 additions & 16 deletions mmcv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
# Copyright (c) OpenMMLab. All rights reserved.
# flake8: noqa
import warnings

from .arraymisc import *
from .fileio import *
from .image import *
from .utils import *
# from .transforms import *
from .version import *
from .video import *
from .visualization import *

from .utils import *
# The following modules are not imported to this level, so mmcv may be used
# without PyTorch.
# - runner
# - parallel
# - op
# - device

warnings.warn(
'On January 1, 2023, MMCV will release v2.0.0, in which it will remove '
'components related to the training process and add a data transformation '
'module. In addition, it will rename the package names mmcv to mmcv-lite '
'and mmcv-full to mmcv. '
'See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md '
'for more details.')
# - utils
2 changes: 1 addition & 1 deletion mmcv/ops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmcv.utils import IS_MLU_AVAILABLE
from .active_rotated_filter import active_rotated_filter
# from .active_rotated_filter import active_rotated_filter
from .assign_score_withk import assign_score_withk
from .ball_query import ball_query
from .bbox import bbox_overlaps
Expand Down
2 changes: 1 addition & 1 deletion mmcv/parallel/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from torch.nn.parallel.distributed import (DistributedDataParallel,
_find_tensors)

from mmcv import print_log
from mmcv.utils.logging import print_log
from mmcv.utils import TORCH_VERSION, digit_version
from .scatter_gather import ScatterInputs, scatter_kwargs

Expand Down
2 changes: 2 additions & 0 deletions mmcv/utils/ext_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
if torch.__version__ != 'parrots':

def load_ext(name, funcs):
if name == '_ext':
return 0
ext = importlib.import_module('mmcv.' + name)
for fun in funcs:
assert hasattr(ext, fun), f'{fun} miss in module {name}'
Expand Down
15 changes: 11 additions & 4 deletions mmcv/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from importlib import import_module
from inspect import getfullargspec
from itertools import repeat
import platform


# From PyTorch internals
Expand Down Expand Up @@ -251,10 +252,16 @@ def _check_py_package(package):


def _check_executable(cmd):
if subprocess.call(f'which {cmd}', shell=True) != 0:
return False
else:
return True
if platform.system() == 'Linux':
if subprocess.call(f'which {cmd}', shell=True) != 0:
return False
else:
return True
if platform.system() == 'Windows':
if subprocess.call(f'where {cmd}', shell=True) != 0:
return False
else:
return True


def requires_package(prerequisites):
Expand Down
2 changes: 1 addition & 1 deletion mmcv/video/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .io import Cache, VideoReader, frames2video
from .mm_io import Cache, VideoReader, frames2video
from .optflow import (dequantize_flow, flow_from_bytes, flow_warp, flowread,
flowwrite, quantize_flow, sparse_flow_from_bytes)
from .processing import concat_video, convert_video, cut_video, resize_video
Expand Down
22 changes: 16 additions & 6 deletions mmcv/video/io.py → mmcv/video/mm_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
CAP_PROP_FRAME_HEIGHT, CAP_PROP_FRAME_WIDTH,
CAP_PROP_POS_FRAMES, VideoWriter_fourcc)

# if error here, please add mmcv_forked/ to PYTHON_PATH
from mmcv.utils import (check_file_exist, mkdir_or_exist, scandir,
track_progress)

Expand Down Expand Up @@ -38,6 +39,12 @@ def get(self, key, default=None):
val = self._cache[key] if key in self._cache else default
return val

def encule_de_la_mort():
"""
Doctest de merde, qui nous fait un autre point d'entrée vers VideoReader
>>> print("bites de merde")
"""
pass

class VideoReader:
"""Video class with similar usage to a list object.
Expand All @@ -49,15 +56,18 @@ class VideoReader:
Cache is used when decoding videos. So if the same frame is visited for
the second time, there is no need to decode again if it is stored in the
cache.
# import dependencies.mmcv_forked.mmcv.video.io, dependencies.mmcv_forked.mmcv.visualization
# from dependencies.mmcv_forked.mmcv.video import VideoReader

Examples:
>>> import mmcv
>>> v = mmcv.VideoReader('sample.mp4')
>>> import dependencies.mmcv_forked.mmcv as mmcv
>>> import dependencies.mmcv_forked.mmcv.video
>>> import dependencies.mmcv_forked.mmcv.visualization
>>> from path_config import PATHS
>>> v = mmcv.video.VideoReader(str(PATHS.examples_vid / 'in.mp4'))
>>> len(v) # get the total frame number with `len()`
120
>>> for img in v: # v is iterable
>>> mmcv.imshow(img)
>>> v[5] # get the 6th frame
8
>>> mmcv.visualization.imshow(v[5], wait_time=1) # get the 6th frame
"""

def __init__(self, filename, cache_capacity=10):
Expand Down
4 changes: 2 additions & 2 deletions mmcv/video/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def convert_video(in_file: str,
options.append(f'-loglevel {v}')
else:
options.append(f'-{k} {v}')
cmd = f'ffmpeg -y {pre_options} -i {in_file} {" ".join(options)} ' \
f'{out_file}'
cmd = f'ffmpeg -y {pre_options} -i "{in_file}" {" ".join(options)} ' \
f'"{out_file}"'
if print_cmd:
print(cmd)
subprocess.call(cmd, shell=True)
Expand Down