VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 10 of 10
Thread

Threaded View

  1. I have a video file in which the audio is delayed by about 4 seconds. The audio starts too late.

    I tried various things according to this post: https://forum.videohelp.com/threads/346293-Insert-Audio-Delay-With-ffmpeg :
    • I tried to use avidemux, but no matter what value I enter in the delay box, the delay was STILL the same
    • I tried to use the following command: `ffmpeg -i test.avi -itsoffset 4.0 -i test.avi -map 0:0 -map 1:1 -vcodec libx264 -r 25 -b:v 1268k -s 512x368 -acodec copy audio_delayed.mp4` but still the delay was the same!
    • The only thing that worked more or less is to use kdenlive to split the audio and the video, shift it manually, repeat and repeat and render the video file taking almost 30 minutes of time. Its a 9 minute video, and all I want is to shift the audio wrt. the video...

    Is there anything else I can try?
    Quote Quote  
  2. Member hech54's Avatar
    Join Date
    Jul 2001
    Location
    Yank in Europe
    Search Comp PM
    Originally Posted by alex2356b View Post
    Is there anything else I can try?
    Yes... AviDemux.
    The delay is in milliseconds, don't be afraid to use big values in there... +- 250, 500, 1000, 2000, etc etc.
    Quote Quote  
  3. Thanks hech54,

    I already used values like 4000 ...
    Quote Quote  
  4. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    I tried your command on a video that was oos by 500ms and it made no difference.

    ffmpeg -i clip.mp4 -itsoffset 0.500 -i clip.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output_clip.mp4
    Then I used this command and it worked.

    ffmpeg -i clip.mp4 -itsoffset 0.500 -i clip.mp4 -vcodec copy -acodec copy -map 0:a -map 1:v output_clip.mp4
    Quote Quote  
  5. What I get is just audio without video! And when I reverse the mapping I have nothing...

    Error message in the first case during playing (repeated hundred times or so):

    missing marker bit!
    MPEG: bad sequence header

    and during the conversion with ffmpeg I seen thousand of buffer underflow errors...

    I am also trying to use mpg file, maybe that play a role...
    Quote Quote  
  6. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Using your script with my offset and map values, I had no problem.

    ffmpeg -i test.avi -itsoffset 0.5 -i test.avi -map 0:A -map 1:V -vcodec libx264 -r 25 -b:v 1268k -s 512x368 -acodec copy audio_delayed.mp4
    Quote Quote  
  7. I got immediately the following error:

    [avi @ 0x3e4bf00] Invalid stream specifier: A.
    Last message repeated 3 times
    Stream map '0:A' matches no streams.

    ffmpeg:

    ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
    built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
    configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
    libavutil 55. 28.100 / 55. 28.100
    libavcodec 57. 48.101 / 57. 48.101
    libavformat 57. 41.100 / 57. 41.100
    libavdevice 57. 0.102 / 57. 0.102
    libavfilter 6. 47.100 / 6. 47.100
    libavresample 3. 0. 0 / 3. 0. 0
    libswscale 4. 1.100 / 4. 1.100
    libswresample 2. 1.100 / 2. 1.100
    libpostproc 54. 0.100 / 54. 0.100
    Hyper fast Audio and Video encoder
    Quote Quote  
  8. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Instead of using V and A in the command I used your line from the first post and reversed the map as shown below and it worked.

    ffmpeg -i test.avi -itsoffset 4.0 -i test.avi -map 0:0 -map 1:1 -vcodec libx264 -r 25 -b:v 1268k -s 512x368 -acodec copy audio_delayed.mp4


    ffmpeg -i test.avi -itsoffset 0.5 -i test.avi -map 0:1 -map 1:0 -vcodec libx264 -r 25 -b:v 1268k -s 512x368 -acodec copy audio_delayed.mp4
    Quote Quote  
  9. Thanks for your help, now the render command work. But the offset between video and audio is still present. I chose a 4 second value(!) but still the audio is way before the video. Also changing to -map 0:1 -map 1:0 did not change anything ...
    Quote Quote  
  10. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    This worked for me.
    Audio leads video
    This file bbt.mp4 stream map showed 0:0 video 0:1 audio

    Add a positive value for audio adjustment (used mpc to get value)
    offset 500 ms will be applied to second file listed on command line (second appearance of bbt.mp4)

    On the command line...map now means something else :
    map 0:0 means first listed file on command line - keep video
    map 1:1 means second listed file on command line apply the offset to audio

    ffmpeg -i bbt.mp4 -itsoffset 0.500 -i bbt.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output_bbt.mp4
    Quote Quote  



Similar Threads