mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
videos: hide the transcoder's temporary output from the file refresh (#731)
ffmpeg wrote `<stem>.transcode.<container>` next to the source. A refresh that overlapped the transcode discovered that file, probed the half-written output (errors in the log), and created a FileGroup and Video for a path the final rename removed moments later. The temporary file is now `.<stem>.transcode.<container>`: every discovery path already skips hidden files, and staying in the same directory keeps the rename over the final path atomic. `transcode_tmp_path` is the single place the name is built. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
86d4bbab98
commit
5dda94492e
2 changed files with 36 additions and 2 deletions
|
|
@ -149,6 +149,15 @@ async def _acquire_transcode_lock():
|
|||
return lock
|
||||
|
||||
|
||||
def transcode_tmp_path(video_path: pathlib.Path, container: str) -> pathlib.Path:
|
||||
"""Where ffmpeg writes its output before it is renamed over the final path.
|
||||
|
||||
Hidden (dot-prefixed) in the video's own directory: a refresh skips hidden files, so a refresh that
|
||||
overlaps the transcode neither probes the half-written output nor creates a FileGroup for a file
|
||||
that the rename removes moments later; and same-directory keeps the final rename atomic."""
|
||||
return video_path.with_name(f'.{video_path.stem}.transcode.{container}')
|
||||
|
||||
|
||||
async def transcode_video_file(video_path: pathlib.Path,
|
||||
target_vcodec: Optional[str] = None,
|
||||
target_acodec: Optional[str] = None,
|
||||
|
|
@ -363,7 +372,7 @@ async def _transcode_video_file(video_path: pathlib.Path, target_vcodec: Optiona
|
|||
mux_args = ()
|
||||
|
||||
final_path = video_path.with_suffix(f'.{container}')
|
||||
tmp_path = video_path.with_suffix(f'.transcode.{container}')
|
||||
tmp_path = transcode_tmp_path(video_path, container)
|
||||
cmd = (FFMPEG_BIN, '-y',
|
||||
'-i', video_path,
|
||||
*map_args,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue