Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.54k stars 1.57k forks source link

How can determinate bitrate and datarate of a video? #1575

Closed Thunderssucks closed 3 years ago

Thunderssucks commented 3 years ago

Couldn't find any info

mondeja commented 3 years ago

Bitrate

from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos

d = ffmpeg_parse_infos("path/to/your/file.ext")
print(d["video_bitrate"])

What do you mean exactly with datarate?

Thunderssucks commented 3 years ago

Bitrate

from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos

d = ffmpeg_parse_infos("path/to/your/file.ext")
print(d["video_bitrate"])

What do you mean exactly with datarate?

image

Thunderssucks commented 3 years ago
d = ffmpeg_parse_infos("path/to/your/file.ext")
print(d["video_bitrate"])

Return: {'duration': 1147.51, 'video_found': True, 'video_size': [576, 324], 'video_fps': 24.0, 'video_nframes': 27541, 'video_duration': 1147.51, 'video_rotation': 0, 'audio_found': True, 'audio_fps': 44100}

mondeja commented 3 years ago

Could you share the file?

Thunderssucks commented 3 years ago

I'm sure this applies to any video file.

https://dropmefiles.com/GtjmN

mondeja commented 3 years ago

I'm using the output of that file with master branch and video_bitrate is parsed:

Input ```python from moviepy.video.io.ffmpeg_reader import FFmpegInfosParser infos = """Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_3154.MP4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: isommp41mp42 creation_time : 2021-05-24T12:53:09.000000Z Duration: 00:00:14.83, start: 0.000000, bitrate: 1157 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 464x848, 1094 kb/s, SAR 1:1 DAR 29:53, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default) Metadata: creation_time : 2021-05-24T12:53:09.000000Z handler_name : Core Media Video Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 56 kb/s (default) Metadata: creation_time : 2021-05-24T12:53:09.000000Z handler_name : Core Media Audio """ d = FFmpegInfosParser(infos, 'test.mp4').parse() ```
Output ```python {'audio_bitrate': 56, 'audio_found': True, 'audio_fps': 44100, 'bitrate': 1157, 'default_audio_input_number': 0, 'default_audio_stream_number': 1, 'default_video_input_number': 0, 'default_video_stream_number': 0, 'duration': 14.83, 'inputs': [{'input_number': 0, 'streams': [{'bitrate': 1094, 'default': True, 'fps': 30.0, 'input_number': 0, 'language': None, 'metadata': {'creation_time': '2021-05-24T12:53:09.000000Z', 'handler_name': 'Core Media Video'}, 'size': [464, 848], 'stream_number': 0, 'stream_type': 'video'}, {'bitrate': 56, 'default': True, 'fps': 44100, 'input_number': 0, 'language': None, 'metadata': {'creation_time': '2021-05-24T12:53:09.000000Z', 'handler_name': 'Core Media Audio'}, 'stream_number': 1, 'stream_type': 'audio'}]}], 'metadata': {'compatible_brands': 'isommp41mp42', 'creation_time': '2021-05-24T12:53:09.000000Z', 'major_brand': 'mp42', 'minor_version': '1'}, 'start': 0.0, 'video_bitrate': 1094, 'video_duration': 14.83, 'video_found': True, 'video_fps': 30.0, 'video_n_frames': 444, 'video_size': [464, 848]} ```

What version of moviepy are you using? These data has been introduced in a recent commit, you must use master because these changes are not released yet.

mondeja commented 3 years ago

The data rate is not something that FFMPEG can output and we can't afford the mantainment of adding another program like ffprobe, so prove with it to get the data rate.

Thunderssucks commented 3 years ago

I am using movie v1.0.3

yes, I've sent you another file, but with this a have the same result.

Thunderssucks commented 3 years ago

It's ok for me if ffmpeg can't handle this. But I still cannot determinate bitrate using moviepy

mondeja commented 3 years ago

Please, try with master branch: pip install -e git+https://github.com/Zulko/moviepy.git#egg=moviepy

Thunderssucks commented 3 years ago

It works, thanks