Videoadjust¶
Auto-generated documentation for musicalgestures._videoadjust module.
- Mgt-python / Modules / Musicalgestures / Videoadjust
contrast_brightness_ffmpeg¶
def contrast_brightness_ffmpeg(
filename,
contrast=0,
brightness=0,
target_name=None,
overwrite=True,
):
Applies contrast and brightness adjustments on the source video using ffmpeg.
Arguments¶
filenamestr - Path to the video to process.contrastint/float, optional - Increase or decrease contrast. Values range from -100 to 100. Defaults to 0.brightnessint/float, optional - Increase or decrease brightness. Values range from -100 to 100. Defaults to 0.target_namestr, optional - Defaults to None (which assumes that the input filename with the suffix "_cb" should be used).overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filename to avoid overwriting. Defaults to True.
Returns¶
str- Path to the output video.
fixed_frames_ffmpeg¶
Specify a fixed target number frames to extract from the video. To extract only keyframes from the video, set the parameter keyframes to True.
Arguments¶
filenamestr - Path to the video to process.framesint), optional - Number frames to extract from the video. If set to -1, it will only extract the keyframes of the video. Defaults to 0.target_namestr, optional - Defaults to None (which assumes that the input filename with the suffix "_fixed" should be used).overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filename to avoid overwriting. Defaults to True.
Returns¶
str- Path to the output video.
mg_resample¶
def mg_resample(
self,
fps=None,
speed=None,
skip=None,
target_name=None,
overwrite=True,
) -> 'musicalgestures.MgVideo':
Resample the (already loaded) video and return a new MgVideo, leaving the original object untouched.
Three independent, combinable operations:
fps: retime to a target frame rate using FFmpeg'sfpsfilter — duration-preserving (frames are dropped/duplicated to hit the rate), e.g. 30 → 25 fps.speed: change playback speed by a factor (>1 faster/shorter, <1 slower/longer); the video is retimed withsetptsand the audio withatemposo they stay in sync.skip: integer frame decimation — discardskipframes for every one kept (this also shortens/speeds up the clip), matching the loader'sskipparameter.
When more than one is given they are applied in order: skip → speed/fps.
Arguments¶
fpsfloat, optional - Target frame rate (duration-preserving). Defaults to None.speedfloat, optional - Playback-speed factor. Defaults to None.skipint, optional - Discardskipframes for every one kept. Defaults to None.target_namestr, optional - Output name. Defaults to None (input filename + "_resampled").overwritebool, optional - Overwrite or auto-increment the filename. Defaults to True.
Returns¶
MgVideo- a new MgVideo pointing to the resampled file.
skip_frames_ffmpeg¶
Time-shrinks the video by skipping (discarding) every n frames determined by skip.
To discard half of the frames (ie. double the speed of the video) use skip=1.
Arguments¶
filenamestr - Path to the video to process.skipint, optional - Discardskipframes before keeping one. Defaults to 0.target_namestr, optional - Defaults to None (which assumes that the input filename with the suffix "_skip" should be used).overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filename to avoid overwriting. Defaults to True.
Returns¶
str- Path to the output video.