Rearchitected transcoding to treat codecs and encoders as separate concepts.
ActivityPub Tests / federation-test (push) Failing after 4s
ActivityPub Tests / chat-sanitization-test (push) Failing after 3s
ActivityPub Tests / follower-validation-test (push) Failing after 4s
Extract Default Translations / extract-and-commit (push) Successful in 4m21s
Automated API tests / test (push) Has been cancelled
Browser Tests / cypress-run (push) Has been cancelled
Chromatic / chromatic-deployment (push) Has been cancelled
CSS Lint and Formatting / css-lint (push) Has been cancelled
javascript-packages / Generate API Documentation (push) Has been cancelled
Lint / Go linter (push) Has been cancelled
Go Tests / test (push) Has been cancelled
Go Tests / test-bsds (map[name:freebsd version:12.2]) (push) Has been cancelled
Go Tests / test-bsds (map[name:openbsd version:6.8]) (push) Has been cancelled
HLS tests / tests (push) Has been cancelled

This commit is contained in:
2026-04-04 14:11:49 -04:00
parent e699bef636
commit 50e14adac2
33 changed files with 1239 additions and 696 deletions
+69
View File
@@ -0,0 +1,69 @@
package transcoder
import log "github.com/sirupsen/logrus"
// V4l2m2mEncoder uses Video4Linux memory-to-memory hardware encoding.
type V4l2m2mEncoder struct{}
func (e *V4l2m2mEncoder) Name() string {
return "v4l2m2m"
}
func (e *V4l2m2mEncoder) DisplayName() string {
return "Video4Linux"
}
func (e *V4l2m2mEncoder) GlobalFlags() []string {
return nil
}
func (e *V4l2m2mEncoder) PixelFormat() string {
return "nv21"
}
func (e *V4l2m2mEncoder) Scaler() string {
return ""
}
func (e *V4l2m2mEncoder) ExtraFilters() string {
return ""
}
func (e *V4l2m2mEncoder) ExtraArguments() []string {
return nil
}
func (e *V4l2m2mEncoder) VariantFlags(v *HLSVariant) []string {
return nil
}
func (e *V4l2m2mEncoder) SupportedVideoCodecs() []string {
return []string{videoCodecH264}
}
func (e *V4l2m2mEncoder) FFmpegEncoderForCodec(codec string) string {
switch codec {
case videoCodecH264:
return "h264_v4l2m2m"
default:
log.Warnf("v4l2m2m encoder does not support codec %q, falling back to h264_v4l2m2m", codec)
return "h264_v4l2m2m"
}
}
func (e *V4l2m2mEncoder) GetPresetForLevel(l int) string {
presetMapping := map[int]string{
0: "ultrafast",
1: "superfast",
2: "veryfast",
3: "faster",
4: "fast",
}
preset, ok := presetMapping[l]
if !ok {
defaultPreset := presetMapping[1]
log.Errorf("Invalid level for v4l preset %d, defaulting to %s", l, defaultPreset)
return defaultPreset
}
return preset
}