MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __init__

Method __init__

detrsmpl/utils/ffmpeg_utils.py:494–525  ·  view source on GitHub ↗

Get video information from video, mimiced from ffmpeg-python. https://github.com/kkroening/ffmpeg-python. Args: vid_file ([str]): video file path. Raises: FileNotFoundError: check the input path. Returns: None.

(self, input_path)

Source from the content-addressed store, hash-verified

492class vid_info_reader(object):
493
494 def __init__(self, input_path) -> None:
495 """Get video information from video, mimiced from ffmpeg-python.
496 https://github.com/kkroening/ffmpeg-python.
497
498 Args:
499 vid_file ([str]): video file path.
500
501 Raises:
502 FileNotFoundError: check the input path.
503
504 Returns:
505 None.
506 """
507 check_input_path(
508 input_path,
509 allowed_suffix=['.mp4', '.gif', '.png', '.jpg', '.jpeg'],
510 tag='input file',
511 path_type='file')
512 cmd = [
513 'ffprobe', '-show_format', '-show_streams', '-of', 'json',
514 input_path
515 ]
516 process = subprocess.Popen(
517 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
518 out, _ = process.communicate()
519 probe = json.loads(out.decode('utf-8'))
520 video_stream = next((stream for stream in probe['streams']
521 if stream['codec_type'] == 'video'), None)
522 if video_stream is None:
523 print('No video stream found', file=sys.stderr)
524 sys.exit(1)
525 self.video_stream = video_stream
526
527 def __getitem__(
528 self,

Callers

nothing calls this directly

Calls 3

check_input_pathFunction · 0.90
printFunction · 0.50
decodeMethod · 0.45

Tested by

no test coverage detected