[bugfix] Parse video metadata more accurately; allow Range in fileserver #1342
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.
Description
This pull request implements a few fixes to issues that were preventing videos from being played properly in Tusky.
Range
norIf-Range
headers are set, GtS will use the previous behavior of just streaming the file directly from storage.Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.notes from matrix:
i figured out why video playback sometimes fails in Tusky, and it's silly
for videos that have metadata encoded at the start of the video, tusky seems to make two requests: one for the whole video file, and then once just for the audio component of the video
in terms of request headers, it looks like this:
so in the first pair of lines, you can see the request headers and then the normal log of the response
in the second pair of lines, you can see that the Tusky user agent is using the Range header to specify that it only wants the last snippet of the file, which is the audio stream
GoToSocial just returns the whole file there, because it doesn't support parsing Range headers
so, i believe we can implement serving Range requests properly using https://pkg.go.dev/net/http#ServeContent
but unfortunately that requires that we wrap the file content in a ReadSeeker, whereas now it's just a ReadCloser iirc
anyway that's also the reason videos that don't work in tusky will work in a web client, because web clients don't bother with range stuff