Hacker News new | ask | show | jobs
by js2 2014 days ago
Literally just used it today to re-sync the audio and video in some movies I recorded where I needed to add a 210ms delay to the audio. There's no better tool that I know of for doing this, even on macOS:

    ffmpeg \
        -i "$input" -itsoffset "$offset" \
        -i "$input" \
        -map 0:0 \
        -map 1:1 \
        -acodec copy \
        -vcodec copy \
        "$output"
4 comments

Another one I used to merge subtitles into their respective mkv video files:

    find . -name "*.mkv" -exec ffmpeg -i "{}" -i "{}.srt" -map 0 -map 1 -c copy "{}_merged.mkv" \;
No hate on ffmpeg but you can do this with mkvmerge as well.
Quite a nice syntax too:

    mkvmerge -o out.mkv in.avi in.srt
Thanks for the recommendation.
I'm curious as to how you figured out the audio was 210ms ahead of the video.
So I had recorded my son playing keyboard for a recital. The audio was recorded via MIDI into GarageBand into QuickTime Player. The video was off my iPhone via EpocCam over USB also into QuickTime Player. I was able to get the audio routing setup via a Multi-Output Device I configured in Audio MIDI Setup.

The video had a slight delay which I didn’t quite notice till after I’d recorded it.

I basically wrote a quick script to generate variations of the recorded movies with delays from 50ms to 500ms in 50ms increments and then just watched each of them to see which appeared most correct for his hands playing the keys and the sound of the notes. It was slightly over 200ms and less than 250ms. 210ms seemed the best.

I have now learned the importance of a clapperboard.

(Originally I was going to record the audio in GarageBand and the video on my phone and join them later, but I was learning as I went and I wanted to see if I could record the two streams together.)

That's an awesome story.

> I have now learned the importance of a clapperboard.

Ha! Good tip! Never thought about using one when doing recordings of recitals and stuff. Good idea.

Although now that I think about it, a clapperboard wouldn't help here because the audio was being generated on the Mac. There was no actual microphone involved capturing the sound a clapperboard would make. I need some other way to measure the latency being added by EpocCam. Hmmm....
Your "clapboard" would be a series of notes played on the keyboard in view of the camera.
That's what I did but it was surprisingly difficult to tell exactly when a key is pressed. It's just not as precise visually or aurally as a clapboard.
Players like vlc and mpv allow you to dynamically shift the audio wrt the video while playing, so one can just play around a bit until the perfect setting is found.
Also just used it a few hours ago, to resize and convert a video in order to send it via e-mail :-)
maybe mkvtoolnix.