Metadata-Version: 2.4
Name: codec-video-prep-legacy-exact
Version: 0.2.5.post4
Summary: Legacy-exact codec video preprocessing wheel
License: Proprietary
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy<2.0.0,>=1.23
Requires-Dist: opencv-python>=4.0
Requires-Dist: Pillow
Requires-Dist: pkgconfig>=1.5.1
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# codec-video-prep-legacy-exact

This repository is a clean legacy-exact source tree for reproducing old codec
preprocessing results. It is intentionally separate from the newer
`codec-video-prep` package.

The legacy pipeline uses the old `cv_reader.api.read_video_cb` backend. It does
not use `cv_reader_fast`, and this repository does not build or package
`cv_reader_fast`.

## Contents

```text
codec_selector/              # legacy selector pipeline
src/cv_reader/               # old cv_reader Python package and C++ extension source
tool/                        # legacy scripts used by the CLI
ffmpeg/ffmpeg_patch/         # patched FFmpeg source files
ffmpeg/install_ffmpeg.sh     # downloads FFmpeg 5.1, applies patches, builds static libs
build_scripts/               # wheel build and verification helpers
codec_video_prep_legacy_exact_cli.py
setup.py
pyproject.toml
```

Generated files are intentionally excluded from the clean tree:

```text
*.so
build/
dist/
*.egg-info/
ffmpeg/ffmpeg_install/
ffmpeg/ffmpeg_source/
__pycache__/
```

## Build patched FFmpeg

Run once per build machine/container:

```bash
cd /video_vit/yunyaoyan/code/codec-video-prep-legacy-exact
bash build_scripts/build_patched_ffmpeg.sh
```

This downloads FFmpeg 5.1, copies files from `ffmpeg/ffmpeg_patch/` into the
FFmpeg source tree, and installs static FFmpeg libraries under:

```text
ffmpeg/ffmpeg_install/
```

`setup.py` reads FFmpeg flags from:

```text
ffmpeg/ffmpeg_install/lib/pkgconfig
```

## Build wheels

Build for available local Python versions:

```bash
cd /video_vit/yunyaoyan/code/codec-video-prep-legacy-exact
bash build_scripts/build_wheels.sh
```

Choose Python versions:

```bash
PY_LIST="3.10 3.11 3.12" bash build_scripts/build_wheels.sh
```

Set version:

```bash
LEGACY_EXACT_VERSION=0.2.5.post4 bash build_scripts/build_wheels.sh
```

Set a platform tag when building inside a target platform/container:

```bash
PLAT_NAME=manylinux_2_35_x86_64 bash build_scripts/build_wheels.sh
PLAT_NAME=manylinux_2_39_aarch64 bash build_scripts/build_wheels.sh
```

For aarch64, run the same scripts inside an aarch64 container or machine after
building patched FFmpeg there.

## Verification

The wheel verifier runs automatically from `build_wheels.sh`. You can also run
it manually:

```bash
python3 build_scripts/verify_legacy_wheel.py dist/*.whl
```

It checks:

- exactly one `cv_reader/api*.so` is present;
- no `cv_reader_fast` files are present;
- no unexpected `cv_reader/*.so` files are present.

Manual inspection:

```bash
unzip -l dist/codec_video_prep_legacy_exact-*.whl | grep -E 'cv_reader.*\.so|cv_reader_fast'
```

Expected output should include `cv_reader/api...so` and should not include
`cv_reader_fast`.

## Smoke test

```bash
python3.10 -m pip install --force-reinstall dist/codec_video_prep_legacy_exact-*-cp310-*.whl
cd /tmp
python3.10 - <<'PY'
from cv_reader import api
print(api.__file__)
PY
codec-video-prep-legacy-exact --help
```

## Legacy behavior note

Do not replace `cv_reader.api` with the newer `cv_reader_fast` path if you need
old `src_patch_position.npy` reproduction. The old exact behavior depends on
`cv_reader.api.read_video_cb` and its historical frame/bitcost alignment behavior.
