How can I synchronize signal from an LED and TTL pulses better?
What you are probably missing here is that the frame rate of a webcam can be all over the place, especially if you are capturing video by getting a handle to the imaging device and then requesting frames by it using a timer.

In any case, wherever you are capturing the frame, capture its timestamp as well. This will allow you to cross reference the frames with the voltage time series better.

One of the first things that you have to do is synchronise at least the first pulse. So, independently of what you are going to do in subsequent processing steps, the first two pulses (one from the voltage time series and one from the video time series) must be synchronised. To do this, you simply shift one (or the other) time series so that the rising edges of the pulses coincide.

Now, extract the same amount of waveform in terms of seconds from both time series. So, extract for example 5 seconds from each. One is going to be 150 samples long the other 150000 samples long. Always subsample the more detailed one.

The two waveforms now will be as synchronised as your equipment allows them to be. If you plot them side by side you might find some mismatches because your camera's frame rate has some jitter.

The only way to escape this is by "counteracting" the FPS jitter by dropping voltage time series samples so that the voltage time series (which has higher resolution) "catches up" (or actually, lags behind) with the video.

You can do this either by matching each individual pulse's width or by Dynamic Time Warping (DTW).

The first method is straightforward: Extract a pulse period from both waveforms, measure the pulse width (in either waveform it has to be 150ms, 4.5 frames in the video waveform, 4500 samples in the voltage waveform), downsample the voltage waveform by a factor equal to the ratio between the pulse widths, move on to the next pulse period.

The second method basically does the same thing and can even return a signal which is exactly this "timing advance" signal by which you have to transform one of the waveforms so that it catches up with the other. In this case, things are even more straightforward: Downsample the voltage to the video sampling frequency and this will give you an approximate matching. Then, with both waveforms in the same sampling frequency, run them past DTW and apply the transformation.

Hope this helps.