We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/yubraaj11/ffmpeg-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
calculate_video_offset.py•1.06 KiB
import json
import logging
from ffmpeg_mcp.configs import setup_logging
from ffmpeg_mcp.exceptions import build_exception_message
from ffmpeg_mcp.services.get_video_metadata import get_video_metadata
setup_logging()
logger = logging.getLogger(__name__)
def calculate_video_offset(input_video_path: str, transition_duration: float):
"""
Calculate the offset duration of the video
Args:
input_video_path(str): takes the path of the input video in string format
transition_duration(float): takes the duration in second at which transition should be started
Returns:
float: offset duration of the video in Seconds(including milliseconds)
"""
metadata = get_video_metadata(input_video_path=input_video_path)
video_duration = json.loads(metadata)['format']['duration']
try:
offset_duration = max(float(video_duration) - transition_duration, 0)
return offset_duration
except Exception as e:
logger.error('Error in calculating offset duration')
return build_exception_message(error_type=Exception, message=f'Error in calculating offest duration: {str(e)}')