|
1 |
| -# Generate FFMpeg easing and tweening strings in Laravel. |
| 1 | +# Tools and utilities to help generate complex strings for FFMpeg in Laravel. |
2 | 2 | [](https://packagist.org/packages/projektgopher/laravel-ffmpeg-tools)
|
3 | 3 | [](https://github.com/projektgopher/laravel-ffmpeg-tools/actions?query=workflow%3Arun-tests+branch%3Amain)
|
4 | 4 | [](https://github.com/projektgopher/laravel-ffmpeg-tools/actions?query=workflow%3A"phpstan"+branch%3Amain)
|
@@ -32,107 +32,21 @@ composer require projektgopher/laravel-ffmpeg-tools
|
32 | 32 | ```
|
33 | 33 |
|
34 | 34 | ## Usage
|
| 35 | + - [Easing](docs/Easing.md) |
| 36 | + - [Expressions](docs/Expressions.md) |
| 37 | + - [Filters](docs/Filters.md) |
| 38 | + - [Filter Graphs](docs/FilterGraphs.md) |
| 39 | + - [Timelines and Keyframes](docs/Timelines.md) |
| 40 | + - [Tweening](docs/Tweening.md) |
| 41 | + |
35 | 42 | ### Using outside of a Laravel application
|
36 | 43 | For now this package can only be used within a Laravel app, but there are plans to extract the core functionality into a separate package that can be used without being bound to the framework.
|
37 | 44 |
|
38 |
| -### Simple tween with delay and duration |
39 |
| -```php |
40 |
| -use ProjektGopher\FFMpegTools\Tween; |
41 |
| -use ProjektGopher\FFMpegTools\Timing; |
42 |
| -use ProjektGopher\FFMpegTools\Ease; |
43 |
| - |
44 |
| -$x = (new Tween()) |
45 |
| - ->from("50") |
46 |
| - ->to("100") |
47 |
| - ->delay(Timing::seconds(1)) |
48 |
| - ->duration(Timing::milliseconds(300)) |
49 |
| - ->ease(Ease::OutSine); |
50 |
| -``` |
51 |
| - |
52 |
| -### Animation sequences using keyframes |
53 |
| -```php |
54 |
| -use ProjektGopher\FFMpegTools\Keyframe; |
55 |
| -use ProjektGopher\FFMpegTools\Timeline; |
56 |
| -use ProjektGopher\FFMpegTools\Timing; |
57 |
| -use ProjektGopher\FFMpegTools\Ease; |
58 |
| - |
59 |
| -$x = new Timeline() |
60 |
| -$x->keyframe((new Keyframe) |
61 |
| - ->value('-text_w') // outside left of frame |
62 |
| - ->hold(Timing::seconds(1)) |
63 |
| -); |
64 |
| -$x->keyframe((new Keyframe) |
65 |
| - ->value('(main_w/2)-(text_w/2)') // center |
66 |
| - ->ease(Ease::OutElastic) |
67 |
| - ->duration(Timing::seconds(1)) |
68 |
| - ->hold(Timing::seconds(3)) |
69 |
| -); |
70 |
| -$x->keyframe((new Keyframe) |
71 |
| - ->value('main_w') // outside right of frame |
72 |
| - ->ease(Ease::InBack) |
73 |
| - ->duration(Timing::seconds(1)) |
74 |
| -); |
75 |
| -``` |
76 |
| - |
77 |
| -> **Note** `new Timeline()` returns a _fluent_ api, meaning methods can be chained as well. |
78 |
| -
|
79 |
| -## Expression Helpers |
80 |
| -When writing _long_ and **complicated** evaluated expressions, it can be easy to lose track of extra/missing perentheses, missing parameters, or unescaped commas. Especially when the whole expression _has_ to be on one line without any linebreaks or whitespace. |
81 |
| - |
82 |
| -The `Expr` class can help with this. If your expression is short enough this might be overkill, but for longer expressions this can really help with these issues. |
83 |
| - |
84 |
| -```diff |
85 |
| -+ use ProjektGopher\FFMpegTools\Utils\Expr; |
86 |
| - |
87 |
| -.... |
88 |
| - |
89 |
| -- return "if(eq(({$time})\\,0)\\,0\\,if(eq(({$time})\\,1)\\,1\\,pow(2\\,-10*({$time}))*sin((({$time})*10-0.75)*{$c4})+1))"; |
90 |
| -+ return Expr::if( |
91 |
| -+ x: Expr::eq($time, '0'), |
92 |
| -+ y: '0', |
93 |
| -+ z: Expr::if( |
94 |
| -+ x: Expr::eq($time, '1'), |
95 |
| -+ y: '1', |
96 |
| -+ z: "pow(2\\,-10*({$time}))*sin((({$time})*10-0.75)*{$c4})+1", |
97 |
| -+ ), |
98 |
| -+ ); |
99 |
| -``` |
100 |
| - |
101 |
| -## Docs |
102 |
| -Here's some more detailed information on some of this package's features: |
103 |
| -[Filter Graphs](docs/FilterGraphs.md) |
104 |
| - |
105 | 45 | ## Testing
|
106 |
| -```bash |
107 |
| -composer test |
108 |
| -``` |
109 |
| - |
110 |
| -### Visual Snapshot Testing |
111 |
| -#### Easing |
112 |
| -To generate plots of all `Ease` methods, from the project root, run |
113 |
| -```bash |
114 |
| -./scripts/generateEasings |
115 |
| -``` |
116 |
| -The 256x256 PNGs will be generated in the `tests/Snapshots/Easings` directory. |
117 |
| -These snapshots will be ignored by git, but allow visual inspection of the plots to |
118 |
| -compare against known good sources, like [Easings.net](https://easings.net). |
119 |
| - |
120 |
| -#### Timelines |
121 |
| -To generate a video using a `Timeline` with `Keyframes`, from the project root, run |
122 |
| -```bash |
123 |
| -./scripts/generateTimeline |
124 |
| -``` |
125 |
| -The 256x256 MP4 will be generated in the `tests/Snapshots/Timelines` directory. |
126 |
| -These snapshots will also be ignored by git, but again allow for a visual |
127 |
| -inspection to ensure they match the expected output. |
128 |
| - |
129 |
| -> **Note** The `scripts` directory _may_ need to have its permissions changed to allow script execution |
130 |
| -```bash |
131 |
| -chmod -R 777 ./scripts |
132 |
| -``` |
| 46 | + - [Instructions](docs/Testing.md) |
133 | 47 |
|
134 | 48 | ## Changelog
|
135 |
| -Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. |
| 49 | +Please see [RELEASES](releases) for more information on what has changed recently. |
136 | 50 |
|
137 | 51 | ## Contributing
|
138 | 52 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
|
|
0 commit comments