Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 50270c8

Browse files
committed
version bump -> v0.5.0
1 parent a9f7eb1 commit 50270c8

File tree

6 files changed

+149
-35
lines changed

6 files changed

+149
-35
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
55

66
## [Unreleased]
77

8+
## [0.5.0] - 2022-04-03
9+
10+
### Changed
11+
12+
- Matching the `ffmpegio` version bump
13+
814
## [0.4.1] - 2022-02-22
915

1016
### Changed
@@ -36,6 +42,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
3642
- First release.
3743
- A plugin to convert raw media I/O data of `ffmpegio` to use `numpy.ndarray` objects.
3844

39-
[Unreleased]: https://github.com/python-ffmpegio/python-ffmpegio/compare/v0.4.1...HEAD
45+
[Unreleased]: https://github.com/python-ffmpegio/python-ffmpegio/compare/v0.5.0...HEAD
46+
[v0.5.0]: https://github.com/python-ffmpegio/python-ffmpegio/compare/v0.4.1...v0.5.0
4047
[v0.3.3]: https://github.com/python-ffmpegio/python-ffmpegio/compare/v0.3.1...v0.4.1
4148
[v0.3.1]: https://github.com/python-ffmpegio/python-ffmpegio/compare/v0.3.0...v0.3.1

README.rst

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
:alt: GitHub Workflow Status
1616

1717
Python `ffmpegio` package aims to bring the full capability of `FFmpeg <https://ffmpeg.org>`__
18-
to read, write, and manipulate multimedia data to Python. FFmpeg is an open-source cross-platform
18+
to read, write, probe, and manipulate multimedia data to Python. FFmpeg is an open-source cross-platform
1919
multimedia framework, which can handle most of the multimedia formats available today.
2020

21-
Since v0.3.0, `ffmpegio` Python distribution package has been split into `ffmpegio-core` and `ffmpegio` to allow
22-
Numpy-independent installation.
21+
.. note::
22+
23+
Since v0.3.0, `ffmpegio` Python distribution package has been split into `ffmpegio-core` and `ffmpegio` to allow
24+
Numpy-independent installation.
2325

2426
Install the full `ffmpegio` package via ``pip``:
2527

@@ -46,7 +48,8 @@ Main Features
4648
* Accepts all FFmpeg options including filter graphs
4749
* Supports a user callback whenever FFmpeg updates its progress information file
4850
(see `-progress` FFmpeg option)
49-
* Advanced users can gain finer controls of FFmpeg I/O with `ffmpegio.ffmpegprocess` submodule
51+
* `ffconcat` scripter to make the use of `-f concat` demuxer easier
52+
* I/O device enumeration to eliminate the need to look up device names. (currently supports only: Windows DirectShow)
5053
* More features to follow
5154

5255
Documentation
@@ -63,6 +66,20 @@ To import `ffmpegio`
6366
6467
>>> import ffmpegio
6568
69+
- `Transcoding <ex_trancode>`__
70+
- `Read Audio Files <ex_read_audio>`__
71+
- `Read Image Files / Capture Video Frames <ex_read_image>`__
72+
- `Read Video Files <ex_read_video>`__
73+
- `Read Multiple Files or Streams <ex_read_media>`__
74+
- `Write Audio, Image, & Video Files <ex_write>`__
75+
- `Filter Audio, Image, & Video Data <ex_filter>`__
76+
- `Stream I/O <ex_stream>`__
77+
- `Device I/O Enumeration <ex_devices>`__
78+
- `Progress Callback <ex_progress>`__
79+
- `Run FFmpeg and FFprobe Directly <ex_direct>`__
80+
81+
.. _ex_trancode:
82+
6683
Transcoding
6784
^^^^^^^^^^^
6885

@@ -79,6 +96,15 @@ Transcoding
7996
>>> ffmpegio.transcode('input.avi', 'output.mkv', two_pass=True, show_log=True,
8097
>>> **{'c:v':'libx264', 'b:v':'2600k', 'c:a':'aac', 'b:a':'128k'})
8198
99+
>>> # concatenate videos using concat demuxer
100+
>>> files = ['/video/video1.mkv','/video/video2.mkv']
101+
>>> ffconcat = ffmpegio.FFConcat()
102+
>>> ffconcat.add_files(files)
103+
>>> with ffconcat: # generates temporary ffconcat file
104+
>>> ffmpegio.transcode(ffconcat, 'output.mkv', f_in='concat', codec='copy', safe_in=0)
105+
106+
.. _ex_read_audio:
107+
82108
Read Audio Files
83109
^^^^^^^^^^^^^^^^
84110

