Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ffmpeg install on macos #329

Merged
merged 26 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ jobs:

- uses: actions/checkout@v4

- name: Setup FFmpeg
uses: Iamshankhadeep/setup-ffmpeg@v1.1
- if: matrix.os == 'ubuntu-latest'
name: Setup FFmpeg
uses: Iamshankhadeep/setup-ffmpeg@v1.1 # does not support arm64
with:
# Not strictly necessary, but it may prevent rate limit
# errors especially on GitHub-hosted macos machines.
token: ${{ secrets.GITHUB_TOKEN }}
version: "4.4"

- if: matrix.os == 'macos-latest'
name: Setup FFmpeg
run: |
brew install ffmpeg@4
jayqi marked this conversation as resolved.
Show resolved Hide resolved
echo "/opt/homebrew/opt/ffmpeg@4/bin" >> $GITHUB_PATH

- name: Configure Windows compilers
uses: ilammy/msvc-dev-cmd@v1

Expand Down
6 changes: 4 additions & 2 deletions tests/test_load_video_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def test_megadetector_lite_yolox_dog(tmp_path):
[
"ffmpeg",
"-r",
"60",
"30",
Copy link
Collaborator Author

@ejm714 ejm714 May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like something funky was happening in the creation of the video from individual images (which is not our standard workflow, the goal was just to create a video with known frames with objects). We separately test MegadetectorLite just on the stack of 10 frames and get the right detections out.

def test_detect_video(mdlite, dog):
total_frames = 10
object_frame_indices = [0, 3, 4, 6]
video = np.zeros([total_frames] + list(dog.size[::-1]) + [3], dtype=np.uint8)
video[object_frame_indices] = np.array(dog)
mdlite = MegadetectorLiteYoloX()
detections = mdlite.detect_video(video)
# Check that we detected the correct number of frames
assert sum(len(score) > 0 for _, score in detections) == len(object_frame_indices)
for frame_index, (frame, (_, score)) in enumerate(zip(video, detections)):
if len(score) > 0:
# Frame index is in intended frame indices
assert frame_index in object_frame_indices
# No blank frames were selected
assert not (frame == np.zeros(frame.shape, dtype=np.uint8)).all()

I can't explain why but any frame rate other than 60 makes this test pass 🤷‍♀️ I use 30 here since that's typically what we see in videos coming in

"-f",
"image2",
"-s",
Expand All @@ -458,7 +458,9 @@ def test_megadetector_lite_yolox_dog(tmp_path):
"-y",
]
)
frames = load_video_frames(tmp_path / "dog.mp4", megadetector_lite_config={"confidence": 0.25})
frames = load_video_frames(
tmp_path / "dog.mp4", megadetector_lite_config=MegadetectorLiteYoloXConfig()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default is a confidence of 0.25 so this isn't changing the underlying behavior

)

# Check that we detected the correct number of frames
assert len(frames) == len(object_frame_indices)
Expand Down
Loading