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
[Attachment 72383 - Click to enlarge]
this is video profile
[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
+ Reply to Thread
Results 1 to 13 of 13
-
Last edited by slick zheng; 12th Jul 2023 at 23:55.
-
-
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
[Attachment 72385 - Click to enlarge] -
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. -
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.
[Attachment 72390 - Click to enlarge]
[Attachment 72391 - Click to enlarge] -
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
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 -
try to use the -ss option with ffmpeg to specify the start time of the audio track.
spribe-aviator.netLast edited by erik656; 14th Jul 2023 at 06:11.
-
-
Similar Threads
-
Using DVDShrink to extract only the video only English audio No subtitles
By RogerTango in forum DVD RippingReplies: 3Last Post: 19th Dec 2021, 17:48 -
How to extract video/audio/script from MKV to later use in Premiere?
By afjka in forum Newbie / General discussionsReplies: 2Last Post: 10th Oct 2020, 16:11 -
Unable to extract LPCM audio from MJPG video stream
By JJonah in forum AudioReplies: 4Last Post: 6th Feb 2020, 05:45 -
Audio sync problem — video goes out of sync after a while
By maxalfreeman in forum AudioReplies: 4Last Post: 12th Sep 2019, 13:07 -
how can i extract audio from claro video
By Juni745 in forum AudioReplies: 6Last Post: 8th Sep 2018, 12:21