66use FFMpeg \Filters \Video \ClipFilter ;
77use FFMpeg \Format \Audio \Mp3 ;
88use FFMpeg \Format \Video \WMV ;
9- use FFMpeg \Format \Video \X264 ;
109use Illuminate \Support \Facades \Storage ;
1110use ProtoneMedia \LaravelFFMpeg \FFMpeg \ProgressListenerDecorator ;
1211use ProtoneMedia \LaravelFFMpeg \Filesystem \Media ;
@@ -23,7 +22,7 @@ public function it_can_export_a_single_video_file()
2322 (new MediaOpener )
2423 ->open ('video.mp4 ' )
2524 ->export ()
26- ->inFormat (new X264 )
25+ ->inFormat ($ this -> x264 () )
2726 ->save ('new_video.mp4 ' );
2827
2928 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video.mp4 ' ));
@@ -49,7 +48,7 @@ public function it_can_bind_a_progress_listener_to_the_format()
4948
5049 $ percentages = [];
5150
52- $ format = new X264 ;
51+ $ format = $ this -> x264 () ;
5352 $ format ->on ('progress ' , function ($ video , $ format , $ percentage ) use (&$ percentages ) {
5453 $ percentages [] = $ percentage ;
5554 });
@@ -70,7 +69,7 @@ public function it_can_decorate_the_format_to_get_access_to_the_progress_listene
7069
7170 $ times = [];
7271
73- $ decoratedFormat = ProgressListenerDecorator::decorate (new X264 );
72+ $ decoratedFormat = ProgressListenerDecorator::decorate ($ this -> x264 () );
7473
7574 (new MediaOpener )
7675 ->open ('video.mp4 ' )
@@ -102,7 +101,7 @@ public function it_can_bind_a_dedicated_progress_listener_to_the_exporter()
102101 $ remainings [] = $ remaining ;
103102 $ rates [] = $ rate ;
104103 })
105- ->inFormat (new X264 )
104+ ->inFormat ($ this -> x264 () )
106105 ->save ('new_video.mp4 ' );
107106
108107 $ this ->assertNotEmpty ($ percentages );
@@ -118,10 +117,10 @@ public function it_can_chain_multiple_exports()
118117 (new MediaOpener )
119118 ->open ('video.mp4 ' )
120119 ->export ()
121- ->inFormat (new X264 )
120+ ->inFormat ($ this -> x264 () )
122121 ->save ('new_video1.mp4 ' )
123122 ->export ()
124- ->inFormat (new X264 )
123+ ->inFormat ($ this -> x264 () )
125124 ->save ('new_video2.mp4 ' );
126125
127126 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video1.mp4 ' ));
@@ -137,7 +136,7 @@ public function it_can_export_a_with_a_single_filter()
137136 ->open ('video.mp4 ' )
138137 ->addFilter (new ClipFilter (TimeCode::fromSeconds (1 ), TimeCode::fromSeconds (2 )))
139138 ->export ()
140- ->inFormat (new X264 )
139+ ->inFormat ($ this -> x264 () )
141140 ->save ('new_video.mp4 ' );
142141
143142 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video.mp4 ' ));
@@ -153,7 +152,7 @@ public function it_can_add_the_filter_after_calling_the_export_method()
153152 ->open ('video.mp4 ' )
154153 ->export ()
155154 ->addFilter (new ClipFilter (TimeCode::fromSeconds (1 ), TimeCode::fromSeconds (2 )))
156- ->inFormat (new X264 )
155+ ->inFormat ($ this -> x264 () )
157156 ->save ('new_video.mp4 ' );
158157
159158 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video.mp4 ' ));
@@ -169,11 +168,11 @@ public function it_doesnt_migrate_filters_from_a_previous_export()
169168 ->open ('video.mp4 ' )
170169 ->addFilter (new ClipFilter (TimeCode::fromSeconds (1 ), TimeCode::fromSeconds (2 )))
171170 ->export ()
172- ->inFormat (new X264 )
171+ ->inFormat ($ this -> x264 () )
173172 ->save ('short_video.mp4 ' )
174173
175174 ->export ()
176- ->inFormat (new X264 )
175+ ->inFormat ($ this -> x264 () )
177176 ->save ('long_video.mp4 ' );
178177
179178 $ this ->assertTrue (Storage::disk ('local ' )->has ('short_video.mp4 ' ));
@@ -196,7 +195,7 @@ public function it_can_export_two_files_into_a_two_files_with_filters_and_a_prog
196195 ->onProgress (function ($ percentage ) use (&$ percentages ) {
197196 $ percentages [] = $ percentage ;
198197 })
199- ->addFormatOutputMapping (new X264 , Media::make ('local ' , 'new_video1.mp4 ' ), ['0:v ' , '1:v ' ])
198+ ->addFormatOutputMapping ($ this -> x264 () , Media::make ('local ' , 'new_video1.mp4 ' ), ['0:v ' , '1:v ' ])
200199 ->addFormatOutputMapping (new WMV , Media::make ('memory ' , 'new_video2.wmv ' ), ['0:v ' , '1:v ' ])
201200 ->save ();
202201
@@ -215,7 +214,7 @@ public function it_can_stack_two_videos_horizontally()
215214 ->open (['video.mp4 ' , 'video2.mp4 ' ])
216215 ->export ()
217216 ->addFilter ('[0:v][1:v] ' , 'hstack ' , '[v] ' )
218- ->addFormatOutputMapping (new X264 , Media::make ('local ' , 'new_video.mp4 ' ), ['[v] ' ])
217+ ->addFormatOutputMapping ($ this -> x264 () , Media::make ('local ' , 'new_video.mp4 ' ), ['[v] ' ])
219218 ->save ();
220219
221220 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video.mp4 ' ));
@@ -230,12 +229,13 @@ public function it_can_stack_two_videos_horizontally()
230229 public function it_can_mix_audio_and_video_files ()
231230 {
232231 $ this ->fakeLocalVideoFile ();
232+ $ this ->addTestFile ('video_no_audio.mp4 ' );
233233 $ this ->addTestFile ('guitar.m4a ' );
234234
235235 FFMpeg::fromDisk ('local ' )
236236 ->open (['video.mp4 ' ,'guitar.m4a ' ])
237237 ->export ()
238- ->addFormatOutputMapping (new X264 ( ' libmp3lame ' ), Media::make ('local ' , 'new_video.mp4 ' ), ['0:v ' , '1:a ' ])
238+ ->addFormatOutputMapping ($ this -> x264 ( ), Media::make ('local ' , 'new_video.mp4 ' ), ['0:v ' , '1:a ' ])
239239 ->save ();
240240
241241 $ this ->assertTrue (Storage::disk ('local ' )->has ('new_video.mp4 ' ));
@@ -249,7 +249,7 @@ public function it_can_export_a_single_media_file_to_an_external_location()
249249 (new MediaOpener )
250250 ->open ('video.mp4 ' )
251251 ->export ()
252- ->inFormat (new X264 )
252+ ->inFormat ($ this -> x264 () )
253253 ->toDisk ('memory ' )
254254 ->save ('new_video.mp4 ' );
255255
@@ -265,7 +265,7 @@ public function it_can_create_a_timelapse_from_images()
265265 ->open ('feature_%04d.png ' )
266266 ->export ()
267267 ->asTimelapseWithFramerate (1 )
268- ->inFormat (new X264 )
268+ ->inFormat ($ this -> x264 () )
269269 ->save ('timelapse.mp4 ' );
270270
271271 $ this ->assertTrue (Storage::disk ('local ' )->has ('timelapse.mp4 ' ));
@@ -292,7 +292,7 @@ public function it_can_concatenate_two_videos_using_the_concat_method()
292292 $ media = (new MediaOpener )->fromDisk ('local ' )->open ('concat.mp4 ' );
293293
294294 $ this ->assertEquals (
295- 7 ,
295+ 9 ,
296296 $ media ->getDurationInSeconds ()
297297 );
298298
@@ -311,15 +311,15 @@ public function it_can_concatenate_two_videos_using_a_complex_filter()
311311 ->open (['video.mp4 ' , 'video2.mp4 ' ])
312312 ->export ()
313313 ->concatWithTranscoding (true , false )
314- ->inFormat (new X264 )
314+ ->inFormat ($ this -> x264 () )
315315 ->save ('concat.mp4 ' );
316316
317317 $ this ->assertTrue (Storage::disk ('local ' )->has ('concat.mp4 ' ));
318318
319319 $ media = (new MediaOpener )->fromDisk ('local ' )->open ('concat.mp4 ' );
320320
321321 $ this ->assertEquals (
322- 7 ,
322+ 9 ,
323323 $ media ->getDurationInSeconds ()
324324 );
325325
0 commit comments