Skip to content

Commit 752e8a1

Browse files
ffmpeg with nice/ionice
1 parent 98aa627 commit 752e8a1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

video/ffmpeg-nice.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash -ex
2+
# Run ffmpeg with low CPU (nice) and IO (ionice) priority
3+
# so it doesn't interfere with other processes too much
4+
nice -n19 ionice -c2 -n7 ffmpeg "$@"

video/transmux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func MuxTStoMP4(tsInputFile, mp4OutputFile string) ([]string, error) {
2525
// transmux the .ts file into a standalone MP4 file
2626
ffmpegErr := bytes.Buffer{}
2727
err := ffmpeg.Input(tsInputFile).
28+
SetFfmpegPath("/path/to/ffmpeg-nice.sh").
2829
Output(mp4OutputFile, ffmpeg.KwArgs{
2930
"analyzeduration": "15M", // Analyze up to 15s of video to figure out the format. We saw failures to detect the video codec without this
3031
"movflags": "faststart", // Need this for progressive playback and probing
@@ -81,7 +82,7 @@ func MuxTStoFMP4(fmp4ManifestOutputFile string, inputs ...string) error {
8182

8283
timeout, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
8384
defer cancel()
84-
cmd := exec.CommandContext(timeout, "ffmpeg", args...)
85+
cmd := exec.CommandContext(timeout, "/path/to/ffmpeg-nice.sh", args...)
8586

8687
var outputBuf bytes.Buffer
8788
var stdErr bytes.Buffer

0 commit comments

Comments
 (0)