Skip to main content

Simple video processing tools using Python with fmpeg

Project description

# NutMeg

A collection of simple video processing tools. Nice Python classes and functions
that wrap practical predefined ffmpeg commands.


## Example NutmegClip

```python
f = '/home/Videos/GoPro/Malibu/GOPR6248.MP4'

p = NutmegProbe()
p.probe(f)

print('\nOriginal file: {}'.format(os.path.basename(f)))
print('Original duration: {}'.format(p.results.container.duration))

time_start = 0
time_stop = 0.5*p.results.container.duration

c = NutmegClip()
c.clip(f, time_start, time_stop)

print('\nClip file: {}'.format(os.path.basename(c.results.fname_out)))

p = NutmegProbe()
p.probe(c.results.fname_out)

print('Clip duration: {}'.format(p.results.container.duration))

```

The above example yields the following output:

```text
Original file: GOPR6248.MP4
Original duration: 40.323617

Clip file: GOPR6248.clip-0.00-20.16.mp4
Clip duration: 20.182

```


## Example NutmegProbe

```python
f = '/home/Videos/GoPro/Malibu/GOPR6248.MP4'

p = NutmegProbe()
p.probe(f)

print('\nContainer:')
IPython.display.display(p.results.container)

for s in p.results.streams:
print('\nStream {}:'.format(s.index))
IPython.display.display(s)
```

Running the above sample code yields the following output:

Container:
```python
{'bit_rate': '24243114',
'duration': '40.323617',
'filename': '/home/Videos/GoPro/Malibu/GOPR6248.MP4',
'format_long_name': 'QuickTime / MOV',
'format_name': 'mov,mp4,m4a,3gp,3g2,mj2',
'nb_programs': 0,
'nb_streams': 3,
'probe_score': 100,
'size': '122196256',
'start_time': '0.000000',
'tags': {'compatible_brands': 'avc1isom',
'creation_time': '2014-07-06T15:20:02.000000Z',
'major_brand': 'avc1',
'minor_version': '0'}}
```

Stream 0:
```python
{'avg_frame_rate': '60000/1001',
'bit_rate': '23967131',
'bits_per_raw_sample': '8',
'chroma_location': 'left',
'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
'codec_name': 'h264',
'codec_tag': '0x31637661',
'codec_tag_string': 'avc1',
'codec_time_base': '1001/120000',
'codec_type': 'video',
'coded_height': 1080,
'coded_width': 1920,
'color_primaries': 'bt709',
'color_range': 'pc',
'color_space': 'bt709',
'color_transfer': 'bt709',
'display_aspect_ratio': '16:9',
'disposition': {'attached_pic': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'original': 0,
'visual_impaired': 0},
'duration': '40.323617',
'duration_ts': 2419417,
'has_b_frames': 1,
'height': 1080,
'index': 0,
'is_avc': 'true',
'level': 42,
'nal_length_size': '4',
'nb_frames': '2417',
'pix_fmt': 'yuvj420p',
'profile': 'Main',
'r_frame_rate': '60000/1001',
'refs': 1,
'sample_aspect_ratio': '1:1',
'start_pts': 0,
'start_time': '0.000000',
'tags': {'creation_time': '2014-07-06T15:20:02.000000Z',
'encoder': 'GoPro AVC encoder',
'handler_name': '\rGoPro AVC',
'language': 'eng',
'timecode': '15:19:06:51'},
'time_base': '1/60000',
'width': 1920}
```

Stream 1:
```python
{'avg_frame_rate': '0/0',
'bit_rate': '128040',
'bits_per_sample': 0,
'channel_layout': 'stereo',
'channels': 2,
'codec_long_name': 'AAC (Advanced Audio Coding)',
'codec_name': 'aac',
'codec_tag': '0x6134706d',
'codec_tag_string': 'mp4a',
'codec_time_base': '1/48000',
'codec_type': 'audio',
'disposition': {'attached_pic': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'original': 0,
'visual_impaired': 0},
'duration': '40.320000',
'duration_ts': 1935360,
'index': 1,
'nb_frames': '1890',
'profile': 'LC',
'r_frame_rate': '0/0',
'sample_fmt': 'fltp',
'sample_rate': '48000',
'start_pts': 0,
'start_time': '0.000000',
'tags': {'creation_time': '2014-07-06T15:20:02.000000Z',
'handler_name': '\rGoPro AAC',
'language': 'eng',
'timecode': '15:19:06:51'},
'time_base': '1/48000'}
```

Stream 2:
```python
{'avg_frame_rate': '60/1',
'codec_tag': '0x64636d74',
'codec_tag_string': 'tmcd',
'codec_type': 'data',
'disposition': {'attached_pic': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'original': 0,
'visual_impaired': 0},
'duration': '40.323617',
'duration_ts': 2419417,
'index': 2,
'nb_frames': '1',
'r_frame_rate': '0/0',
'start_pts': 0,
'start_time': '0.000000',
'tags': {'creation_time': '2014-07-06T15:20:02.000000Z',
'language': 'eng',
'timecode': '15:19:06:51'},
'time_base': '1/60000'}
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nutmeg-2017.7.30.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

nutmeg-2017.7.30-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file nutmeg-2017.7.30.tar.gz.

File metadata

  • Download URL: nutmeg-2017.7.30.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nutmeg-2017.7.30.tar.gz
Algorithm Hash digest
SHA256 f0615988e6f93d912a2c93afc0aaccdc4ba1433f341d7d79d482005008fac7ee
MD5 46892dc4ad95676c7eac5dba5fac71d7
BLAKE2b-256 844e64878079cffd7364d322c4b6e32926d73bd00ebd65513bfb9b85a82636b8

See more details on using hashes here.

File details

Details for the file nutmeg-2017.7.30-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for nutmeg-2017.7.30-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 abddf8665d1dea1b1a461c7461a534443ed797c8adb975430a7bfba03dd8780d
MD5 78339719f0f80a40df7219918f4b04d6
BLAKE2b-256 4e9056c62566fdbd294d69108761f8ab18cf4baabfffcc9a17d1c6b7a1bf7aae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page