Fix negative audio timestamps in progressive downloads

- Move -avoid_negative_ts to global output options
- Was only applied to video stream, now applies to both video and audio
- Fixes audio start_time being negative (-0.036) while video was at 0
- Ensures both streams start at timestamp 0 for proper seeking
This commit is contained in:
mani
2026-01-08 02:44:49 +01:00
parent ea35738e67
commit 02318463dd

View File

@@ -7503,9 +7503,18 @@ namespace MediaBrowser.Controller.MediaEncoding
var inputModifier = GetInputModifier(state, encodingOptions, null);
// Add timestamp normalization for progressive downloads
var timestampArgs = string.Empty;
if (state.TranscodingType == TranscodingJobType.Progressive && !state.BaseRequest.CopyTimestamps)
{
// For progressive downloads without copyTimestamps, ensure timestamps start at 0
// This fixes seeking issues in strict players like mpv, iina, and infuse
timestampArgs = " -avoid_negative_ts make_zero -start_at_zero";
}
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"",
"{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8}{9} -y \"{10}\"",
inputModifier,
GetInputArgument(state, encodingOptions, null),
keyFrame,
@@ -7514,6 +7523,7 @@ namespace MediaBrowser.Controller.MediaEncoding
threads,
GetProgressiveVideoAudioArguments(state, encodingOptions),
GetSubtitleEmbedArguments(state),
timestampArgs,
format,
outputPath).Trim();
}
@@ -7602,13 +7612,6 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " -start_at_zero";
}
}
else if (state.TranscodingType == TranscodingJobType.Progressive && !state.BaseRequest.CopyTimestamps)
{
// For progressive downloads without copyTimestamps, ensure timestamps start at 0
// This fixes seeking issues in strict players like mpv, iina, and infuse
args += " -avoid_negative_ts make_zero -start_at_zero";
}
var qualityParam = GetVideoQualityParam(state, videoCodec, encodingOptions, defaultPreset);
if (!string.IsNullOrEmpty(qualityParam))