startswith ( 'video/' )): raise UnsupportedFormatError ( 'Unsupported source asset type: %s ' % asset. mime_type ) if not encoder_name or not ( asset. :param asset: Audio or video asset, which will serve as the source :param from_seconds: Start time of the clip in seconds :type from_seconds: float :param to_seconds: End time of the clip in seconds :type to_seconds: float :return: New asset with trimmed essence """ encoder_name = self. duration return Asset ( essence = result, ** metadata ) def trim ( self, asset, from_seconds = 0, to_seconds = 0 ): """ Creates a trimmed audio or video asset that only contains the data between from_seconds and to_seconds. height if mime_category in ( 'audio', 'video' ): metadata = asset. split ( '/' ) if mime_category in ( 'image', 'video' ): metadata = asset. """ _decoder_and_stream_type_to_mime_type = mime_category = mime_type. The minimum version of FFmpeg required is v0.9. class FFmpegProcessor ( Processor ): """ Represents a processor that uses FFmpeg to read audio and video data. output_path, 'rb' ) as temp_out : shutil. seek ( 0 ) return self def _exit_ ( self, exc_type, exc_val, exc_tb ): if os. join ( tmpdir_path, 'output_file' ) with open ( self. Simply put, the subprocess module is equivalent to a shell-clad command. join ( tmpdir_path, 'input_file' ) self. To implement calling ffmpeg in python, you need to understand the subprocess module. _result = result def _enter_ ( self ): tmpdir_path = super (). TemporaryDirectory ): def _init_ ( self, source, result ): super (). loads ( string_result ) return json_obj def _get_decoder_and_stream_type ( probe_data ): decoder_name = probe_data stream_type = '' for stream in probe_data : if stream = 'video' : stream_type = 'video' break elif stream = 'audio' : stream_type = 'audio' return decoder_name, stream_type class _FFmpegContext ( tempfile. PIPE, check = True ) string_result = result. name ) result = subprocess_run ( command, stdout = subprocess. seek ( 0 ) command = 'ffprobe -loglevel error -print_format json -show_format -show_streams'. NamedTemporaryFile ( mode = 'wb' ) as temp_in : shutil. Import io import json import multiprocessing import os import shutil import subprocess import tempfile from bidict import bidict from re import Asset, MetadataProcessor, Processor, operator, OperatorError, UnsupportedFormatError from madam.future import CalledProcessError, subprocess_run def _probe ( file ): with tempfile.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |