Skip to content

Commit

Permalink
chore (plg_video_transcoder): cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Jan 31, 2024
1 parent 921fada commit f310470
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server/plugin/plg_video_transcoder/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package plg_video_transcoder

import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
. "github.com/mickael-kerjean/filestash/server/common"
. "github.com/mickael-kerjean/filestash/server/middleware"
"io"
"math"
"net/http"
Expand All @@ -15,6 +13,10 @@ import (
"strconv"
"strings"
"time"

"github.com/gorilla/mux"
. "github.com/mickael-kerjean/filestash/server/common"
. "github.com/mickael-kerjean/filestash/server/middleware"
)

const (
Expand Down Expand Up @@ -180,7 +182,7 @@ func hls_transcode(ctx *App, res http.ResponseWriter, req *http.Request) {
return
}

cmd := exec.Command("ffmpeg", []string{
cmd := exec.CommandContext(req.Context(), "ffmpeg", []string{
"-timelimit", "30",
"-ss", fmt.Sprintf("%d.00", startTime),
"-i", cachePath,
Expand Down Expand Up @@ -210,12 +212,12 @@ func hls_transcode(ctx *App, res http.ResponseWriter, req *http.Request) {
"pipe:out%03d.ts",
}...)

var str bytes.Buffer
var buffer bytes.Buffer
cmd.Stdout = res
cmd.Stderr = &str
cmd.Stderr = &buffer
err = cmd.Run()
if err != nil {
Log.Error("plg_video_transcoder::ffmpeg::run '%s' - %s", err.Error(), str.String())
Log.Error("plg_video_transcoder::ffmpeg::run '%s' - %s", err.Error(), base64.StdEncoding.EncodeToString(buffer.Bytes()))
}
}

Expand Down

0 comments on commit f310470

Please sign in to comment.