Skip to content

Commit

Permalink
Merge branch 'master' into owk_filename_for_text
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 authored May 30, 2020
2 parents 3ec998a + e8ce135 commit 12dbeaa
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 15 deletions.
25 changes: 15 additions & 10 deletions .github/ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
<!--
Thank you for submitting this issue!
If you are *not* reporting a bug, please delete all of the following text.
If you *are* reporting a bug, please ensure that moviepy is updated to the latest version before submitting, as some bugs may only be present on older versions.
---
name: Bug Report
about: Report a bug with MoviePy
title: ''
labels: bug
assignees: ''

---

<!--
You can format code by putting ``` (that's 3 backticks) on a line by itself at the beginning and end of each code block. For example:
```
from moviepy.editor import *
clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)
clip.write_videofile("colorclip.mp4", fps=24)
```
-->
### Expected Behavior


### Actual Behavior
#### Expected Behavior


#### Actual Behavior


### Steps to Reproduce the Problem
#### 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 -->


### Specifications
#### Specifications

- Python Version:
- Moviepy Version:
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Feature Request
about: Suggest an idea for MoviePy
title: ''
labels: feature-request
assignees: ''

---


21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Question
about: Ask a question about how to use 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.
--------------------
You can format code by putting ``` (that's 3 backticks) on a line by itself at the beginning and end of each code block. For example:
```
from moviepy.editor import *
clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)
```
-->
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Using `rotate()` with a `ColorClip` no longer crashes [#1139]
- `AudioFileClip` would not generate audio identical to the original file [#1108]
- Fixed `TypeError` when using `filename` instead of `txt` parameter in `TextClip` [#1201]
- Several issues resulting from incorrect time values due to floating point errors [#1195], for example:
- Blank frames at the end of clips [#210]
- Sometimes getting `IndexError: list index out of range` when using `concatenate_videoclips` [#646]
- Applying `resize` with a non-constant `newsize` to a clip with a mask would remove the mask [#1200]


## [v1.0.3](https://github.com/zulko/moviepy/tree/v1.0.3) (2020-05-07)
Expand Down
6 changes: 5 additions & 1 deletion moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,11 @@ def iter_frames(self, fps=None, with_times=False, logger=None, dtype=None):
for frame in myclip.iter_frames()])
"""
logger = proglog.default_bar_logger(logger)
for t in logger.iter_bar(t=np.arange(0, self.duration, 1.0 / fps)):
for frame_index in logger.iter_bar(t=np.arange(0, int(self.duration * fps))):
# int is used to ensure that floating point errors are rounded
# down to the nearest integer
t = frame_index / fps

frame = self.get_frame(t)
if (dtype is not None) and (frame.dtype != dtype):
frame = frame.astype(dtype)
Expand Down
1 change: 1 addition & 0 deletions moviepy/video/compositing/concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def concatenate_videoclips(
h = max(r[1] for r in sizes)

tt = np.maximum(0, tt + padding * np.arange(len(tt)))
tt[-1] -= padding # Last element is the duration of the whole

if method == "chain":

Expand Down
12 changes: 8 additions & 4 deletions moviepy/video/fx/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def trans_newsize(ns):
return ns

if hasattr(newsize, "__call__"):
# The resizing is a function of time

def newsize2(t):
return trans_newsize(newsize(t))
Expand All @@ -114,12 +115,15 @@ def fun(gf, t):
def fun(gf, t):
return resizer(gf(t).astype("uint8"), newsize2(t))

return clip.fl(
newclip = clip.fl(
fun, keep_duration=True, apply_to=(["mask"] if apply_to_mask else [])
)
if apply_to_mask and clip.mask is not None:
newclip.mask = resize(clip.mask, newsize, apply_to_mask=False)

else:
return newclip

else:
newsize = trans_newsize(newsize)

elif height is not None:
Expand All @@ -132,7 +136,6 @@ def fun(t):
return resize(clip, fun)

else:

newsize = [w * height / h, height]

elif width is not None:
Expand All @@ -144,7 +147,8 @@ def fun(t):

return resize(clip, fun)

newsize = [width, h * width / w]
else:
newsize = [width, h * width / w]

# From here, the resizing is constant (not a function of time), size=newsize

Expand Down
23 changes: 23 additions & 0 deletions tests/test_compositing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,26 @@ def test_clips_array_duration():
video = clips_array([[red, green, blue]]).set_duration(5)
video.write_videofile(join(TMP_DIR, "test_clips_array.mp4"))
close_all_clips(locals())


def test_concatenate_self():
clip = BitmapClip([["AAA", "BBB"], ["CCC", "DDD"]]).set_fps(1)
target = BitmapClip([["AAA", "BBB"], ["CCC", "DDD"]]).set_fps(1)

concatenated = concatenate_videoclips([clip])

concatenated.write_videofile(join(TMP_DIR, "test_concatenate_self.mp4"))
assert concatenated == target


def test_concatenate_floating_point():
"""
>>> print("{0:.20f}".format(1.12))
1.12000000000000010658
This test uses duration=1.12 to check that it still works when the clip duration is
represented as being bigger than it actually is. Fixed in #1195.
"""
clip = ColorClip([100, 50], color=[255, 128, 64], duration=1.12).set_fps(25.0)
concat = concatenate_videoclips([clip])
concat.write_videofile("concat.mp4", preset="ultrafast")

0 comments on commit 12dbeaa

Please sign in to comment.