-1

I'm working on a project which involves capturing output from a camera via HDMI (Sony Alpha A7 IV), and projecting it via a laser/lamp projector, but the catch is that the stream which is going into the projector should be delayed by ~4 minutes. (If you start recording something at 10:00am, it will start playing back at 10:04am, etc.) It should be capturing and playing back the feed non-stop for the whole day.

First I was thinking of using FFplay to display a DirectShow stream from a HDMI capture card (like the Elgato 4K60 Pro) and opening the FFplay window on the 'projector screen', but I wasn't able to find any way to manually add delay to the stream. My second idea was to record the actual feed to a video file, and then immediately play it back in intervals (still using FFmpeg+FFplay).

Any other ideas/thoughts?

1 Answers1

0

I have no idea if this idea will work but here is something you can give it a try.

I'd go along your second idea. If the stars align, you can use ffmpeg process encoding with segment muxer while ffplay process decoding with concat demuxer.

The main idea is that segment muxer to produce a ~3-min video snippet (some duration shorter than the needed delay of ~4 min) after snippet throughout the day. This will give you predictable list of video files that ffplay needs to play in a sequence. So, you can prepare the playlist accordingly.

The encoder part should look something like:

ffmpeg [fill dshow input here] -f segment -segment_time 180 -segment_format_options movflags=+faststart out%03d.mp4

You can pick any codec/format you wish. mp4/h264 is probably a sensible solution but if you want raw you can use .nut format as well (see the other examples in the doc). When you experiment with it, you can enable -segment_list playlist.ffconcat to see what the concat demuxer expects.

If this display (is this an art installation?) will run for 24 hours, then you will have 480 files (assuming 3-min segments). Have all these filenames listed in the concat text and start ffplay after 4 minutes, by then the first segment should be available for playback. As ffplay plays, ffmpeg deposits new segments with prearranged file names every 3 minutes. So, you should be able to achieve continuous playback.

There is likely a way to make the delayed playback automated if you're programming all this. See the FFmpeg wiki on the topic of concatenation for more ideas.

You do need to be careful about the disk space, especially if you chose to store uncompressed video (.nut). Get a large storage or run a program on a side to delete consumed segments.

Again, I've never done this myself so I could very well be missing some details. But if I were you, this would be my first line of attack. Good luck.

kesh
  • 4,515
  • 2
  • 12
  • 20
  • Thank you for the segment muxer tip, I didn't know about that. Yes, it is a part of an art installation. I got more specific details, and the video recording/playback should only start after a motion sensor is triggered, otherwise the system should remain in a 'standby' mode, so I'm not sure if it will work using the method you described, (I guess it's designed for non-stop playback?) I'm more worried about the video playback (ffplay process starting/closing) being seamless. – Viktor Vošček Sep 28 '22 at 11:51
  • Assuming that you're a programmer supporting this project, once you verify this concept works, you should be able to adapt to realize the artist's vision. The complexity likely depends on whether you need to show the 4-min past prior to visitor entering the room. If you need further brainstorming, feel free to drop me a note on [GitHub](https://github.com/python-ffmpegio/python-ffmpegio/discussions) – kesh Sep 28 '22 at 15:02