Closed eberrigan closed 1 month ago
The recent changes enhance video handling in the application by replacing the skvideo
library with imageio
, ensuring better compatibility and flexibility. Key files have been updated to reflect this new dependency, particularly in user feedback and internal logic. This transition improves encoding processes and overall robustness in managing video writing functionalities.
Files | Change Summary |
---|---|
sleap/gui/dialogs/export_clip.py , sleap/io/videowriter.py , tests/io/test_videowriter.py |
Transitioned from skvideo to imageio for video encoding; updated checks for ffmpeg availability, modified user feedback, and introduced a new VideoWriterImageio class for improved video writing capabilities. The VideoWriterSkvideo class was replaced, and method names were adapted to align with the new library. New tests ensure functionality. |
sequenceDiagram
participant User
participant ExportClip
participant VideoWriter
User->>ExportClip: Initiate export
ExportClip->>VideoWriter: Check for ffmpeg availability
VideoWriter-->>ExportClip: Return availability status
alt ffmpeg available
ExportClip->>VideoWriter: Encode video with imageio
else ffmpeg not available
ExportClip->>User: Fallback to AVI using OpenCV
end
VideoWriter->>ExportClip: Confirm encoding completion
ExportClip-->>User: Export finished
In the garden of code, a rabbit hops free,
Withimageio
's magic, as bright as can be!
No moreskvideo
clutter, just smooth, swift grace,
Encoding our dreams in a new, happy space.
πβ¨ Letβs dance in the light of our video streams!
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Attention: Patch coverage is 80.00000%
with 5 lines
in your changes missing coverage. Please review.
Project coverage is 74.47%. Comparing base (
7ed1229
) to head (8def1c8
). Report is 30 commits behind head on develop.
Files | Patch % | Lines |
---|---|---|
sleap/gui/dialogs/export_clip.py | 0.00% | 2 Missing :warning: |
sleap/io/videowriter.py | 90.90% | 2 Missing :warning: |
sleap/gui/commands.py | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
skvideo
is no longer supported and results in a syntax error with newer versions of python (>3.7). We are updating all of our dependencies--see #1841.imageio.v2
with an ffmpeg backend instead.VideoWriter
is re-written and tested to useimageio.v2
.VideoWriter.safe_builder
checks ifffmpeg
is available. It should be since now we installimageio-ffmpeg
in the environment.VideoWriterImageio
. This test should always pass sinceimageio-ffmpeg
is now in the test environment.safe_builder
method is tested. It should always useimageio
now thatimageio-ffmpeg
is in the environment.was removed from
output_params
sinceimagio-ffmpeg
already resizes : "WARNING:imageio_ffmpeg:IMAGEIO FFMPEG_WRITER WARNING: input image is not divisible by macro_block_size=16, resizing from (406, 720) to (416, 720) to ensure video compatibility with most codecs and players. To prevent resizing, make your input image divisible by the macro_block_size or set the macro_block_size to 1 (risking incompatibility)."imagio-ffmpeg
resizes automatically correctly for videos with odd number of pixels for height and width.imagio.v2
full documentation is not easy to find.The writing parameters are here for convenience from "\miniforge\pkgs\imageio-2.34.2-pyh12aca89_0\site-packages\imageio\plugins" """ Parameters for writing
fps : scalar The number of frames per second. Default 10. codec : str the video codec to use. Default 'libx264', which represents the widely available mpeg4. Except when saving .wmv files, then the defaults is 'msmpeg4' which is more commonly supported for windows quality : float | None Video output quality. Default is 5. Uses variable bit rate. Highest quality is 10, lowest is 0. Set to None to prevent variable bitrate flags to FFMPEG so you can manually specify them using output_params instead. Specifying a fixed bitrate using 'bitrate' disables this parameter. bitrate : int | None Set a constant bitrate for the video encoding. Default is None causing 'quality' parameter to be used instead. Better quality videos with smaller file sizes will result from using the 'quality' variable bitrate parameter rather than specifying a fixed bitrate with this parameter. pixelformat: str The output video pixel format. Default is 'yuv420p' which most widely supported by video players. input_params : list List additional arguments to ffmpeg for input file options (i.e. the stream that imageio provides). output_params : list List additional arguments to ffmpeg for output file options. (Can also be provided as
ffmpeg_params
for backwards compatibility) Example ffmpeg arguments to use only intra frames and set aspect ratio: ['-intra', '-aspect', '16:9'] ffmpeg_log_level: str Sets ffmpeg output log level. Default is "warning". Values can be "quiet", "panic", "fatal", "error", "warning", "info" "verbose", or "debug". Also prints the FFMPEG command being used by imageio if "info", "verbose", or "debug". macro_block_size: int Size constraint for video. Width and height, must be divisible by this number. If not divisible by this number imageio will tell ffmpeg to scale the image up to the next closest size divisible by this number. Most codecs are compatible with a macroblock size of 16 (default), some can go smaller (4, 8). To disable this automatic feature set it to None or 1, however be warned many players can't decode videos that are odd in size and some codecs will produce poor results or fail. See https://en.wikipedia.org/wiki/Macroblock. audio_path : str | None Audio path of any audio that needs to be written. Defaults to nothing, so no audio will be written. Please note, when writing shorter video than the original, ffmpeg will not truncate the audio track; it will maintain its original length and be longer than the video. audio_codec : str | None The audio codec to use. Defaults to nothing, but if an audio_path has been provided ffmpeg will attempt to set a default codec.Types of changes
Does this address any currently open issues?
[list open issues here]
Outside contributors checklist
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
Summary by CodeRabbit
New Features
imageio
for AVI file support.VideoWriterImageio
class to improve video writing functionality.Bug Fixes
ffmpeg
, clarifying encoding options.Tests
VideoWriterImageio
class, ensuring robustness in video writing processes.