VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Could someone please enlighten me on how to use aresample=async=1 with ffmpeg?

    I have a mkv i'm trying to encode where the audio is out of sync and was advised to use aresample

    I included it on the command line like so: ffmpeg -i c:\input.mp4 -c:a copy -c:v libx264 -preset slower -level:v 4.1 -crf 26 -aresample=async=1 c:\output.mkv

    However I get the following:

    Unrecognized option 'aresample=async=1'.
    Error splitting the argument list: Option not found

    The ffmpeg manual is not very clear on how to use this either. I have tried a few different combinations with no luck.
    Quote Quote  
  2. I doubt ffmpeg will magically fix your sync issue, but the error happens since you need to use:
    Code:
     -af aresample=async=1
    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Thanks, that worked, however the sync issue stems from using decimate by 5.

    I have a file which is using 29.970fps, every 5th frame is duplicated. I ran it through ffmpeg using -vf decimate=cycle=5 which fixed the issue with the video, new frame rate on the output was 23.976fps and the audio was copied using -c:a copy. The resulting file played fine at the start with audio/video in sync, however it gradually gets out of sync as it plays. It is out of sync by around 300ms at the end - 1hr 20min total length with the audio playing late.

    I opened the original and converted files in avidemux and checked the total length, converted file shows video stream being 300ms shorter than the audio stream - this is not the case in the original file, both streams almost match in length - around 5ms difference and there's no sync issues in the original.
    Quote Quote  
  4. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    gareth41

    Your original post.
    I have a mkv i'm trying to encode where the audio is out of sync and was advised to use aresample
    Your last post.
    this is not the case in the original file, both streams almost match in length - around 5ms difference and there's no sync issues in the original.
    I'm not sure which is true.
    Perhaps try Virtualdub2.
    Image
    [Attachment 63225 - Click to enlarge]


    I have never tried this.

    Cheers.
    Quote Quote  
  5. Try clever FFmpeg-GUI.
    Load your original 29.970 fps file, click main, click convert audio stream, click continue, leave all settings as they are except the settings marked in red in the following picture.
    Enter the exact same values, click convert, wait until it is completed.

    Image
    [Attachment 63226 - Click to enlarge]


    Then click multiplex, the new created audiostream is shown in green, click Add Stream, add your modified 23.976 fps videostream, deselect the video and audiostream of the 29.970 fps video, select the desired container, click multiplex. Done.

    Image
    [Attachment 63227 - Click to enlarge]
    Quote Quote  
  6. Just an update to this. I managed to sort out the sync issue.

    Basically you need to make sure the video length matches the audio length. The video length seems to change somewhat when decimating from 29.970 to 23.976.

    I'll post what I did as it may assist someone else with the same issue.

    I started out with a mp4 file x264 which someone had encoded and converted the frame rate from the original of 23.976 to 29.970 - resulting in every 5th frame being a duplicate. I wanted to decimate it to remove the duplicated frames while copying the audio stream intact (eg not re-encoding the audio).

    Using ffmpeg to do this works fine, but you will probably end up with the audio being out of sync like I did.

    Initially I used the following which did not work, the audio was playing too late towards the end of the video:
    ffmpeg -i C:\Input.mp4 -vf decimate=cycle=5,setpts=N/23.976/TB -c:a copy -c:v libx264 -preset slower -level:v 4.1 -crf 26 C:\Output.mkv

    So I ended up working out a formula to calculate the new frame rate to that the audio and video lengths matched exactly, this did the trick.

    First you need to get the total number of frames after decimating, using a dry run like this:
    ffmpeg -i C:\Input.mp4 -vf decimate=cycle=5,setpts=N/23.976/TB -loglevel debug -f null -

    Take a note of this, in my case it was 120149 frames total after decimating

    The audio length is also required, ffmpeg will give you this in its output. Convert this to ms. In my case this was 5011712ms. Basically we're going to change the playback speed of the video to match the audio length.

    use the following formula: 1000 / (audio_length_ms / total_video_frames)

    In my case this gave me 23.97364 which is the new frame rate to use

    Add this into ffmpeg like so:
    ffmpeg -i C:\Input.mp4 -vf decimate=cycle=5,setpts=N/23.97364/TB -c:a copy -c:v libx264 -preset slower -level:v 4.1 -crf 26 C:\Output.mkv

    The resulting file will have the video frame rate slowed down by a very small fraction so that it matches the audio length. my Samsung smart tv didn't seem to have any issue playing the file with the slightly reduced frame rate. The video motion is also very smooth now, not all jerky like before.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!