Skip to content

Output: pick the codec from the extension; add --keep-audio - #55

Merged
joeljose merged 1 commit into
mainfrom
feat/output-formats
Sep 29, 2026
Merged

joeljose merged 1 commit into
mainfrom
feat/output-formats

Conversation

@joeljose

Copy link
Copy Markdown
Owner

Closes #43.

Changes

  • The extension picks the codec:
    • .mkv writes FFV1, lossless; the frames read back match the 8-bit output exactly (the acceptance test);
    • .avi writes MJPG (unchanged, still the default output);
    • .mp4 writes MPEG-4 Part 2 (mp4v). H.264 isn't available in OpenCV's pip builds.
    • Any other extension is an error before processing starts. Before, any container got MJPG, with a warning.
  • --keep-audio copies the input's audio track into the output with ffmpeg -map 0:v -map 1:a? -c copy. Without ffmpeg it warns at startup and writes video only. If the container can't hold the audio codec, it warns and keeps the video-only file.
  • The README flag table recommends .mkv for analysis: JPEG compression noise is as large as the sub-1% colour changes EVM reveals.

Not done

  • PNG sequences and --save-npy: suggested, but not in the acceptance criteria. .mkv already gives lossless 8-bit output, and library users get the float result from eulerian_magnification().
  • ffmpeg in the Docker images: it would add weight for an optional flag. The images warn and keep the video.

Verification

  • ./test.sh: all pass. test_keep_audio_end_to_end is skipped there because the image has no ffmpeg.
  • Locally with ffmpeg 6.1: 104 passed, 1 skipped, including an end-to-end --keep-audio run (ffprobe shows a video and an audio stream).
  • Manual check with face.mp4 plus an AAC track: .mkv gives ffv1 + aac, .mp4 gives mpeg4 + aac, .avi gives mjpeg + aac. -o out.webm exits 1 with the list of supported extensions.

.mkv writes lossless FFV1 (frames match the 8-bit output exactly), .avi
MJPG and .mp4 MPEG-4 (mp4v); other extensions are rejected before
processing instead of writing MJPG into any container. --keep-audio
copies the input's audio track into the output with ffmpeg when it is
on the PATH, and warns otherwise. Closes #43.
@joeljose
joeljose merged commit f370cc0 into main Sep 29, 2026
2 checks passed
@joeljose
joeljose deleted the feat/output-formats branch September 29, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output: add lossless codecs, keep the audio track, and pick the codec from the file extension

1 participant