[PR #660] [CLOSED] Revert "Update MediaEncoding" #8251

Closed
opened 2025-12-22 06:46:08 +01:00 by backuprepo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/660
Author: @joshuaboniface
Created: 1/21/2019
Status: Closed

Base: release-10.1.0Head: revert-613-mediaencoding-dev


📝 Commits (1)

  • a495d7f Revert "Update MediaEncoding"

📊 Changes

6 files changed (+265 additions, -302 deletions)

View changed files

📝 MediaBrowser.Api/Playback/StreamRequest.cs (+23 -0)
📝 MediaBrowser.Api/Playback/StreamState.cs (+77 -15)
📝 MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs (+81 -195)
📝 MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs (+21 -52)
📝 MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs (+12 -29)
📝 MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs (+51 -11)

📄 Description

CC @MatMaul

PR #613 seems to be causing a release-critical bug with ffmpeg logging. Specifically, with any version of ffmpeg (tested 3.2, 4.0, and 4.1), the ffmpeg logs do not update with live transcode information. From our understanding of the code, these frame updates are required by Jellyfin for the WebUI to keep track of where the transcode is, and also to assist in troubleshooting any ffmpeg problems.

For example, an ffmpeg log without #613:

    Side data:
      cpb: bitrate max/min/avg: 7360000/0/0 buffer size: 14720000 vbv_delay: -1
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 384 kb/s (default)
    Metadata:
      encoder         : Lavc58.35.100 aac
frame=   39 fps=0.0 q=28.0 size=N/A time=00:00:02.00 bitrate=N/A speed=4.01x
frame=   64 fps= 63 q=28.0 size=N/A time=00:00:02.96 bitrate=N/A speed=2.92x
frame=   94 fps= 61 q=28.0 size=N/A time=00:00:04.30 bitrate=N/A speed=2.78x

And an ffmpeg log with #613:

    Side data:
      cpb: bitrate max/min/avg: 7360000/0/0 buffer size: 14720000 vbv_delay: -1
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 384 kb/s (default)
    Metadata:
      encoder         : Lavc58.35.100 aac [end with no newline]

The admin team has tried several quick fixes, including:

  1. Swapping around these two statement to restore the pre-#613 order:
--- a/MediaBrowser.Api/Playback/StreamState.cs
+++ b/MediaBrowser.Api/Playback/StreamState.cs
@@ -109,8 +109,8 @@ namespace MediaBrowser.Api.Playback
         public override void Dispose()
         {
             DisposeTranscodingThrottler();
-            DisposeLogStream();
             DisposeLiveStream();
+            DisposeLogStream();

             TranscodingJob = null;
         }
  1. Removing the try block around new StreamReader(source):
--- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
+++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
@@ -20,8 +20,6 @@ namespace MediaBrowser.Controller.MediaEncoding

         public async void StartStreamingLog(EncodingJobInfo state, Stream source, Stream target)
         {
-            try
-            {
                 using (var reader = new StreamReader(source))
                 {
                     while (!reader.EndOfStream)
@@ -36,16 +34,6 @@ namespace MediaBrowser.Controller.MediaEncoding
                         await target.FlushAsync().ConfigureAwait(false);
                     }
                 }
-            }
-            catch (ObjectDisposedException)
-            {
-                //TODO Investigate and properly fix.
-                // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
-            }
-            catch (Exception ex)
-            {
-                _logger.LogError(ex, "Error reading ffmpeg log");
-            }
         }

         private void ParseLogLine(string line, EncodingJobInfo state)

Which results in this unhandled exception:

