The extension is preserved on the temp path on purpose: ffmpeg infers the
container from it, so writing to out.mp4.tmp would select the wrong muxer
(or none) and fail, and it would fail after the encode rather than before.
Uses path.basename/path.extname rather than splitting on / by hand.
A hand-rolled split finds no separator in C:\out\video.mp4, so stem came
back as the whole path and the temp file was built from it — which is not a
valid filename, making every atomic write fail on Windows.
Split a path into its stem and final extension.
The extension is preserved on the temp path on purpose: ffmpeg infers the container from it, so writing to
out.mp4.tmpwould select the wrong muxer (or none) and fail, and it would fail after the encode rather than before.Uses
path.basename/path.extnamerather than splitting on/by hand. A hand-rolled split finds no separator inC:\out\video.mp4, sostemcame back as the whole path and the temp file was built from it — which is not a valid filename, making every atomic write fail on Windows.