diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-08-18 18:29:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-18 18:29:28 -0400 |
| commit | 136cbacc7a0769e7b9b09b1d51151cf5581526f1 (patch) | |
| tree | 25ea77a202015f3f7ca81d8fba977e0f1c8aaf68 /MediaBrowser.Api/Playback/BaseStreamingService.cs | |
| parent | db9c02fffddc15f4660f2462093e72ba257f8acb (diff) | |
| parent | 9ac5d5417bbc8141c9ce1e8af9e406c65e93119d (diff) | |
Merge pull request #2074 from softworkz/BitrateReporting
Add accurate bitrate reporting for ffmpeg jobs
Diffstat (limited to 'MediaBrowser.Api/Playback/BaseStreamingService.cs')
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index ac967e194..39fdc98f5 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1172,6 +1172,7 @@ namespace MediaBrowser.Api.Playback double? percent = null; TimeSpan? transcodingPosition = null; long? bytesTranscoded = null; + int? bitRate = null; var parts = line.Split(' '); @@ -1235,11 +1236,32 @@ namespace MediaBrowser.Api.Playback } } } + else if (part.StartsWith("bitrate=", StringComparison.OrdinalIgnoreCase)) + { + var rate = part.Split(new[] { '=' }, 2).Last(); + + int? scale = null; + if (rate.IndexOf("kbits/s", StringComparison.OrdinalIgnoreCase) != -1) + { + scale = 1024; + rate = rate.Replace("kbits/s", string.Empty, StringComparison.OrdinalIgnoreCase); + } + + if (scale.HasValue) + { + float val; + + if (float.TryParse(rate, NumberStyles.Any, UsCulture, out val)) + { + bitRate = (int)Math.Ceiling(val * scale.Value); + } + } + } } if (framerate.HasValue || percent.HasValue) { - ApiEntryPoint.Instance.ReportTranscodingProgress(transcodingJob, state, transcodingPosition, framerate, percent, bytesTranscoded); + ApiEntryPoint.Instance.ReportTranscodingProgress(transcodingJob, state, transcodingPosition, framerate, percent, bytesTranscoded, bitRate); } } |
