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
4 changes: 4 additions & 0 deletions ffmpeg4discord/twopass.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ def _generate_params(self, settings: EncodeSettings, bitrate_targets: dict) -> d

params["pass2"].update(CODEC_OVERRIDES.get(codec, {}))

# MP4 only (same rule as `_output_filename()`): move the index to the front so a linked video starts playing sooner
if "vp9" not in codec:
params["pass2"]["movflags"] = "+faststart"

# Apply bitrate targets to both passes
for pass_params in params.values():
pass_params.update(**bitrate_targets)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_twopass.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ def test_x265_stats_path_escapes_ffmpeg_separators():
assert params["x265-params"] == r"pass=1:stats=C\:/Users/O\'Brien/Temp/ff4d-abc/x265_2pass.log"


@pytest.mark.parametrize("codec", CODEC_ENCODERS)
def test_run_puts_mp4_index_at_the_front(make_twopass, passes, codec):
make_twopass().run(make_settings(codec=codec))
*first, last = passes
has_faststart = "-movflags" in last.args and last.args[last.args.index("-movflags") + 1] == "+faststart"
assert has_faststart == (codec != "vp9") # vp9 writes .webm, which has no movflags
assert all("-movflags" not in p.args for p in first)


def test_hardware_codecs_have_no_stats_file(make_twopass, passes):
make_twopass().run(make_settings(codec="h264_nvenc"))
assert "-passlogfile" not in passes[0].args
Expand Down
Loading