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

<pre><code>ffmpeg  -i witness.mov -af asetrate=48018 resampled.mkv
</code></pre>

<p>The <code>resampled.mkv</code> has correct sync, but unfortunately the audio is <em>shorter</em> 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:</p>

<pre><code>ffmpeg  -i witness.mov -framerate 60 resampled.mkv
</code></pre>

<p>But the video frame rate did not change.</p>

CC BY-SA 4.0
2020-11-22T13:34:47.010Z
I have webm -> mp4 1h duration, both methods don't work.
Alex Sham
CC BY-SA 4.0
2018-11-03T12:54:19.607Z
2018-11-03T12:54:19.607Z
Grzegorz Adam Hankiewicz
<p>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 <em>faster</em> than the video. The input file as reported by ffmpeg is:</p>

<pre><code>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)
</code></pre>

<p>After running the following transcode command <code>ffmpeg  -i witness.mov  -filter:v scale=640:-1 mini.mkv</code> which reencodes everything, this is the stats of the output file:</p>

<pre><code>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
</code></pre>

<p>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?</p>

<p>I've seen <a href="https://video.stackexchange.com/a/19238/6553">the following answer for a similar problem</a> 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?</p>

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

CC BY-SA 4.0
2018-11-02T14:27:18.200Z
Add `-af aresample=async=1` and check.
Gyan
CC BY-SA 4.0
2018-11-02T17:54:14.577Z
@Gyan no difference compared to not using that switch.
Grzegorz Adam Hankiewicz
<video><ffmpeg><audio><sync>
Long video ffmpeg transcode makes audio go out of sync
Grzegorz Adam Hankiewicz
# Long video ffmpeg transcode makes audio go out of sync

(Asked by: username_0 on 2018-11-02)

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

**Tags:** video, ffmpeg, audio, sync

> **Comments:**
> **username_1**: Add `-af aresample=async=1` and check.  
> **username_0**: @username_1 no difference compared to not using that switch.  

---

## 1 answers

### Answer by username_0 on 2018-11-03. Score: 1 | Accepted answer

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.

> **Comments:**
> **username_2**: I have webm -> mp4 1h duration, both methods don't work.  

---

