Skip to content

Commit

Permalink
Add some notes on recording in regards to ffconcat
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Dec 20, 2024
1 parent f78bcf3 commit 0c768bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
13 changes: 1 addition & 12 deletions pkg/worker/caged/libretro/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/worker/recorder/ffmpegmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
12 changes: 12 additions & 0 deletions pkg/worker/recorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0c768bb

Please sign in to comment.