Fix MP4 movflags for progressive downloads
Use faststart instead of fragmented MP4 flags for non-segmented streams. This fixes seeking and duration metadata in downloaded transcoded files. When transcoding for download (no segment container), MP4 files now use the faststart movflag which moves the moov atom to the beginning of the file. This enables: - Proper duration metadata for video players - Accurate time display and seeking - Better compatibility with standard video players Fragmented MP4 flags (frag_keyframe+empty_moov+delay_moov) are still used for adaptive streaming (HLS/DASH) where segment containers are specified.
This commit is contained in:
@@ -7482,8 +7482,18 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
if (Path.GetExtension(outputPath.AsSpan()).Equals(".mp4", StringComparison.OrdinalIgnoreCase)
|
||||
&& state.BaseRequest.Context == EncodingContext.Streaming)
|
||||
{
|
||||
// Comparison: https://github.com/jansmolders86/mediacenterjs/blob/master/lib/transcoding/desktop.js
|
||||
format = " -f mp4 -movflags frag_keyframe+empty_moov+delay_moov";
|
||||
// Use fragmented MP4 for adaptive streaming (HLS/DASH with segments)
|
||||
// Use faststart for progressive downloads (better seeking and metadata)
|
||||
if (!string.IsNullOrEmpty(state.Request.SegmentContainer))
|
||||
{
|
||||
// Fragmented MP4 for HLS/DASH
|
||||
format = " -f mp4 -movflags frag_keyframe+empty_moov+delay_moov";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Progressive download - use faststart for proper seeking and duration
|
||||
format = " -f mp4 -movflags faststart";
|
||||
}
|
||||
}
|
||||
|
||||
var threads = GetNumberOfThreads(state, encodingOptions, videoCodec);
|
||||
|
||||
Reference in New Issue
Block a user