Skip to content

Conversation

clonejo
Copy link
Contributor

@clonejo clonejo commented Jun 22, 2025

Hello!

Driven by the fact that my 1.5 years worth of trains are now approaching 1TB of space usage, and most of that is just the (poorly looking) gifs, i have hacked together this h264/mp4 train clip encoding feature using gstreamer. Gstreamer has been a pain, but i finally got it working. I went for gstreamer and not ffmpeg in the hopes that we could save some context switches and copying frames around.

example train renderings

train_00010101_000004 186_Z

train_00010101_000004 186_Z

train_00010101_000004.186_Z.mp4

This clip plays for me locally in mp4, just one more detail i have not figured out …

But it is much better looking than the gif, while being smaller than the stitched jpg.

There is still a bunch of stuff to do, but i wanted your feedback on the general idea.

Cheers,
Feiko

@jo-m
Copy link
Owner

jo-m commented Jun 25, 2025

Certainly a good idea, GIF is a terrible format for this and h264 is much better.

However, I am not happy about the choice of gstreamer. We already depend on the ffmpeg (cli) anyways, and the overhead when using ffmpeg in a separate process is prob. negligible as this is only happening asynchronously for a few frames, not all the time.

@clonejo
Copy link
Contributor Author

clonejo commented Jul 3, 2025

OK. Doesn't feel great since gstreamer was a a bunch of work. But understandable.

BTW, is there a way to provide per frame timings to ffmpeg? This is relevant because we sometimes have frames dropped within a frame (because it is too dark/contrast too low) and it would be nice to not have the train clip jump. Also ofc there's webcams with variable frame rate. Would be awesome if the videos were good enough to be reprocessed afterwards. I also imagine would could save the video on stitching failures, to generate test cases.

@jo-m
Copy link
Owner

jo-m commented Jul 3, 2025

Yes, videos could indeed be quite useful to generate more testdata and aid in debugging.

Supposedly, you can provide a per frame duration to the demuxer:

no per-frame PTS yet
@jo-m
Copy link
Owner

jo-m commented Jul 13, 2025

Let me know when ready for review. I am also fine with completely removing the GIF recording functionality, but ofc. the database has to stay backwards compatible and to know if for a certain recording there is a gif or a h264 clip.

I can also fix the frontend if that change is implemented.

But please be aware that I am currently under a bit of time pressure, so it might take a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants