Skip to content

Commit

Permalink
Merge branch 'master' into use-audio-codec-for-existing-audiofile
Browse files Browse the repository at this point in the history
  • Loading branch information
zalgo3 committed Jan 25, 2025
2 parents b994ec1 + 52329a1 commit 13c56ac
Show file tree
Hide file tree
Showing 43 changed files with 1,347 additions and 457 deletions.
15 changes: 13 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ You can format code by putting ``` (that's 3 backticks) on a line by itself at t
from moviepy import *
clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)
```
Please, include runnable working example of code that can trigger the bug so we can easily reproduce and investigate the bug.
-->


Expand All @@ -23,8 +25,17 @@ clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)
#### Actual Behavior


#### Steps to Reproduce the Problem
<!-- Please include code that demonstrates this problem so that we can reproduce it. For advice on how to do this, see https://stackoverflow.com/help/mcve -->
#### Steps and code to Reproduce the Problem
<!-- Please include code that demonstrates this problem so that we can reproduce it. For advice on how to do this, see https://stackoverflow.com/help/mcve
It's higlhy helpfull if you can provide an exact and complete code reproducing the bug, *along with all necessary medias (videos, images, sounds, etc.).*
Ideally you should provide a functional code snippet that maintainers can run to investigate the bug.
-->


#### Used medias
<!-- If you use any external media in the code triggering the bug, please include them in this issue so we can easily reproduce -->


#### Specifications
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
name: Question
about: Ask a question about how to use MoviePy
about: Ask a question about an unexpected behavior of MoviePy
title: ''
labels: question
assignees: ''

---

