@Override
            String reencodeRecording(@NonNull VncRecordingContainer container, @NonNull String source)
                throws IOException, InterruptedException {
                String newFileOutput = "/newScreen.mp4";
                container.execInContainer(
                    "ffmpeg",
                    "-i",
                    source,
                    "-vcodec",
                    "libx264",
                    "-movflags",
                    "faststart",
                    "-pix_fmt",
                    "yuv420p",
                    newFileOutput
                );
                return newFileOutput;
            }
Create a sidekick container and attach it to another container. The VNC output of that container will be recorded.
core/src/main/java/org/testcontainers/containers/VncRecordingContainer.java