1

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)?

2
  • 1
    Add -af aresample=async=1 and check.
    – Gyan
    Commented Nov 2, 2018 at 14:27
  • @Gyan no difference compared to not using that switch. Commented Nov 2, 2018 at 17:54

1 Answer 1

1

After trying a few random things, I managed to make the audio/video sync by changing the rate of the audio:

ffmpeg  -i witness.mov -af asetrate=48018 resampled.mkv

The resampled.mkv has correct sync, but unfortunately the audio is shorter than the remaining video for a few seconds. Which means the problem is really that the frame rate is slightly slower than it should in the input file. According to my calculations, the problem is that the frame rate is set to 59.96, and setting it to exactly 60.0 would make the video match the audio. I tried using:

ffmpeg  -i witness.mov -framerate 60 resampled.mkv

But the video frame rate did not change.

1
  • I have webm -> mp4 1h duration, both methods don't work.
    – Alex Sham
    Commented Nov 22, 2020 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.