I have recorded a 50 minute video, edited it in Hitfilm Express to censor/blur people, and exported it in Hitfilm's high resolution format, generating an 80GB file. When I try to transcode this file into something more manageable, ffmpeg makes the audio drift. In the beginning everything sounds fine, but slowly the audio goes faster than the video. The input file as reported by ffmpeg is:
Guessed Channel Layout for Input Stream #0.1 : stereo Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/BakaTres/witness.mov': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt Duration: 00:50:31.42, start: 0.000000, bitrate: 230875 kb/s Stream #0:0(eng): Video: cfhd (CFHD / 0x44484643), yuv422p10le, 1920x1080, 229401 kb/s, 59.96 fps, 59.96 tbr, 90k tbn, 90k tbc (default) Metadata: encoder : CineForm HD Stream #0:1(eng): Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
After running the following transcode command
ffmpeg -i witness.mov -filter:v scale=640:-1 mini.mkv which reencodes everything, this is the stats of the output file:
Input #0, matroska,webm, from 'mini.mkv': Metadata: COMPATIBLE_BRANDS: qt MAJOR_BRAND : qt MINOR_VERSION : 537199360 ENCODER : Lavf57.56.100 Duration: 00:50:30.42, start: 0.000000, bitrate: 785 kb/s Stream #0:0(eng): Video: h264 (High 4:2:2), yuv422p(progressive), 640x360, 59.96 fps, 59.96 tbr, 1k tbn, 119.92 tbc (default) Metadata: ENCODER : Lavc57.64.101 libx264 DURATION : 00:50:30.422000000 Stream #0:1(eng): Audio: vorbis, 48000 Hz, stereo, fltp (default) Metadata: ENCODER : Lavc57.64.101 libvorbis DURATION : 00:50:28.403000000
The first sign that something goes wrong is that the original file specifies a duration of 50:31.42, while the transcode generates a 50:30.42 file. I wouldn't mind the second less if it weren't because the produced audio is 50:28.4, two seconds less than the video, which explains the delay difference. Unfortunately ffmpeg doesn't show the input length, but if I copy the source audio to an aiff file, Audacity tells me it's indeed 50:28.4 long, so is Hitfilm exporting the audio incorrectly with a shorter length than video?
I've seen the following answer for a similar problem but I don't understand how the values are calculated or how to apply these values to my input files. What values should I look for in the information of input/output to compare?
Even if the final transcoded length is slightly different, how can I prevent the audio from going out of sync (or fix Hitfilm's exported difference in video vs audio)?