<!--
Hello! If you think that it is a simple problem, then consider asking instead on our Gitter channel: https://gitter.im/movie-py/. This makes it easier to have a back-and-forth discussion in real-time.
If possible, please prioritize using discussions (https://github.com/Zulko/moviepy/discussions) or online forums for asking questions on how to use MoviePy, issues should be used mainly for questions about a specific behavior that seem incoherent and could possibly be a bug.
--------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/formatting_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
python -m pip install --upgrade wheel pip
pip install .[lint]
- name: Run isort
run: isort --check-only --diff moviepy setup.py scripts docs/conf.py examples tests
run: isort --check-only --diff moviepy scripts docs/conf.py examples tests
13 changes: 10 additions & 3 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ on:
jobs:
# Uses Python Framework build because on macOS, Matplotlib requires it
macos:
runs-on: macos-12
runs-on: macos-13
# Do not ignore bash profile files. From:
# https://github.com/marketplace/actions/setup-miniconda
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/[email protected]
- uses: s-weigand/setup-[email protected]
- uses: conda-incubator/setup-miniconda@v3
with:
activate-conda: true
auto-update-conda: true
python-version: ${{ matrix.python-version }}
auto-activate-base: true

- name: Install pythonw
run: conda install python.app
Expand Down
86 changes: 40 additions & 46 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Important Announcements

### Added <!-- for new features -->
- Support for `copy.copy(clip)` and `copy.deepcopy(clip)` with same behaviour as `clip.copy()` [\#1442](https://github.com/Zulko/moviepy/pull/1442)
- `audio.fx.multiply_stereo_volume` to control volume by audio channels [\#1424](https://github.com/Zulko/moviepy/pull/1424)
- Support for retrieve clip frames number using `clip.n_frames` [\#1471](https://github.com/Zulko/moviepy/pull/1471)
- `AudioClip.max_volume(stereo=True)` now can return more than 2 channels [\#1464](https://github.com/Zulko/moviepy/pull/1464)
- `video.io.ffmpeg_reader.ffmpeg_parse_infos` returns data from all streams by FFmpeg inputs in attribute `inputs` [\#1466](https://github.com/Zulko/moviepy/pull/1466)
- `video.io.ffmpeg_reader.ffmpeg_parse_infos` returns metadata of the container in attribute `metadata` [\#1466](https://github.com/Zulko/moviepy/pull/1466)
- `center`, `translate` and `bg_color` arguments to `video.fx.rotate` [\#1474](https://github.com/Zulko/moviepy/pull/1474)
- `audio.fx.audio_delay` FX [\#1481](https://github.com/Zulko/moviepy/pull/1481)
- `start_time` and `end_time` optional arguments to `multiply_volume` FX which allow to specify a range applying the transformation [\#1572](https://github.com/Zulko/moviepy/pull/1572)
- `loop` argument support writing GIFs with ffmpeg for `write_gif` and `write_gif_with_tempfiles` [\#1605](https://github.com/Zulko/moviepy/pull/1605)
- Add support for flac codec
- Add codecs to .mov files
- Add background radius to text clips
- Support pillow 11
- Add support for Pillow default font on textclip
- Add support for ffmpeg v7

### Changed <!-- for changes in existing functionality -->
- Lots of method and parameter names have been changed. This will be explained better in the documentation soon. See https://github.com/Zulko/moviepy/pull/1170 for more information. [\#1170](https://github.com/Zulko/moviepy/pull/1170)
- Changed recommended import from `import moviepy.editor` to `import moviepy`. This change is fully backwards compatible [\#1340](https://github.com/Zulko/moviepy/pull/1340)
- Renamed `audio.fx.volumex` to `audio.fx.multiply_volume` [\#1424](https://github.com/Zulko/moviepy/pull/1424)
- Renamed `cols_widths` argument of `clips_array` function by `cols_heights` [\#1465](https://github.com/Zulko/moviepy/pull/1465)
- `video_nframes` attribute of dictionary returned from `ffmpeg_parse_infos` renamed to `video_n_frames` [\#1471](https://github.com/Zulko/moviepy/pull/1471)
- Renamed `colorx` FX by `multiply_color` [\#1475](https://github.com/Zulko/moviepy/pull/1475)
- Renamed `speedx` FX by `multiply_speed` [\#1478](https://github.com/Zulko/moviepy/pull/1478)
- `make_loopable` transition must be used as FX [\#1477](https://github.com/Zulko/moviepy/pull/1477)
- `requests` package is no longer a dependency [\#1566](https://github.com/Zulko/moviepy/pull/1566)
- `accel_decel` FX raises `ValueError` if `sooness` parameter value is lower than zero [\#1546](https://github.com/Zulko/moviepy/pull/1546)
- `Clip.subclip` raise `ValueError` if `start_time >= clip.duration` (previously printing a message to stdout only if `start_time > clip.duration`) [\#1589](https://github.com/Zulko/moviepy/pull/1589)
- Allow to pass times in `HH:MM:SS` format to `t` argument of `clip.show` method [\#1594](https://github.com/Zulko/moviepy/pull/1594)
- `TextClip` now raises `ValueError` if none of the `text` or `filename` arguments are specified [\#1842](https://github.com/Zulko/moviepy/pull/1842)
- Subclipping outside of clip boundaries now raise an exception
- Freeze effect no longer remove start and end

### Deprecated <!-- for soon-to-be removed features -->
- `moviepy.video.fx.all` and `moviepy.audio.fx.all`. Use the fx method directly from the clip instance or import the fx function from `moviepy.video.fx` and `moviepy.audio.fx`. [\#1105](https://github.com/Zulko/moviepy/pull/1105)

### Removed <!-- for now removed features -->
- `VideoFileClip.coreader` and `AudioFileClip.coreader` methods removed. Use `VideoFileClip.copy` and `AudioFileClip.copy` instead [\#1442](https://github.com/Zulko/moviepy/pull/1442)
- `audio.fx.audio_loop` removed. Use `video.fx.loop` instead for all types of clip [\#1451](https://github.com/Zulko/moviepy/pull/1451)
- `video.compositing.on_color` removed. Use `VideoClip.on_color` instead [\#1456](https://github.com/Zulko/moviepy/pull/1456)

### Fixed <!-- for any bug fixes -->
- Fixed BitmapClip with fps != 1 not returning the correct frames or crashing [\#1333](https://github.com/Zulko/moviepy/pull/1333)
- Fixed `rotate` sometimes failing with `ValueError: axes don't match array` [\#1335](https://github.com/Zulko/moviepy/pull/1335)
- Fixed positioning error generating frames in `CompositeVideoClip` [\#1420](https://github.com/Zulko/moviepy/pull/1420)
- Changed deprecated `tostring` method by `tobytes` in `video.io.gif_writers::write_gif` [\#1429](https://github.com/Zulko/moviepy/pull/1429)
- Fixed calling `audio_normalize` on a clip with no sound causing `ZeroDivisionError` [\#1401](https://github.com/Zulko/moviepy/pull/1401)
- Fixed `freeze` FX was freezing at time minus 1 second as the end [\#1461](https://github.com/Zulko/moviepy/pull/1461)
- Fixed `Clip.cutout` transformation not being applied to audio [\#1468](https://github.com/Zulko/moviepy/pull/1468)
- Fixed arguments inconsistency in `video.tools.drawing.color_gradient` [\#1467](https://github.com/Zulko/moviepy/pull/1467)
- Fixed `fps` not defined in `CompositeAudioClip` at initialization [\#1462](https://github.com/Zulko/moviepy/pull/1462)
- Fixed `clip.preview()` crashing at exit when running inside Jupyter Notebook in Windows [\#1537](https://github.com/Zulko/moviepy/pull/1537)
- Fixed rotate FX not being applied to mask images [\#1399](https://github.com/Zulko/moviepy/pull/1399)
- Fixed opacity error blitting VideoClips [\#1552](https://github.com/Zulko/moviepy/pull/1552)
- Fixed rotation metadata of input not being taken into account rendering VideoClips [\#577](https://github.com/Zulko/moviepy/pull/577)
- Fixed mono clips crashing when `audio_fadein` FX applied [\#1574](https://github.com/Zulko/moviepy/pull/1574)
- Fixed mono clips crashing when `audio_fadeout` FX applied [\#1578](https://github.com/Zulko/moviepy/pull/1578)
- Fixed scroll FX not being scrolling [\#1591](https://github.com/Zulko/moviepy/pull/1591)
- Fixed parsing FFMPEG streams with square brackets [\#1781](https://github.com/Zulko/moviepy/pull/1781)
- Fixed audio processing for streams with missing `audio_bitrate` [\#1783](https://github.com/Zulko/moviepy/pull/1783)
- Fixed parsing language from stream output with square brackets [\#1837](https://github.com/Zulko/moviepy/pull/1837)
- Fix ffmpeg reading crash when invalid metadata (see pr #2311)
- Fix GPU h264_nvenc encoding not working.
- Improve perfs of decorator by pre-computing arguments
- Fix textclip being cut or of impredictable height (see issues #2325, #2260 and #2268)
- Fix TimeMirror and TimeSymmetrize cutting last second of clip
- Fix audiopreview not working with ffplay >= 7.0.0

## [v2.1.2](https://github.com/zulko/moviepy/tree/master)

[Full Changelog](https://github.com/zulko/moviepy/compare/v2.1.2...HEAD)

### Important Announcements

Compositing and rendering of video with transparency was bugged for a long long time (probably since start of the project), if you had encountered any issue with transparency in the past we strongly suggest you to try this new release.

### Added <!-- for new features -->
- Add codec extraction during ffmpeg meta parsing if available

### Changed <!-- for changes in existing functionality -->

### Deprecated <!-- for soon-to-be removed features -->

### Removed <!-- for now removed features -->

### Fixed <!-- for any bug fixes -->
- Massive refactor and fixing of ffmpeg reader and writer for transparency support, all transparency was actually buggy, both during rendering and reading.
- Complete refactor of CompositeVideoClip compositing to properly support tranparency with CompositeVideoClip including one or more CompositeVideoClip, and transparency in general who was completly buggy (just so many issue related, for more info take a look at pr #2307)
- Fix issue #2305: Change stroke_width from float 0.5 to int 1
- Fix issue #2160 where filenames starting with `-` crashed file saving
- Fix issue #2247 with default mask erronous size of 1 by 1




## [v2.0.0.dev2](https://github.com/zulko/moviepy/tree/v2.0.0.dev2) (2020-10-05)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ To ask for help or simply discuss usage and examples, use [our Reddit channel](h

# Maintainers

## Active maintainers
- [Zulko](https://github.com/Zulko) (owner)
- [@osaajani](https://github.com/OsaAjani) led the development of v2 ([MR](https://github.com/Zulko/moviepy/pull/2024))
- [@tburrows13](https://github.com/tburrows13)
- [@keikoro](https://github.com/keikoro)

## Past maintainers and thanks
- [@mgaitan](https://github.com/mgaitan)
- [@earney](https://github.com/earney)
- [@mbeacom](https://github.com/mbeacom)
- [@overdrivr](https://github.com/overdrivr)
- [@keikoro](https://github.com/keikoro)
- [@ryanfox](https://github.com/ryanfox)
- [@mondeja](https://github.com/mondeja)

Expand Down
6 changes: 6 additions & 0 deletions docs/developer_guide/developers_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ And you can lint with:
$ python -m black .
and

.. code:: bash
$ python3 -m flake8 -v --show-source --max-line-length=92 moviepy docs/conf.py examples tests
1 change: 1 addition & 0 deletions docs/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ The Developers Guide covers most of the things people wanting to participate to

developers_install
contribution_guidelines
maintainers_publish
59 changes: 59 additions & 0 deletions docs/developer_guide/maintainers_publish.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. _maintainers_publish:

Publishing a New Version of MoviePy
===================================

This section is for maintainers responsible for publishing new versions of MoviePy. Follow these steps to ensure the process is smooth and consistent:

**Pre-requisites**
------------------
- Ensure you have proper permissions to push changes and create releases in the MoviePy repository.

Steps to Publish a New Version
------------------------------

1. **Update the `CHANGELOG.md`**

- Add a new section for the upcoming version, respecting the format used in previous entries.
- Summarize all changes, fixes, and new features.

2. **Update the version in `pyproject.toml`**

- Open the `pyproject.toml` file.
- Update the `version` field to the new version, following `Semantic Versioning <https://semver.org/>`_.

3. **Commit and Push**

- Stage your changes::

git add CHANGELOG.md pyproject.toml

- Commit your changes::

git commit -m "Release vX.Y.Z"

- Push your changes::

git push

4. **Create a New Tag**

- Create a tag for the new version (replace ``vX.Y.Z`` with the actual version number)::

git tag -a vX.Y.Z -m "Release vX.Y.Z"

- Push the tag to the remote repository::

git push origin vX.Y.Z

5. **Create a New Release**

- Go to the repository's page on GitHub (or the relevant hosting platform).
- Navigate to the "Releases" section and create a new release.
- Use the new tag (``vX.Y.Z``) and provide a description for the release.
- Copy the changelog for this version into the release description.
- Publish the release.

GitHub actions will automatically build and publish the new release on PyPi.

By following these steps, you ensure that each MoviePy release is well-documented, correctly versioned, and accessible to users.
Binary file added media/-video-with-dash-.mp4
Binary file not shown.
Binary file added media/transparent.webm
Binary file not shown.
28 changes: 27 additions & 1 deletion moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def with_start(self, t, change_end=True):
These changes are also applied to the ``audio`` and ``mask``
clips of the current clip, if they exist.
note::
The start and end attribute of a clip define when a clip will start
playing when used in a composite video clip, not the start time of
the clip itself.
i.e: with_start(10) mean the clip will still start at his first frame,
but if used in a composite video clip it will only start to show at
10 seconds.
Parameters
----------
Expand Down Expand Up @@ -248,6 +257,15 @@ def with_end(self, t):
(hour, min, sec), or as a string: '01:03:05.35'. Also sets the duration
of the mask and audio, if any, of the returned clip.
note::
The start and end attribute of a clip define when a clip will start
playing when used in a composite video clip, not the start time of
the clip itself.
i.e: with_start(10) mean the clip will still start at his first frame,
but if used in a composite video clip it will only start to show at
10 seconds.
Parameters
----------
Expand Down Expand Up @@ -422,6 +440,14 @@ def subclipped(self, start_time=0, end_time=None):
end_time = self.duration + end_time

if end_time is not None:
# Allow a slight tolerance to account for rounding errors
if (self.duration is not None) and (end_time - self.duration > 0.00000001):
raise ValueError(
"end_time (%.02f) " % end_time
+ "should be smaller or equal to the clip's "
+ "duration (%.02f)." % self.duration
)

new_clip.duration = end_time - start_time
new_clip.end = new_clip.start + new_clip.duration

Expand Down Expand Up @@ -652,7 +678,7 @@ def __getitem__(self, key):
if key.step < 0:
# time mirror
clip = clip.time_transform(
lambda t: clip.duration - t - 1,
lambda t: clip.duration - t - 1 / self.fps,
keep_duration=True,
apply_to=apply_to,
)
Expand Down
6 changes: 3 additions & 3 deletions moviepy/audio/AudioClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ def write_audiofile(
"""
if not fps:
if not self.fps:
fps = 44100
else:
if hasattr(self, "fps"):
fps = self.fps
else:
fps = 44100

if codec is None:
name, ext = os.path.splitext(os.path.basename(filename))
Expand Down
6 changes: 3 additions & 3 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from moviepy.config import FFMPEG_BINARY
from moviepy.decorators import requires_duration
from moviepy.tools import cross_platform_popen_params
from moviepy.tools import cross_platform_popen_params, ffmpeg_escape_filename


class FFMPEG_AudioWriter:
Expand Down Expand Up @@ -89,15 +89,15 @@ def __init__(
if input_video is None:
cmd.extend(["-vn"])
else:
cmd.extend(["-i", input_video, "-vcodec", "copy"])
cmd.extend(["-i", ffmpeg_escape_filename(input_video), "-vcodec", "copy"])

cmd.extend(["-acodec", codec] + ["-ar", "%d" % fps_input])
cmd.extend(["-strict", "-2"]) # needed to support codec 'aac'
if bitrate is not None:
cmd.extend(["-ab", bitrate])
if ffmpeg_params is not None:
cmd.extend(ffmpeg_params)
cmd.extend([filename])
cmd.extend([ffmpeg_escape_filename(filename)])

popen_params = cross_platform_popen_params(
{"stdout": sp.DEVNULL, "stderr": logfile, "stdin": sp.PIPE}
Expand Down
Loading

0 comments on commit 13c56ac

Please sign in to comment.