mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-05 08:16:55 +08:00
Merge pull request #517 from skrashevich/230711-jpg-resize
This commit is contained in:
@@ -61,9 +61,22 @@ func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
|
||||
case core.CodecH264, core.CodecH265:
|
||||
ts := time.Now()
|
||||
var err error
|
||||
if data, err = ffmpeg.TranscodeToJPEG(data); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
// Resize image if "h" parameter exists
|
||||
if hParam := r.URL.Query().Get("h"); hParam != "" {
|
||||
h, err := strconv.Atoi(hParam)
|
||||
if err != nil {
|
||||
http.Error(w, "Invalid height parameter", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if data, err = ffmpeg.TranscodeToJPEG(data, h); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if data, err = ffmpeg.TranscodeToJPEG(data); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Debug().Msgf("[mjpeg] transcoding time=%s", time.Since(ts))
|
||||
}
|
||||
|
Reference in New Issue
Block a user