def test_ffprobe(self):
        ffprobe = FFProbe(self.src_video)

        all_media = ffprobe.all()

        streams = ffprobe.streams()
        self.assertIsInstance(streams, Streams)
        self.assertEqual(streams.all(), all_media['streams'])
        self.assertEqual(streams.first_stream(), all_media['streams'][0])
        self.assertEqual(streams.video()['codec_type'], 'video')
        self.assertEqual(streams.audio()['codec_type'], 'audio')
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('-i',
                        '--input',
                        required=True,
                        help='The path to the video file (required).')

    args = parser.parse_args()

    return FFProbe(args.input)
Ejemplo n.º 3
0
    def analyze_video(self, input_path) -> FFProbe:

        try:
            return FFProbe(input_path, cmd=settings.FFPROBE_BIN_PATH)
        except RuntimeError as e:
            # TODO ignore if RuntimeError('It could not determine the value of width/height')
            # TODO capture error and notify developer
            print(e)
            raise self.retry(exc=e)
        except Exception as e:
            # FileNotFoundError:
            # [Errno 2] No such file or directory: 'ffprobe'
            # TODO capture error and notify developer
            print(e)
            raise self.retry(exc=e)
Ejemplo n.º 4
0
def async_convert_video_and_extract_meta_data(id):
    """
    Converts the uploaded video into 480 mp4 files that can be streamed using the .m38u file.
    The duration of the files is then extracted from the file and resaved in the Video object
    """
    print('async convert video running')
    print(id)
    instance = Video.objects.get(id=id)
    video_path = instance.url.path

    if instance.url.storage.exists(instance.url.name):
        video = ffmpeg_streaming.input(video_path)
        hls = video.hls(Formats.h264())
        _480p = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
        hls.representations(_480p)
        hls.output()

        duration_in_seconds = int(float(FFProbe(instance.url.path).streams().video().get('duration', 60)))
        minutes = int(time.strftime('%M', time.gmtime(duration_in_seconds)))
        Video.objects.filter(pk=instance.pk).update(duration=minutes if minutes > 1 else 1)
from ffmpeg_streaming import FFProbe
import os

current_dir = os.path.dirname(os.path.abspath(__file__))

ffprobe = FFProbe(os.path.join(current_dir, 'video.mp4'))
'''
ffprobe.save_as_json(os.path.join(current_dir, 'probe.json'))

all_media = ffprobe.all()

video_format = ffprobe.format()

streams = ffprobe.streams().all()
videos = ffprobe.streams().videos()
audios = ffprobe.streams().audios()

first_stream = ffprobe.streams().first_stream()
first_video = ffprobe.streams().video()
first_audio = ffprobe.streams().audio()

print("all:")
print(all_media)

print("format:")
print(video_format)

print("streams:")
print(streams)

print("videos:")
Ejemplo n.º 6
0
def ffprobe(__input):
    return FFProbe(__input)