oh god. I thought every social media was breaking my audio when uploaded, but no, they're transcoding my mp4 into a perfectly sync'd mp4.

which firefox/their video player then plays out of sync.

I feel like less shit for making a video that played wrong, I thought I fucked up the sync.

but now I have zero idea how to fix this

yeah, it's not tumblr that's fucking this, I made my own HTML that was just <title>VIDEO</title><video width="320" height="240" controls><source src="video.mp4" type="video/mp4"></video> and it still plays out of sync in firefox

ahh, if I convert the video to webm with handbrake, it burns the audio de-sync into the file.

but if I convert it to mp4, I get a mp4 that plays correct in VLC and chrome, but not firefox.

weird.

I think this is handbrake/ffmpeg doing something VERY weird when converting it to mp4

@foone how did you create the original video? I've seen stuff like this if you try to trim the beginning of a video while using -vcodec copy. You'll often end up with a few broken frames at the beginning because it starts on an i-frame rather than a keyframe.

If so, maybe it's dropping those frames when it transcodes and throwing it out of sync.

@mcgrew it was generated by ffmpeg in the first place, with an audio track added in using avidemux I think.
@foone well it was a thought. Not sure what else could cause it but ffmpeg is weird like that sometimes.

@mcgrew @foone not sure if related but: i had an a/v desync problem with ffmpeg-trimmed videos after uploading to instagram stories (yeah i know, still have to be there for reasons) which otherwise played okay in vlc etc.

-force_key_frames "00:00:00.000" seemed to fix that for me, at least with test reuploads of same videos but with this added to the final ffmpeg prompt. hadn't tested in a browser player though.

@grischa808 @foone I didn't know about that option. That actually could be helpful in one of my projects - I'll have to try it.
@mcgrew @foone had no idea either, until last month. turns out it can also populate the video with keyframes at a specified interval (e.g. for more precise seeking in a player) but in this case i figured it would sort of help initialize a/v sync with the extra keyframe at zero (if i get the idea correctly). needs more testing anyway.