fix(server): avoid transcoding thumbnail streams #11603
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the only property of video streams used when picking one to transcode is their lengths (always trying to select the longest one). Certain video formats embed thumbnails as "video" streams but then don't report back their lengths in frames via
ffprobe
.For example, some WMVs from an ancient camera of mine have an embedded thumbnail as stream 0 and the actual video as stream 1, but
ffprobe
doesn't report annb_frames
for either so they both get treated as length 0 and the first one is selected, which causesffmpeg
to explode.This patch adds a second layer to the sort for "main video streams", where if two streams are of the same length but one was marked by
ffprobe
as having the dispositionattached_pic
(which is used for video thumbnails), the one not marked asattached_pic
is preferred. In this way,ffmpeg
is given the correct stream and successfully generates a transcoded version of my ancient WMVs on a test instance. I wouldn't be surprised if this is the problem behind #11100 as well, but there isn't enough information in that report to check.Currently the only consumer of this new
holdsThumbnail
property is the transcoding logic; there is probably some more intelligent way to use it when generating our own video thumbnails but I have not explored that here.