From 0c768bb3d6dd55decf4ba2ee90515c4748c70a62 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Sat, 21 Dec 2024 01:37:42 +0300 Subject: [PATCH] Add some notes on recording in regards to ffconcat --- pkg/worker/caged/libretro/recording.go | 13 +------------ pkg/worker/recorder/ffmpegmux.go | 15 +++++++++++++++ pkg/worker/recorder/recorder.go | 12 ++++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pkg/worker/caged/libretro/recording.go b/pkg/worker/caged/libretro/recording.go index cc4cdcdde..647345367 100644 --- a/pkg/worker/caged/libretro/recording.go +++ b/pkg/worker/caged/libretro/recording.go @@ -15,17 +15,6 @@ type RecordingFrontend struct { } func WithRecording(fe Emulator, rec bool, user string, game string, conf config.Recording, log *logger.Logger) *RecordingFrontend { - - pix := "" - switch fe.PixFormat() { - case 0: - pix = "rgb1555" - case 1: - pix = "brga" - case 2: - pix = "rgb565" - } - rr := &RecordingFrontend{Emulator: fe, rec: recorder.NewRecording( recorder.Meta{UserName: user}, log, @@ -36,7 +25,6 @@ func WithRecording(fe Emulator, rec bool, user string, game string, conf config. Zip: conf.Zip, Vsync: true, Flip: fe.Flipped(), - Pix: pix, })} rr.ToggleRecording(rec, user) return rr @@ -70,6 +58,7 @@ func (r *RecordingFrontend) LoadGame(path string) error { } r.rec.SetFramerate(float64(r.Emulator.FPS())) r.rec.SetAudioFrequency(r.Emulator.AudioSampleRate()) + r.rec.SetPixFormat(r.Emulator.PixFormat()) return nil } diff --git a/pkg/worker/recorder/ffmpegmux.go b/pkg/worker/recorder/ffmpegmux.go index 37c9df6aa..ba5435510 100644 --- a/pkg/worker/recorder/ffmpegmux.go +++ b/pkg/worker/recorder/ffmpegmux.go @@ -17,6 +17,21 @@ const demuxFile = "input.txt" // // !to change // +// - can't read pix_fmt from ffconcat +// - maybe change raw output to yuv420? +// - frame durations and size can change dynamically +// - or maybe merge encoded streams +// +// new: +// +// ffmpeg -f image2 -framerate 59 -video_size 384x224 -pixel_format rgb565le \ +// -i "./f%07d__384x224__768.raw" \ +// -ac 2 -channel_layout stereo -i audio.wav -b:a 192K \ +// -c:v libx264 -pix_fmt yuv420p -crf 20 \ +// output.mp4 +// +// old: +// // ffmpeg -f concat -i input.txt \ // -ac 2 -channel_layout stereo -i audio.wav \ // -b:a 192K -crf 23 -vf fps=30 -pix_fmt yuv420p \ diff --git a/pkg/worker/recorder/recorder.go b/pkg/worker/recorder/recorder.go index 5c1bf9046..8082ab507 100644 --- a/pkg/worker/recorder/recorder.go +++ b/pkg/worker/recorder/recorder.go @@ -165,6 +165,18 @@ func (r *Recording) Set(enable bool, user string) { func (r *Recording) SetFramerate(fps float64) { r.opts.Fps = fps } func (r *Recording) SetAudioFrequency(fq int) { r.opts.Frequency = fq } +func (r *Recording) SetPixFormat(fmt uint32) { + pix := "" + switch fmt { + case 0: + pix = "rgb1555" + case 1: + pix = "brga" + case 2: + pix = "rgb565le" + } + r.opts.Pix = pix +} func (r *Recording) Enabled() bool { r.Lock()