5214d81264
* Query for installed codecs * Start modeling out codecs * Can now specify a codec and get the correct settings returned from the model * Return codecs in admin/serverconfig * Start handling transcoding errors and return messages to user * filter available codecs against a whitelist * Fix merge * Codecs are working * Switching between codecs work * Add apis for setting a custom video codec * Cleanup the logging of transcoder errors * Add v4l codec * Add fetching v4l * Add support for per-codec presets * Use updated nvenc encoding parameters * Update log message * Some more codec WIP * Turn off v4l. It is a mess. * Try to make the lowest latency level a bit more playable * Use a human redable display name in console messages * Turn on transcoder persistent connections * Add more codec-related user-facing error messages * Give the initial offline state transcoder an id * Force a minimum segment count of 3 * Disable qsv for now. set x264 specific params in VariantFlags * Close body in case * Ignore vbv underflow message, it is not actionable * Determine a dynamic gop value based on the length of segments * Add codec-specific tests * Cleanup * Ignore goconst lint warnings in codec file * Troubleshoot omx * Add more codec tests * Remove no longer accurate comment * Bundle admin from codec branch * Revert back to old setting * Cleanup list of codecs a bit * Remove old references to the encoder preset * Commit updated API documentation * Update admin bundle * Commit updated API documentation * Add codec setting to api spec * Commit updated API documentation Co-authored-by: Owncast <owncast@owncast.online>
82 lines
4.0 KiB
Go
82 lines
4.0 KiB
Go
package transcoder
|
|
|
|
import (
|
|
"strings"
|
|
"sync"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var _lastTranscoderLogMessage = ""
|
|
var l = &sync.RWMutex{}
|
|
|
|
var errorMap = map[string]string{
|
|
"Unrecognized option 'vaapi_device'": "you are likely trying to utilize a vaapi codec, but your version of ffmpeg or your hardware doesn't support it. change your codec to libx264 and restart your stream",
|
|
"unable to open display": "your copy of ffmpeg is likely installed via snap packages. please uninstall and re-install via a non-snap method. https://owncast.online/docs/troubleshooting/#misc-video-issues",
|
|
"Failed to open file 'http://127.0.0.1": "error transcoding. make sure your version of ffmpeg is compatible with your selected codec or is recent enough https://owncast.online/docs/troubleshooting/#codecs",
|
|
"can't configure encoder": "error with codec. if your copy of ffmpeg or your hardware does not support your selected codec you may need to select another",
|
|
"Unable to parse option value": "you are likely trying to utilize a specific codec, but your version of ffmpeg or your hardware doesn't support it. either fix your ffmpeg install or try changing your codec to libx264 and restart your stream",
|
|
"OpenEncodeSessionEx failed: out of memory": "your NVIDIA gpu is limiting the number of concurrent stream qualities you can support. remove a stream output variant and try again.",
|
|
"Cannot use rename on non file protocol, this may lead to races and temporary partial files": "",
|
|
"No VA display found for device": "vaapi not enabled. either your copy of ffmpeg does not support it, your hardware does not support it, or you need to install additional drivers for your hardware.",
|
|
"Could not find a valid device": "your codec is either not supported or not configured properly",
|
|
"H.264 bitstream error": "transcoding content error playback issues may arise. you may want to use the default codec if you are not already.",
|
|
|
|
`Unknown encoder 'h264_qsv'`: "your copy of ffmpeg does not have support for Intel QuickSync encoding (h264_qsv). change the selected codec in your video settings",
|
|
`Unknown encoder 'h264_vaapi'`: "your copy of ffmpeg does not have support for VA-API encoding (h264_vaapi). change the selected codec in your video settings",
|
|
`Unknown encoder 'h264_nvenc'`: "your copy of ffmpeg does not have support for NVIDIA hardware encoding (h264_nvenc). change the selected codec in your video settings",
|
|
`Unknown encoder 'h264_x264'`: "your copy of ffmpeg does not have support for the default x264 codec (h264_x264). download a version of ffmpeg that supports this.",
|
|
`Unrecognized option 'x264-params`: "your copy of ffmpeg does not have support for the default libx264 codec (h264_x264). download a version of ffmpeg that supports this.",
|
|
|
|
// Generic error for a codec
|
|
"Unrecognized option": "error with codec. if your copy of ffmpeg or your hardware does not support your selected codec you may need to select another",
|
|
}
|
|
|
|
var ignoredErrors = []string{
|
|
"Duplicated segment filename detected",
|
|
"Error while opening encoder for output stream",
|
|
"Unable to parse option value",
|
|
"Last message repeated",
|
|
"Option not found",
|
|
"use of closed network connection",
|
|
"URL read error: End of file",
|
|
"upload playlist failed, will retry with a new http session",
|
|
"VBV underflow",
|
|
"Cannot use rename on non file protocol",
|
|
}
|
|
|
|
func handleTranscoderMessage(message string) {
|
|
log.Debugln(message)
|
|
|
|
l.Lock()
|
|
defer l.Unlock()
|
|
|
|
// Ignore certain messages that we don't care about.
|
|
for _, error := range ignoredErrors {
|
|
if strings.Contains(message, error) {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Convert specific transcoding messages to human-readable messages.
|
|
for error, displayMessage := range errorMap {
|
|
if strings.Contains(message, error) {
|
|
message = displayMessage
|
|
break
|
|
}
|
|
}
|
|
|
|
if message == "" {
|
|
return
|
|
}
|
|
|
|
// No good comes from a flood of repeated messages.
|
|
if message == _lastTranscoderLogMessage {
|
|
return
|
|
}
|
|
|
|
log.Error(message)
|
|
|
|
_lastTranscoderLogMessage = message
|
|
}
|