video_file = "Neighbour_hls-1146-1.mp4" print(get_video_info(video_file)) This example extracts and prints the duration, resolution, frame rate, and codec of the specified video file. Make sure you have ffmpeg and ffmpeg-python installed in your environment.
import ffmpeg
def get_video_info(video_file): probe = ffmpeg.probe(video_file) video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None) audio_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'audio'), None) Neighbour_hls-1146-1.mp4
return video_info
video_info = { 'duration': probe['format']['duration'], 'resolution': f"{video_stream['width']}x{video_stream['height']}", 'frame_rate': video_stream.get('r_frame_rate', 'N/A'), 'codec': video_stream['codec_name'], } video_file = "Neighbour_hls-1146-1