aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/VideoHlsController.cs
diff options
context:
space:
mode:
authornyanmisaka <nst799610810@gmail.com>2020-11-14 14:22:15 +0800
committernyanmisaka <nst799610810@gmail.com>2020-11-14 14:23:00 +0800
commit32bb73acbb071a8329c485738176711dac4e1bcb (patch)
treeb3bbc688e2cddc1bacf549bf904dca190bfe4578 /Jellyfin.Api/Controllers/VideoHlsController.cs
parent536b0548730466d7b1e51178146c004af8801ae8 (diff)
add aac_adtstoasc bitstream filter for mpegts to mp4 conversion
Diffstat (limited to 'Jellyfin.Api/Controllers/VideoHlsController.cs')
-rw-r--r--Jellyfin.Api/Controllers/VideoHlsController.cs28
1 files changed, 26 insertions, 2 deletions
diff --git a/Jellyfin.Api/Controllers/VideoHlsController.cs b/Jellyfin.Api/Controllers/VideoHlsController.cs
index 7b50b47b1..21c042f4b 100644
--- a/Jellyfin.Api/Controllers/VideoHlsController.cs
+++ b/Jellyfin.Api/Controllers/VideoHlsController.cs
@@ -439,7 +439,19 @@ namespace Jellyfin.Api.Controllers
{
if (EncodingHelper.IsCopyCodec(audioCodec))
{
- return "-acodec copy -strict -2";
+ var segmentFormat = HlsHelpers.GetSegmentFileExtension(state.Request.SegmentContainer).TrimStart('.');
+ var bitStreamArgs = string.Empty;
+
+ // Apply aac_adtstoasc bitstream filter when media source is in mpegts.
+ if (string.Equals(segmentFormat, "mp4", StringComparison.OrdinalIgnoreCase)
+ && (string.Equals(state.MediaSource.Container, "mpegts", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.MediaSource.Container, "hls", StringComparison.OrdinalIgnoreCase)))
+ {
+ bitStreamArgs = _encodingHelper.GetBitStreamArgs(state.AudioStream);
+ bitStreamArgs = !string.IsNullOrEmpty(bitStreamArgs) ? " " + bitStreamArgs : string.Empty;
+ }
+
+ return "-acodec copy -strict -2" + bitStreamArgs;
}
var audioTranscodeParams = new List<string>();
@@ -467,7 +479,19 @@ namespace Jellyfin.Api.Controllers
if (EncodingHelper.IsCopyCodec(audioCodec))
{
- return "-codec:a:0 copy -strict -2";
+ var segmentFormat = HlsHelpers.GetSegmentFileExtension(state.Request.SegmentContainer).TrimStart('.');
+ var bitStreamArgs = string.Empty;
+
+ // Apply aac_adtstoasc bitstream filter when media source is in mpegts.
+ if (string.Equals(segmentFormat, "mp4", StringComparison.OrdinalIgnoreCase)
+ && (string.Equals(state.MediaSource.Container, "mpegts", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.MediaSource.Container, "hls", StringComparison.OrdinalIgnoreCase)))
+ {
+ bitStreamArgs = _encodingHelper.GetBitStreamArgs(state.AudioStream);
+ bitStreamArgs = !string.IsNullOrEmpty(bitStreamArgs) ? " " + bitStreamArgs : string.Empty;
+ }
+
+ return "-acodec copy -strict -2" + bitStreamArgs;
}
var args = "-codec:a:0 " + audioCodec;