Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/encode.moon
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,7 @@ encode = (region, startTime, endTime) ->

-- Clean up pass log file.
os.remove(get_pass_logfile_path(out_path))
os.remove "x264_2pass.log"
os.remove "x264_2pass.log.mbtree"
if is_temporary
os.remove(path)
28 changes: 28 additions & 0 deletions tests/testcases/test_x264_pass_log_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from .base_test_case import BaseTestCase


class TestX264PassLogCleanup(BaseTestCase):
def test_bitrate_twopass_removes_x264_stats(self):
self.openTestVideoFile(self.createVideo(size="64x64"))
# Keep the output directory distinct from mpv's working directory:
# libx264 writes its stats files into the encoder's current directory,
# which is what the bug left behind.
output_dir = self.tempdir / "out"
output_dir.mkdir()
self.encodeClip(0, 1, options={
"output_format": "avc", "target_filesize": 250,
"twopass": True, "threads": 2, "crf": 20,
"output_template": "x264-twopass",
"output_directory": str(output_dir),
})
output = output_dir / "x264-twopass.mp4"
self.assertGreater(output.stat().st_size, 0)
self.assertGreater(len(self.decodeVideo(output)), 0)
# The stats files only exist because a real second pass looked them up;
# make sure the regression test cannot pass vacuously.
self.waitUntil(lambda: "--ovcopts-add=flags=+pass2" in self.getLog(),
"second pass command")
self.assertIn("First-pass command line:", self.getLog())
for name in ("x264_2pass.log", "x264_2pass.log.mbtree"):
self.assertFalse((self.tempdir / name).exists(),
f"{name} was left behind after encoding")