VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. i use ffmpeg to extract audio from video, the video's duration is 2min, but the extracted audio's duration is 1min58s, it has 2 seconds delay, the delay timestamp is from 1min56s, not the begin or end of the video
    this is audio profile
    Image
    [Attachment 72383 - Click to enlarge]


    this is video profile
    Image
    [Attachment 72384 - Click to enlarge]


    my command is ffmpeg -i input.mp4 -vn input.flac, i want to know how can i fix this problem? does anyone who had same problems as this
    Last edited by slick zheng; 12th Jul 2023 at 23:55.
    Quote Quote  
  2. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by slick zheng View Post
    i use ffmpeg to extract audio from video, the video's duration is 2min, but the extracted audio's duration is 1min58s, it has 2 seconds delay, the delay timestamp is from 1min56s, not the begin or end of the video
    this is audio profile
    Image
    [Attachment 72383 - Click to enlarge]


    this is video profile
    Image
    [Attachment 72384 - Click to enlarge]


    my command is ffmpeg -i input.mp4 -vn input.flac, i want to know how can i fix this problem? does anyone who had same problems as this
    try adding -async 1 to your ffmpeg command - ffmpeg -i input.mp4 -async 1 -vn input.flac
    Quote Quote  
  3. i try adding -async 1 in the ffmpeg command, this can fix the middle gap, but this can't fix the begin gap video, the video and audio track like this, you can see a gap between two track
    Image
    [Attachment 72385 - Click to enlarge]
    Quote Quote  
  4. You sent two images, first the ffmpeg output of the extracted flac stream, below the ffmpeg output of the video stream. You can't do anything with these.

    Send an image of the ffmpeg output of the complete video before extracting the audio stream.
    It should show the starttime info for the video stream AND the audio stream.
    Only then you can see an existing audio delay.
    Quote Quote  
  5. i find out the solution
    the second case's root cause is because of the audio track (which is in the video)'s start_pts is not same as the extracted audio file's start_pts, like one is 0.6, other is 0. so the performance is out-of-sync. so i use -af aresample=first_pts=0.6 to force set the extracted audio file's start_pts
    Quote Quote  
  6. Originally Posted by slick zheng View Post
    i find out the solution
    the second case's root cause is because of the audio track (which is in the video)'s start_pts is not same as the extracted audio file's start_pts, like one is 0.6, other is 0. so the performance is out-of-sync. so i use -af aresample=first_pts=0.6 to force set the extracted audio file's start_pts
    Wrong solution. You should use audio delay instead.
    Use clever FFmpeg-GUI, so you can see the audio delay and insert it when muxing.

    Image
    [Attachment 72390 - Click to enlarge]

    Image
    [Attachment 72391 - Click to enlarge]
    Quote Quote  
  7. so you mean i should use some like delay filter to do this? but i can't use GUI to solve, instead i only can use ffmpeg to do this. can you tell me which command you suggest to use
    Quote Quote  
  8. Originally Posted by slick zheng View Post
    so you mean i should use some like delay filter to do this? but i can't use GUI to solve, instead i only can use ffmpeg to do this. can you tell me which command you suggest to use
    Assuming that videostream and audiostream are into the same file (inputvideo):

    Add positive audio delay (video starts before audio) of 280ms:
    FFmpeg.exe -i inputvideo -itsoffset 0.28 -i inputvideo -map 0:0 -map 1:1 -c copy outputvideo
    Add negative audio delay(audio starts before video) of 280ms:
    FFmpeg.exe -itsoffset 0 -i inputvideo -itsoffset -0.28 -i inputvideo -map 0:0 -map 1:1 -c copy outputvideo
    Quote Quote  
  9. Originally Posted by ProWo View Post
    Originally Posted by slick zheng View Post
    so you mean i should use some like delay filter to do this? but i can't use GUI to solve, instead i only can use ffmpeg to do this. can you tell me which command you suggest to use
    Assuming that videostream and audiostream are into the same file (inputvideo):

    Add positive audio delay (video starts before audio) of 280ms:
    FFmpeg.exe -i inputvideo -itsoffset 0.28 -i inputvideo -map 0:0 -map 1:1 -c copy outputvideo
    Add negative audio delay(audio starts before video) of 280ms:
    FFmpeg.exe -itsoffset 0 -i inputvideo -itsoffset -0.28 -i inputvideo -map 0:0 -map 1:1 -c copy outputvideo
    sure, i understand your answer is to change the original file's video or audio track's timestamp, and to re-mux a new file, this absolutely can fix!
    but i just want to extract a audio file, and make sure the extracted audio file's timestamp is as same as it in the original video. ffmpeg -vn will ignore the original audio stream's start_pts, and set 0 to the audio file, so i must set the audio file's start_pts manually
    Quote Quote  
  10. Changing the start_pts for a single isolated stream makes no sense.
    Quote Quote  
  11. try to use the -ss option with ffmpeg to specify the start time of the audio track.

    spribe-aviator.net
    Last edited by erik656; 14th Jul 2023 at 06:11.
    Quote Quote  
  12. Originally Posted by ProWo View Post
    Changing the start_pts for a single isolated stream makes no sense.
    my work is separate the audio/video track into two file, so if there are some delay in anyone track, the new merged file will happen av out-of-sync
    Quote Quote  
  13. Originally Posted by erik656 View Post
    try to use the -ss option with ffmpeg to specify the start time of the audio track.
    i think it may loss some audio data, and it can't solve the time not match problem, because the extracted audio's start_pts always 0
    Quote Quote  



Similar Threads

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