JoeCondor
Posts: 3
Joined: Mon Feb 25, 2019 1:02 pm

Variable framerate

Mon Feb 25, 2019 1:11 pm

Hi everyone.
I'm actually using raspberry pi3 with the camera module v.2 to acquire (digitalyze) some old super8 films. The film projector runs at 18fps. I grabbed off the projector's lens and inserted a camera module inside the lens hole.
Everything works quite well except when I'm digitalyzing a film with sound. I'm recording the sound with an external recorder (Zoom h1 mic) and then putting video and audio together inside a NLE video software.
The problem is this: it seems that raspivid captures video with a variable framerate so, even if the audio and video streams durations are quite the same, when stitched together, they are out-of-sync and if I re-syng a part of the video, other parts go out-of-sync.

What am I doing wrong?
Thank you

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24924
Joined: Sat Jul 30, 2011 7:41 pm

Re: Variable framerate

Mon Feb 25, 2019 2:21 pm

How are you syncing the projectors with the camera shutter?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7889
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Variable framerate

Mon Feb 25, 2019 5:03 pm

raspivid does record at a fixed framerate, however that frame rate has to be an integer multiple of the line time. This varies slightly between modes, but for the V2.1 sensor is typically 18904nsecs.
18fps would be a frame period of 55.555msecs. Convert to an integer number of lines and you get either 2938 or 2939, giving an actual frame period of 55.54ms or 55.559ms. If you aren't accounting for that slight inaccuracy then audio and video will drift.

The best approach is to use timestamps. raspivid can save the timestamps of each frame by adding "-pts file.txt" to the command line. Tools such as mkvmerge should then be able to merge them together to get an accurately timestamped video clip ("mkvmerge -o video.mkv --timecodes 0:file.txt video.h264").
At that point you may need to query the exact accuracy on the sample clock of your Zoom H1 - is it exactly 44.10000kHz, or 44.1001kHz, because again that deviation will cause drift. This is why you get SMPTE timecode and the like within the professional domain for slaving audio accurately to video.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

JoeCondor
Posts: 3
Joined: Mon Feb 25, 2019 1:02 pm

Re: Variable framerate

Tue Feb 26, 2019 11:25 am

raspivid does record at a fixed framerate........
Thank you very much, 6by9. Your words are gold for me.
Actually I doesn't need that much accuracy. The projector itself isn't so accurate with the 18 fps (i don't know hot to measure it but I'm afraid it's rolling at "18,something" fps).
My problem is that importing my video+audio into the timeline, my audio duration, which is reasonabilly correct, is 15':50" while mi video duration is 15':39".
I noticed that framerate changes while variating exposure.
I made some tests changing light's power with a 10 sec video @60fps
- hi-powered lamp gives me 592 frames
- lo-powered lamp gives me 588 frames.

So I tried to turn off the auto esposure (-ex off). It seems to work quite well: a 2,5 mins video @ 18fps gives me exactly 2700 frames both with HI and LO light.

It seems i've find my way so I'm trying with a full 27 mins lenght reel.
Else, I'll come back to you and try the timestamp method.

Thank you very much!

JoeCondor
Posts: 3
Joined: Mon Feb 25, 2019 1:02 pm

Re: Variable framerate

Tue Feb 26, 2019 11:29 am

jamesh wrote:
Mon Feb 25, 2019 2:21 pm
How are you syncing the projectors with the camera shutter?
I sync it by specifying fps to the command line. It gives me quite a good result, for me. I see just a little bit of flickering but nothing to worry about. I don't need to be so precise as with a frame-by-frame digtization

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7889
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Variable framerate

Tue Feb 26, 2019 12:08 pm

The exposure time should be clipped to the frame rate, so changes shouldn't affect anything.
There are a couple of frames of variable frame rate preview before recording kicks in, although I still wouldn't expect recording to be affected.

With your use case having fixed shutter speed and gains make much more sense anyway. You want to accurately record what is being projected, complete with any "dynamic changes" as present on the film. If that happens to avoid your framerate changes then so much the better.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Washburn
Posts: 1
Joined: Sun Jan 19, 2020 9:25 pm

Re: Variable framerate

Sun Jan 19, 2020 9:31 pm

Hi, I have stumbled onto this forum and was looking at using a Raspberry Pi to connect to my cine projector, as I have over 100 films I want to digitize. I would appreciate it if you could tell me what projector you are using and the software you are using too.

User avatar
rpdom
Posts: 16070
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Variable framerate

Mon Jan 20, 2020 10:47 am

Washburn wrote:
Sun Jan 19, 2020 9:31 pm
Hi, I have stumbled onto this forum and was looking at using a Raspberry Pi to connect to my cine projector, as I have over 100 films I want to digitize. I would appreciate it if you could tell me what projector you are using and the software you are using too.
I'm not sure that I can help you here, but I have cine films too that I made a long time ago. I would be interested if there is a way to transfer them to video on the Pi. I no longer have the projector (Bell & Howell).

Return to “Camera board”