Skip to content

Commit

Permalink
fix temp dir name
Browse files Browse the repository at this point in the history
  • Loading branch information
yajrendrag committed Nov 19, 2024
1 parent 06f1d15 commit 25fce74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions source/detect_audio_language/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

**<span style="color:#56adda">0.0.8</span>**
- fix dir variable in os.remove
- also delete the temp video files created

**<span style="color:#56adda">0.0.7</span>**
- add code to explicitly remove temp wav files as on some systems shutil.rmtree throws an exception if non-empty directory

Expand Down
2 changes: 1 addition & 1 deletion source/detect_audio_language/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"on_worker_process": 1
},
"tags": "audio",
"version": "0.0.7"
"version": "0.0.8"
}
6 changes: 4 additions & 2 deletions source/detect_audio_language/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def tag_streams(astreams, vid_file):

# for each audio stream needing a tag, create video file with that single audio stream
for astream, _ in enumerate(astreams):
output_file = tmp_dir + '/' + os.path.splitext(os.path.basename(vid_file))[0] + '.' + str(astream) + os.path.splitext(os.path.basename(vid_file))[1]
sfx = os.path.splitext(os.path.basename(vid_file))[1]
output_file = tmp_dir + '/' + os.path.splitext(os.path.basename(vid_file))[0] + '.' + str(astream) + sfx
command = ['ffmpeg', '-hide_banner', '-loglevel', 'info', '-i', str(vid_file), '-strict', '-2', '-max_muxing_queue_size', '9999', '-map', '0:v:0', '-map', '0:a:'+str(astream), '-c', 'copy', '-y', output_file]

try:
Expand All @@ -144,8 +145,9 @@ def tag_streams(astreams, vid_file):
else:
logger.error("Language not successfully identified for audio stream '{}' of file '{}', so skipping stream".format(astream, vid_file))

for f in glob.glob(dir + "/*.wav"):
for f in glob.glob(tmp_dir + "/*.wav"):
os.remove(f)
os.remove(tmp_dir + "/*" + sfx)

shutil.rmtree(dir, ignore_errors=True)
return tag_args
Expand Down

0 comments on commit 25fce74

Please sign in to comment.