aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: f2d86e268fcd8dba0ad54be791d7ee7b04ebdf75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# trackcrop

Crop a video to a 1:1 square while keeping a chosen object centered. You pick
the object on the first frame, OpenCV's CSRT tracker follows it, the path is
smoothed to remove jitter, and the cropped frames are encoded with ffmpeg.

## Requirements

- Python 3 with numpy and `opencv-contrib-python` (a GUI build, not `-headless`)
- ffmpeg with the `h264_vaapi` encoder and a VA-API device at `/dev/dri/renderD128`

## Usage

```sh
./trackcrop.py [--no-audio] [--ak820 FPS] in.mp4 out.mp4
```

1. A window opens on the first frame. Drag a box around the object and press
   Enter or Space (`c` cancels the selection).
2. The script tracks the object and encodes the result. It is done when the
   prompt returns.

Audio is copied unchanged unless `--no-audio` is given.

### AJAZZ AK820 Pro screen

The AK820 Pro keyboard screen holds at most 255 frames, so at a given upload
frame rate it can only show `255 / FPS` seconds (8.5 s at 30 fps). With
`--ak820 FPS`, a clip longer than that asks which part to keep before the
object selection:

- `s` or Enter: the start
- `e`: the end
- a number: start at that many seconds

The object box is then drawn on the first frame of the kept part, and the
audio is trimmed to match. Upload the result with
`ak820-upload out.mp4 FPS`, using the same `FPS`.

## Notes

- The object must be visible in the first frame. Trim the start otherwise:
  `ffmpeg -ss 3 -i in.mp4 -c copy trimmed.mp4`.
- The square never leaves the frame, so the object sits off center near the
  edges.
- Works on landscape videos too, the square is cut horizontally.

## License

GPLv2 only. See [LICENSE](LICENSE).

## Development Approach

This project is developed using AI-assisted tools. Code is generated with the help of AI based on human-provided specifications, design decisions, and iterative feedback.

All contributions are reviewed, tested, and curated by the maintainer before being included in the codebase. AI is used as a productivity and exploration tool, while human oversight remains central to all decisions.

The goal is to combine the flexibility of AI-assisted development with standard open-source practices such as transparency, review, and accountability.