@@ -29,12 +29,19 @@ def copy_media_and_reencode(
29
29
dest : str ,
30
30
ffmpeg_args : list [str ],
31
31
test_files : dict [str , pathlib .Path ],
32
+ * ,
33
+ use_temp_dir_for_temp_file : bool = False ,
32
34
** kwargs : Any ,
33
35
):
34
36
src_path = temp_dir .joinpath (src )
35
37
dest_path = temp_dir .joinpath (dest )
36
38
shutil .copy2 (test_files [src_path .suffix [1 :]], src_path )
37
- return reencode (src_path , dest_path , ffmpeg_args , ** kwargs )
39
+ if use_temp_dir_for_temp_file :
40
+ return reencode (
41
+ src_path , dest_path , ffmpeg_args , existing_tmp_path = temp_dir , ** kwargs
42
+ )
43
+ else :
44
+ return reencode (src_path , dest_path , ffmpeg_args , ** kwargs )
38
45
39
46
40
47
def test_config_defaults ():
@@ -392,6 +399,23 @@ def test_reencode_media(
392
399
assert expected ["codecs" ] == converted_details ["codecs" ]
393
400
394
401
402
+ @pytest .mark .slow
403
+ def test_reencode_media_with_tmp_dir (test_files : dict [str , pathlib .Path ]):
404
+ with tempfile .TemporaryDirectory () as t :
405
+ temp_dir = pathlib .Path (t )
406
+ copy_media_and_reencode (
407
+ temp_dir ,
408
+ "video.mp4" ,
409
+ "video.webm" ,
410
+ VideoWebmLow ().to_ffmpeg_args (),
411
+ test_files ,
412
+ use_temp_dir_for_temp_file = True ,
413
+ )
414
+ converted_details = get_media_info (temp_dir .joinpath ("video.webm" ))
415
+ assert converted_details ["duration" ] == 2
416
+ assert converted_details ["codecs" ] == ["vp9" , "vorbis" ]
417
+
418
+
395
419
@pytest .mark .slow
396
420
@pytest .mark .parametrize (
397
421
"src,dest,ffmpeg_args,delete_src" ,
0 commit comments