[2019-01-21 16:51:27.474 -05:00] [FTL] Unhandled Exception
System.NullReferenceException: Object reference not set to an instance of an object.
   at MediaBrowser.Controller.MediaEncoding.EncodingJobInfo.ReportTranscodingProgress(Nullable`1 transcodingPosition, Single framerate, Nullable`1 percentComplete, Int64 bytesTranscoded, Nullable`1 bitRate) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs:line 722
   at MediaBrowser.Controller.MediaEncoding.JobLogger.ParseLogLine(String line, EncodingJobInfo state) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/JobLogger.cs:line 128
   at MediaBrowser.Controller.MediaEncoding.JobLogger.StartStreamingLog(EncodingJobInfo state, Stream source, Stream target) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/JobLogger.cs:line 29
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

But neither have succeeded and we do not know exactly why this is happening.

We will need to revert this PR for the 10.1.0 release and revisit this in dev afterwards unless someone knows a quick fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/660 **Author:** [@joshuaboniface](https://github.com/joshuaboniface) **Created:** 1/21/2019 **Status:** ❌ Closed **Base:** `release-10.1.0` ← **Head:** `revert-613-mediaencoding-dev` --- ### 📝 Commits (1) - [`a495d7f`](https://github.com/jellyfin/jellyfin/commit/a495d7f082fa99a1e6f3533438b8770361b0caef) Revert "Update MediaEncoding" ### 📊 Changes **6 files changed** (+265 additions, -302 deletions) <details> <summary>View changed files</summary> 📝 `MediaBrowser.Api/Playback/StreamRequest.cs` (+23 -0) 📝 `MediaBrowser.Api/Playback/StreamState.cs` (+77 -15) 📝 `MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs` (+81 -195) 📝 `MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs` (+21 -52) 📝 `MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs` (+12 -29) 📝 `MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs` (+51 -11) </details> ### 📄 Description CC @MatMaul PR #613 seems to be causing a release-critical bug with `ffmpeg` logging. Specifically, with any version of `ffmpeg` (tested `3.2`, `4.0`, and `4.1`), the `ffmpeg` logs do not update with live transcode information. From our understanding of the code, these frame updates are required by Jellyfin for the WebUI to keep track of where the transcode is, and also to assist in troubleshooting any `ffmpeg` problems. For example, an `ffmpeg` log without #613: ``` Side data: cpb: bitrate max/min/avg: 7360000/0/0 buffer size: 14720000 vbv_delay: -1 Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 384 kb/s (default) Metadata: encoder : Lavc58.35.100 aac frame= 39 fps=0.0 q=28.0 size=N/A time=00:00:02.00 bitrate=N/A speed=4.01x frame= 64 fps= 63 q=28.0 size=N/A time=00:00:02.96 bitrate=N/A speed=2.92x frame= 94 fps= 61 q=28.0 size=N/A time=00:00:04.30 bitrate=N/A speed=2.78x ``` And an ffmpeg log with #613: ``` Side data: cpb: bitrate max/min/avg: 7360000/0/0 buffer size: 14720000 vbv_delay: -1 Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 384 kb/s (default) Metadata: encoder : Lavc58.35.100 aac [end with no newline] ``` The admin team has tried several quick fixes, including: 1. Swapping around these two statement to restore the pre-#613 order: ``` --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -109,8 +109,8 @@ namespace MediaBrowser.Api.Playback public override void Dispose() { DisposeTranscodingThrottler(); - DisposeLogStream(); DisposeLiveStream(); + DisposeLogStream(); TranscodingJob = null; } ``` 2. Removing the `try` block around `new StreamReader(source)`: ``` --- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs +++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs @@ -20,8 +20,6 @@ namespace MediaBrowser.Controller.MediaEncoding public async void StartStreamingLog(EncodingJobInfo state, Stream source, Stream target) { - try - { using (var reader = new StreamReader(source)) { while (!reader.EndOfStream) @@ -36,16 +34,6 @@ namespace MediaBrowser.Controller.MediaEncoding await target.FlushAsync().ConfigureAwait(false); } } - } - catch (ObjectDisposedException) - { - //TODO Investigate and properly fix. - // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux - } - catch (Exception ex) - { - _logger.LogError(ex, "Error reading ffmpeg log"); - } } private void ParseLogLine(string line, EncodingJobInfo state) ``` Which results in this unhandled exception: ``` [2019-01-21 16:51:27.474 -05:00] [FTL] Unhandled Exception System.NullReferenceException: Object reference not set to an instance of an object. at MediaBrowser.Controller.MediaEncoding.EncodingJobInfo.ReportTranscodingProgress(Nullable`1 transcodingPosition, Single framerate, Nullable`1 percentComplete, Int64 bytesTranscoded, Nullable`1 bitRate) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs:line 722 at MediaBrowser.Controller.MediaEncoding.JobLogger.ParseLogLine(String line, EncodingJobInfo state) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/JobLogger.cs:line 128 at MediaBrowser.Controller.MediaEncoding.JobLogger.StartStreamingLog(EncodingJobInfo state, Stream source, Stream target) in /jellyfin-10.1/MediaBrowser.Controller/MediaEncoding/JobLogger.cs:line 29 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ThreadPoolWorkQueue.Dispatch() ``` But neither have succeeded and we do not know exactly why this is happening. We will need to revert this PR for the 10.1.0 release and revisit this in `dev` afterwards unless someone knows a quick fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
backuprepo 2025-12-22 06:46:09 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#8251
No description provided.