@@ -29,12 +29,19 @@ def copy_media_and_reencode(
2929 dest : str ,
3030 ffmpeg_args : list [str ],
3131 test_files : dict [str , pathlib .Path ],
32+ * ,
33+ use_temp_dir_for_temp_file : bool = False ,
3234 ** kwargs : Any ,
3335):
3436 src_path = temp_dir .joinpath (src )
3537 dest_path = temp_dir .joinpath (dest )
3638 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 )
3845
3946
4047def test_config_defaults ():
@@ -392,6 +399,23 @@ def test_reencode_media(
392399 assert expected ["codecs" ] == converted_details ["codecs" ]
393400
394401
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+
395419@pytest .mark .slow
396420@pytest .mark .parametrize (
397421 "src,dest,ffmpeg_args,delete_src" ,
0 commit comments