SEEK and play a growing recording file

Has anyone managed to SEEK inside a growing file. I’m recording a DNxHD MXF with FFMPEG and can play it back even it is still recording. So far so good. But as the file length is “0” sending a SEEK > 0 crahes the playback. Recording is still running and playback from the beginning is possible as well. I’d like to do a timeshift playout.

You could check out the MAV forks:
https://github.com/krzyc/CasparCG-Server/tree/2.0.x-mav
https://github.com/jstarpl/casparcg-mav

Otherwise I’m guessing you would need to modify CCG to either ignore the total duration or recheck the file at a interval.

Thank for the hint. I tried the 2.0.7_MAV 8 as there is an open issue relating audio sync in MAV_9. This issue is still open since nearly 5 years. So I believe there is no support and will be no new versions based on 2.2.0 and following.

MAV_8 works pretty good. A combination of SPEED and SEEK commands combined with RESUME and PAUSE via Companion/Streamdeck makes it a pretty cheap replay machine.

Does anybody know what codec is used and if it can be changed ? It saves around 20Mbytes/s (160Mbit) to my drive which seems not too bad. But maybe there is room for improvements.

In the end I was hoping for a solution based on the main release thats more up to date and offers active support. But as you mentioned it seems that massive changes to the code are neccessary to make this possible.

It uses JPEG and you can’t change it, but you can change the subsampling and quality: https://github.com/krzyc/CasparCG-Server/blob/2.0.x-mav/modules/replay/consumer/replay_consumer.cpp#L366

The sampling doesn’t seam to change the filesize, and I can’t find a way to open the .mav in other software to analyse the quality. Do you know what type of container is used ? Or is the only way to access the recorded content playing it back in realtime and recording it with a FFmpeg consumer ?

Looks like mjpeg packaging from the source code. Does ffprobe tell you anything?

I did do some tests regarding this in the old 2.1.0 which had very crude slow-mo capabilities as well. My results with MKV files and what I think was the vp9 or vp8 codec were quite good for a proof of concept, but I never wrote any controls for it.

From what I remember this still reported a length 0? So it might just be that that version of CasparCG didn’t crash on seeking and it’s not related to codecs/containers.

Then there is the new kid on the block for replays: https://nageru.sesse.net/doc/futatabi.html
It does not support decklink in/out or interlaced but the maintainer says that can easily be done, so if you have some budget you could ask him about it.

1 Like

ffprobe tells “Invalid Data found when processing input”. Seems to be proprietary data that’s non standard video container.

I have just pushed Replay module compatible with current CasparCG to my repository:


No binaries yet. I have quickly tested it in Ubuntu 19.10 and it looks ok.
I will try to compile it in Windows when I find some free time.

Replay module uses custom file format, so ffprobe will not show anything. For every replay there are two files. Index file has 52 bytes of header followed by 32-bit indexes. Data file contains (for every frame): 32-bit length of audio data, then raw audio data, then JPEG compressed video data.

Please feel free to create issues in GitHub - I will try to fix them.

Sorry for my inactivity, but for now this project is just a hobby for me, so it is not on my priority list and CasparCG has undergone many changes since 2.1 version.

2 Likes

Was there ever a PR submitted for the replay module? Might be about time to look into it again. I was actually interested in using some of it in another way and have it continuously update preview JPEG’s of all running channels.

1 Like

No, there were no PRs of replay module. I do not think that it is production ready and in my opinion someone with knowledge of CCG internals should take a look at sources first. Also I do not know whether it is essential module for CCG - and, when merged, it will need some attention with every CCG release.

It was/is useful for me - it can be used as simple recorder and also for replays and delays - but maybe ffmpeg can be used for same purpose with similar results now?

edit

I have released binaries - here are details: