Skip to content

Commit 9727540

Browse files
authored
Merge pull request #18 from LukasBommes/build_wheel2
Build wheel2
2 parents 2ccce5b + b88450a commit 9727540

12 files changed

+226
-39
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/build/
22
/dist/
3+
/wheelhouse/
34
/*.egg-info
45
/*.egg
56
.eggs

Dockerfile

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04 AS builder
1+
FROM quay.io/pypa/manylinux_2_24_x86_64 AS builder
22

33
WORKDIR /home/video_cap
44

@@ -14,11 +14,7 @@ RUN apt-get update -qq --fix-missing && \
1414
pkg-config \
1515
autoconf \
1616
automake \
17-
git-core \
18-
python3-dev \
19-
python3-pip \
20-
python3-numpy \
21-
python3-pkgconfig && \
17+
git-core && \
2218
rm -rf /var/lib/apt/lists/*
2319

2420
# Install OpenCV
@@ -36,21 +32,11 @@ RUN mkdir -p /home/video_cap && \
3632
chmod +x install_ffmpeg.sh && \
3733
./install_ffmpeg.sh
3834

39-
FROM ubuntu:22.04
40-
41-
# install Python
42-
RUN apt-get update && \
43-
apt-get upgrade -y && \
44-
apt-get install -y \
45-
pkg-config \
46-
python3-dev \
47-
python3-pip \
48-
python3-numpy \
49-
python3-pkgconfig && \
50-
rm -rf /var/lib/apt/lists/*
35+
FROM quay.io/pypa/manylinux_2_24_x86_64
5136

5237
RUN apt-get update && \
5338
apt-get -y install \
39+
pkg-config \
5440
libgtk-3-dev \
5541
libavcodec-dev \
5642
libavformat-dev \
@@ -63,7 +49,7 @@ RUN apt-get update && \
6349
libvdpau-dev \
6450
libvorbis-dev \
6551
libopus-dev \
66-
libdc1394-dev \
52+
libdc1394-22-dev \
6753
liblzma-dev && \
6854
rm -rf /var/lib/apt/lists/*
6955

@@ -91,6 +77,9 @@ COPY src /home/video_cap/src/
9177

9278
# Install Python package
9379
COPY vid.mp4 /home/video_cap
94-
RUN python3 setup.py install
80+
RUN python3.10 -m pip install --upgrade pip build twine && \
81+
python3.10 -m pip install 'pkgconfig>=1.5.1' 'numpy>=1.17.0'
82+
83+
RUN python3.10 setup.py install
9584

9685
CMD ["sh", "-c", "tail -f /dev/null"]

MANIFEST.in

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
recursive-include ffmpeg_patch *
2+
recursive-include src *
3+
recursive-include tests *
4+
include LICENSE
5+
include pyproject.toml
6+
include extract_mvs.py
7+
include setup.py
8+
include vid.mp4

README.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# Motion Vector Extractor
1+
2+
<h1 align="center">
3+
<a href="https://github.com/LukasBommes/mv-extractor" target="blank_">
4+
<img width="250" alt="mvextractor" src="logo.png" />
5+
</a>
6+
<br>
7+
Motion Vector Extractor
8+
</h1>
29

310
This tool extracts frames, motion vectors, frame types and timestamps from H.264 and MPEG-4 Part 2 encoded videos.
411

@@ -22,9 +29,10 @@ A usage example can be found in `extract_mvs.py`.
2229
### Recent Changes
2330

2431
- Added unittests in `tests/tests.py`
25-
- Updated to Ubuntu 22.04, Python 3.10, and OpenCV 4.5.5
32+
- Updated Python 3.10, and OpenCV 4.5.5
2633
- Provided a script to wrap Docker run command
2734
- Updated demo script with command line arguments for extraction and storing of motion vectors
35+
- Changed Docker image to manylinux_2_24_x86_64 to prepare for building wheels
2836

2937
### Looking for Contributors
3038

@@ -50,21 +58,21 @@ git clone https://github.com/LukasBommes/mv-extractor.git mv_extractor
5058

5159
Change into the `mv_extractor` directory and run the extraction script
5260
```
53-
sudo ./run.sh python3 extract_mvs.py
61+
sudo ./run.sh python3.10 extract_mvs.py
5462
```
5563
This pulls a prebuild Docker image and runs the mv-extractor within this image.
5664

5765
The extraction script provides several command line options, e.g., to store extracted motion vectors to disk, and to enable/disable graphical output. To see all command line options type
5866
```
59-
sudo ./run.sh python3 extract_mvs.py -h
67+
sudo ./run.sh python3.10 extract_mvs.py -h
6068
```
6169
For example, if you want to store extracted frames and motion vectors to disk, you can do so by running
6270
```
63-
sudo ./run.sh python3 extract_mvs.py --dump
71+
sudo ./run.sh python3.10 extract_mvs.py --dump
6472
```
6573
You can also open another video stream by specifying its file path or url, e.g.,
6674
```
67-
sudo ./run.sh python3 extract_mvs.py "another_video.mp4"
75+
sudo ./run.sh python3.10 extract_mvs.py "another_video.mp4"
6876
```
6977
Note, that the last command will fail because there is no file called `another_video.mp4`.
7078

@@ -75,7 +83,7 @@ Note, that the last command will fail because there is no file called `another_v
7583

7684
To test if everything is installed succesfully you can run the tests with
7785
```
78-
sudo ./run.sh python3 tests/tests.py
86+
sudo ./run.sh python3.10 tests/tests.py
7987
```
8088
Confirm that all tests pass.
8189

build.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
./run.sh python3.10 -m build && \
4+
auditwheel repair dist/mv_extractor-0.0.0-cp310-cp310-linux_x86_64.whl
5+
6+
#TODO: run for other python versions
7+
#TODO: upload to PyPI via twine
8+

install_ffmpeg.sh

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ apt-get -y install \
2828
libx265-dev \
2929
libnuma-dev \
3030
libvpx-dev \
31-
libfdk-aac-dev \
3231
libmp3lame-dev \
3332
libopus-dev
3433

install_opencv.sh

+3-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apt-get install -y \
2626
openexr \
2727
libtbb2 \
2828
libtbb-dev \
29-
libdc1394-dev \
29+
libdc1394-22-dev \
3030
libgtk2.0-dev && \
3131
rm -rf /var/lib/apt/lists/*
3232

@@ -39,10 +39,6 @@ wget -O "$INSTALL_BASE_DIR"/opencv.zip https://github.com/opencv/opencv/archive/
3939
unzip "$INSTALL_BASE_DIR"/opencv.zip
4040
mv "$INSTALL_BASE_DIR"/opencv-"$OPENCV_VERSION"/ "$INSTALL_BASE_DIR"/opencv/
4141
rm -rf "$INSTALL_BASE_DIR"/opencv.zip
42-
wget -O "$INSTALL_BASE_DIR"/opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/"$OPENCV_VERSION".zip
43-
unzip "$INSTALL_BASE_DIR"/opencv_contrib.zip
44-
mv "$INSTALL_BASE_DIR"/opencv_contrib-"$OPENCV_VERSION"/ "$INSTALL_BASE_DIR"/opencv_contrib/
45-
rm -rf "$INSTALL_BASE_DIR"/opencv_contrib.zip
4642

4743
echo "Configuring OpenCV"
4844
cd "$INSTALL_BASE_DIR"/opencv
@@ -51,8 +47,8 @@ cd build
5147
cmake -D CMAKE_BUILD_TYPE=RELEASE \
5248
-D OPENCV_GENERATE_PKGCONFIG=YES \
5349
-D CMAKE_INSTALL_PREFIX=/usr/local \
54-
-D OPENCV_ENABLE_NONFREE=ON \
55-
-D OPENCV_EXTRA_MODULES_PATH="$INSTALL_BASE_DIR"/opencv_contrib/modules ..
50+
-D OPENCV_ENABLE_NONFREE=OFF \
51+
-D BUILD_LIST=core,imgproc ..
5652
echo "Compiling OpenCV"
5753
make -j $(nproc)
5854
make install

logo.png

18 KB
Loading

logo.svg

+173
Loading

pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"pkgconfig",
5+
"numpy"
6+
]
7+
build-backend = "setuptools.build_meta"

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
mv_extractor = Extension('mv_extractor',
1010
include_dirs = [
11-
'/home/ffmpeg_sources/ffmpeg',
1211
*d['include_dirs'],
1312
np.get_include()
1413
],
@@ -33,4 +32,5 @@
3332
ext_modules = [mv_extractor],
3433
packages = ['mv_extractor'],
3534
package_dir = {'mv_extractor': 'src'},
36-
python_requires='>=3.6, <3.12')
35+
python_requires='>=3.6, <3.12',
36+
install_requires=['pkgconfig>=1.5.1', 'numpy>=1.17.0', 'opencv-python>=4.1.0.25,<4.6'])

src/mat_to_ndarray.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include <Python.h>
55
#include <numpy/ndarrayobject.h>
66
#include <opencv2/opencv.hpp>
7-
#include <opencv2/imgproc.hpp>
8-
#include <opencv2/highgui.hpp>
97
#include "opencv2/core/core.hpp"
108
#include "opencv2/core/types_c.h"
119
#include "opencv2/opencv_modules.hpp"

0 commit comments

Comments
 (0)