@@ -95,6 +121,8 @@ Read Audio Files
95121
>>> # filter: equalizer which attenuate 10 dB at 1 kHz with a bandwidth of 200 Hz
96122
>>> fs, x = ffmpegio.audio.read('myaudio.mp3', t=10.0, af='equalizer=f=1000:t=h:width=200:g=-10')
97123
124+
.. _ex_read_image:
125+
98126
Read Image Files / Capture Video Frames
99127
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100128

@@ -125,6 +153,8 @@ Read Image Files / Capture Video Frames
125153
>>> I = ffmpegio.image.read('myaudio.mp3', filter_complex='showspectrumpic=s=960x540', pix_fmt='rgb24')
126154
127155
156+
.. _ex_read_video:
157+
128158
Read Video Files
129159
^^^^^^^^^^^^^^^^
130160

@@ -136,7 +166,9 @@ Read Video Files
136166
137167
>>> # get running spectrogram of audio input (must specify pix_fmt if input is audio)
138168
>>> fs, F = ffmpegio.video.read('myvideo.mp4', pix_fmt='rgb24', filter_complex='showspectrum=s=1280x480')
169+
139170
171+
.. _ex_read_media:
140172

141173
Read Multiple Files or Streams
142174
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -157,6 +189,8 @@ Read Multiple Files or Streams
157189
>>> # rates: dict of frame rates: keys="v:0" and "v:1"
158190
>>> # data: dict of video frame arrays: keys="v:0" and "v:1"
159191
192+
.. _ex_write:
193+
160194
Write Audio, Image, & Video Files
161195
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162196

@@ -171,7 +205,9 @@ Write Audio, Image, & Video Files
171205
>>> # create an audio file from a numpy array
172206
>>> ffmpegio.audio.write('myaudio.mp3', rate, x)
173207
174-
Filter Audio, Image, & Video data
208+
.. _ex_filter:
209+
210+
Filter Audio, Image, & Video Data
175211
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
176212

177213
.. code-block:: python
@@ -186,6 +222,8 @@ Filter Audio, Image, & Video data
186222
>>> filter = "drawtext=fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
187223
>>> fs_out, F_out = ffmpegio.video.filter(filter, fs_in, F_in)
188224
225+
.. _ex_stream:
226+
189227
Stream I/O
190228
^^^^^^^^^^
191229

@@ -198,10 +236,28 @@ Stream I/O
198236
>>> for frames in fin:
199237
>>> fout.write(myprocess(frames))
200238
239+
.. _ex_devices:
240+
241+
Device I/O Enumeration
242+
^^^^^^^^^^^^^^^^^^^^^^
243+
244+
.. code-block:: python
245+
246+
>>> # record 5 minutes of audio from Windows microphone
247+
>>> fs, x = ffmpegio.audio.read('a:0', f_in='dshow', sample_fmt='dbl', t=300)
201248
202-
Progress callback
249+
>>> # capture Windows' webcam frame
250+
>>> with ffmpegio.open('v:0', 'rv', f_in='dshow') as webcam,
251+
>>> for frame in webcam:
252+
>>> process_frame(frame)
253+
254+
.. _ex_progress:
255+
256+
Progress Callback
203257
^^^^^^^^^^^^^^^^^
204258

