@@ -46,16 +46,16 @@ void resizeRectangularImage() throws Exception {
4646 assertImageConsistency (result , 512 , 341 );
4747 }
4848
49- private static void assertImageConsistency (File result , int expectedWidth , int expectedHeight ) throws Exception {
50- var videoInfo = MediaHelper .retrieveMultimediaInfo (result ).video ();
51- assertNotNull (videoInfo );
52- var actualExtension = getExtension (result );
49+ private static void assertImageConsistency (File image , int expectedWidth , int expectedHeight ) throws Exception {
50+ var imageInfo = MediaHelper .retrieveMultimediaInfo (image ).video ();
51+ assertNotNull (imageInfo );
52+ var actualExtension = getExtension (image );
5353
5454 assertAll ("Image validation failed" ,
5555 () -> assertThat ("image's extension must be webp" , actualExtension , is (equalTo (".webp" ))),
56- () -> assertThat ("image's width is not correct" , videoInfo .width (), is (equalTo (expectedWidth ))),
57- () -> assertThat ("image's height is not correct" , videoInfo .height (), is (equalTo (expectedHeight ))),
58- () -> assertThat ("image size should not exceed 512 KB" , Files .size (result .toPath ()), is (lessThanOrEqualTo (MAX_IMAGE_FILE_SIZE )))
56+ () -> assertThat ("image's width is not correct" , imageInfo .width (), is (equalTo (expectedWidth ))),
57+ () -> assertThat ("image's height is not correct" , imageInfo .height (), is (equalTo (expectedHeight ))),
58+ () -> assertThat ("image size should not exceed 512 KB" , Files .size (image .toPath ()), is (lessThanOrEqualTo (MAX_IMAGE_FILE_SIZE )))
5959 );
6060 }
6161
@@ -149,28 +149,29 @@ void convertLongMovVideo() throws Exception {
149149 var movVideo = loadResource ("long.mov" );
150150 var result = MediaHelper .convert (movVideo );
151151
152- assertVideoConsistency (result , 512 , 288 , 29.97003F , 3_003L );
152+ assertVideoConsistency (result , 512 , 288 , 29.97003F , 2.969F );
153153 }
154154
155- private static void assertVideoConsistency (File result , int expectedWidth , int expectedHeight , float expectedFrameRate , long expectedDuration ) throws Exception {
156- var mediaInfo = MediaHelper .retrieveMultimediaInfo (result );
155+ private static void assertVideoConsistency (File video , int expectedWidth , int expectedHeight , float expectedFrameRate , float expectedDuration ) throws Exception {
156+ var mediaInfo = MediaHelper .retrieveMultimediaInfo (video );
157157 var videoInfo = mediaInfo .video ();
158158 assertNotNull (videoInfo );
159159 var formatInfo = mediaInfo .format ();
160160 assertNotNull (formatInfo );
161+ assertNotNull (formatInfo .duration ());
161162
162- var actualExtension = getExtension (result );
163+ var actualExtension = getExtension (video );
163164
164165 assertAll ("Video validation failed" ,
165166 () -> assertThat ("video's extension must be webm" , actualExtension , is (equalTo (".webm" ))),
166167 () -> assertThat ("video's width is not correct" , videoInfo .width (), is (equalTo (expectedWidth ))),
167168 () -> assertThat ("video's height is not correct" , videoInfo .height (), is (equalTo (expectedHeight ))),
168- () -> assertThat ("video's frame rate is not correct" , videoInfo .frameRateAsFloat (), is (equalTo (expectedFrameRate ))),
169+ () -> assertThat ("video's frame rate is not correct" , videoInfo .frameRate (), is (equalTo (expectedFrameRate ))),
169170 () -> assertThat ("video must be encoded with the VP9 codec" , videoInfo .codec (), is (equalTo (VP9_CODEC ))),
170- () -> assertThat ("video's duration is not correct" , formatInfo .durationAsMillis ( ), is (equalTo (expectedDuration ))),
171+ () -> assertThat ("video's duration is not correct" , Float . parseFloat ( formatInfo .duration () ), is (equalTo (expectedDuration ))),
171172 () -> assertThat ("video's format must be matroska" , formatInfo .format (), startsWith (MATROSKA_FORMAT )),
172173 () -> assertThat ("video must have no audio stream" , mediaInfo .audio (), is (nullValue ())),
173- () -> assertThat ("video size should not exceed 256 KB" , Files .size (result .toPath ()), is (lessThanOrEqualTo (MAX_VIDEO_FILE_SIZE )))
174+ () -> assertThat ("video size should not exceed 256 KB" , Files .size (video .toPath ()), is (lessThanOrEqualTo (MAX_VIDEO_FILE_SIZE )))
174175 );
175176 }
176177
@@ -180,7 +181,7 @@ void convertMp4WithAudio() throws Exception {
180181 var mp4Video = loadResource ("video_with_audio.mp4" );
181182 var result = MediaHelper .convert (mp4Video );
182183
183- assertVideoConsistency (result , 512 , 288 , 29.97003F , 3_003L );
184+ assertVideoConsistency (result , 512 , 288 , 29.97003F , 2.969F );
184185 }
185186
186187 @ Test
@@ -189,7 +190,7 @@ void convertM4vWithAudio() throws Exception {
189190 var m4vVideo = loadResource ("video_with_audio.m4v" );
190191 var result = MediaHelper .convert (m4vVideo );
191192
192- assertVideoConsistency (result , 512 , 214 , 23.976025F , 3_003L );
193+ assertVideoConsistency (result , 512 , 214 , 23.976025F , 2.962F );
193194 }
194195
195196 @ Test
@@ -198,7 +199,7 @@ void convertShortAndLowFpsVideo() throws Exception {
198199 var webmVideo = loadResource ("short_low_fps.webm" );
199200 var result = MediaHelper .convert (webmVideo );
200201
201- assertVideoConsistency (result , 512 , 288 , 10F , 1_000L );
202+ assertVideoConsistency (result , 512 , 288 , 10F , 1.0F );
202203 }
203204
204205 @ Test
@@ -207,7 +208,7 @@ void resizeSmallWebmVideo() throws Exception {
207208 var webmVideo = loadResource ("small_video_sticker.webm" );
208209 var result = MediaHelper .convert (webmVideo );
209210
210- assertVideoConsistency (result , 512 , 212 , 30F , 2_600L );
211+ assertVideoConsistency (result , 512 , 212 , 30F , 2.6F );
211212 }
212213
213214 @ Test
@@ -216,7 +217,7 @@ void convertVerticalWebmVideo() throws Exception {
216217 var webmVideo = loadResource ("vertical_video_sticker.webm" );
217218 var result = MediaHelper .convert (webmVideo );
218219
219- assertVideoConsistency (result , 288 , 512 , 30F , 2_000L );
220+ assertVideoConsistency (result , 288 , 512 , 30F , 2.0F );
220221 }
221222
222223 @ Test
@@ -225,7 +226,7 @@ void convertGifVideo() throws Exception {
225226 var gifVideo = loadResource ("valid.gif" );
226227 var result = MediaHelper .convert (gifVideo );
227228
228- assertVideoConsistency (result , 512 , 274 , 10F , 1_000L );
229+ assertVideoConsistency (result , 512 , 274 , 10F , 1.0F );
229230 }
230231
231232 @ Test
@@ -234,7 +235,7 @@ void convertAviVideo() throws Exception {
234235 var aviVideo = loadResource ("valid.avi" );
235236 var result = MediaHelper .convert (aviVideo );
236237
237- assertVideoConsistency (result , 512 , 512 , 30F , 3_000L );
238+ assertVideoConsistency (result , 512 , 512 , 30F , 2.966F );
238239 }
239240
240241 @ Test
0 commit comments