The Compressed Video Reader is designed to read motion vectors and residuals from H.264 encoded videos.
To install the reader, you can run the installation script located in the project root:
bash install.sh
The script will perform the following tasks:
- Download the source code of FFmpeg
- Apply patches to the source code
- Configure and compile the FFmpeg package
- Build and install the reader
To test if the reader has been successfully installed, run the following command:
# Test if the reader is installed successfully.
cv_reader -h || echo "Installation failed!"
import cv_reader
video_frames = cv_reader.read_video(video_path=path_to_video, with_residual=True)
You can use the following command to extract motion vectors and residuals from a compressed video:
$ cv_reader -h
usage: Compressed Video Reader [-h] video output
positional arguments:
video Path to h.264 video file
output Path to save extracted motion vectors and residuals
optional arguments:
-h, --help show this help message and exit
To run the extraction process on the example video, execute the following command:
cv_reader ./test_data/h264_sample.mp4 ./test_output
This reader was initially written by Congcong Li and modified by Yaojie Shen based on the original version.
The installation and configuration scripts are modified based on the code from Motion Vector Extractor.