259+
.. code-block:: python
260+
205261
>>> import pprint
206262
207263
>>> # progress callback
@@ -219,3 +275,34 @@ Progress callback
219275
>>> with ffmpegio.open('myvideo.mp4', 'rv', blocksize=100, progress=progress) as fin:
220276
>>> for frames in fin:
221277
>>> myprocess(frames)
278+
279+
.. _ex_direct:
280+
281+
Run FFmpeg and FFprobe Directly
282+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
283+
284+
.. code-block:: python
285+
286+
>>> from ffmpegio import ffmpeg, FFprobe, ffmpegprocess
287+
>>> from subprocess import PIPE
288+
289+
>>> # call with options as a long string
290+
>>> ffmpeg('-i input.avi -b:v 64k -bufsize 64k output.avi')
291+
292+
>>> # or call with list of options
293+
>>> ffmpeg(['-i', 'input.avi' ,'-r', '24', 'output.avi'])
294+
295+
>>> # the same for ffprobe
296+
>>> ffprobe('ffprobe -show_streams -select_streams a INPUT')
297+
298+
>>> # specify subprocess arguments to capture stdout
299+
>>> out = ffprobe('ffprobe -of json -show_frames INPUT',
300+
stdout=PIPE, universal_newlines=True).stdout
301+
302+
>>> # use ffmpegprocess to take advantage of ffmpegio's default behaviors
303+
>>> out = ffmpegprocess.run({"inputs": [("input.avi", None)],
304+
"outputs": [("out1.mp4", None),
305+
("-", {"f": "rawvideo", "vframes": 1, "pix_fmt": "gray", "an": None})
306+
}, capture_log=True)
307+
>>> print(out.stderr) # print the captured FFmpeg logs (banner text omitted)
308+
>>> b = out.stdout # width*height bytes of the first frame

sandbox/test_image_video.py

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,53 @@
11
import ffmpegio
22
from matplotlib import pyplot as plt
33

4-
vf = ffmpegio.FilterGraph(
5-
[
6-
[
7-
(
8-
"drawtext",
9-
{
10-
"fontfile": "C:\\WINDOWS\\FONTS\\BKANT.TTF",
11-
"text": "Test Text",
12-
"x": "(w-text_w)/2",
13-
"y": "(h-text_h)/2",
14-
"fontsize": 24,
15-
"fontcolor": "[email protected]",
16-
"box": 1,
17-
"boxcolor": "[email protected]",
18-
"boxborderw": 6,
19-
},
20-
)
21-
]
22-
]
23-
)
24-
25-
I = ffmpegio.image.create("smptebars", d=1, vf=vf)
26-
27-
plt.imshow(I)
28-
plt.show()
4+
# vf = ffmpegio.FilterGraph(
5+
# [
6+
# [
7+
# (
8+
# "drawtext",
9+
# {
10+
# "fontfile": "C:\\WINDOWS\\FONTS\\BKANT.TTF",
11+
# "text": "Test Text",
12+
# "x": "(w-text_w)/2",
13+
# "y": "(h-text_h)/2",
14+
# "fontsize": 24,
15+
# "fontcolor": "[email protected]",
16+
# "box": 1,
17+
# "boxcolor": "[email protected]",
18+
# "boxborderw": 6,
19+
# },
20+
# )
21+
# ]
22+
# ]
23+
# )
24+
25+
# I = ffmpegio.image.create("smptebars", d=1, vf=vf)
26+
27+
# plt.imshow(I)
28+
# plt.show()
2929

3030
# T = 10
3131
# ffmpegio.video.write(
3232
# r"sandbox\test.mp4", 1 / T, I, r=25, t=10, show_log=True, overwrite=True
3333
# )
34+
35+
i = 0
36+
37+
url = r'sandbox\test.mp4'
38+
39+
info = ffmpegio.probe.video_streams_basic(url)[0]
40+
w = info['width']
41+
h = info['height']
42+
43+
with ffmpegio.open(url, f_in='lavfi',pix_fmt='rgb24',
44+
hwaccel_in='auto',bufsize=w*h*3*2) as f:
45+
for image in f:
46+
i += 1
47+
print(image.shape,image.dtype)
48+
49+
# throw away the data in the pipe's buffer.
50+
f.read(2) # flush the buffer (of size 2)
51+
52+
if i>2:
53+
break

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ classifiers =
3030
package_dir=
3131
=src
3232
install_requires =
33-
ffmpegio-core >= 0.3.1
33+
ffmpegio-core >= 0.5.0
3434
numpy >= 1.20
3535
python_requires = >=3.7,
3636
packages=ffmpegio_plugin_numpy

src/ffmpegio_plugin_numpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
hookimpl = HookimplMarker("ffmpegio")
1010

11-
__version__ = "0.4.3"
11+
__version__ = "0.5.0"
1212

1313
__all__ = [
1414
"video_info",

0 commit comments

Comments
 (0)