[FFmpeg-user] Extracted Audio not in Sync with Video
Josh
jnfo-d at grauman.com
Thu Nov 2 19:25:25 EET 2023
Sorry for top posting again, forgot about that!
So this worked. I added "[1]rubberband=tempo=.99991[aud];" to the filters
and now the audio and video all sync properly.
But this created a new problem. Now the audio has some slight distortion.
It almost sounds like an mp3 that doesn't have a high enough bitrate. It's
very faint, and most people probably wouldn't notice it, but I can
definitely hear it. Are there other ways so change the tempo that won't
distort the sound?
Josh
On Wed, 1 Nov 2023, Torsten Kaiser wrote:
> (top posted since the whole thing is top posted)
>
> That is what I do for adapting audio length to the video track
>
> In preparation I calculate the durations in seconds for VIDEO.mp4 and
> AUDIO.mp3 separately. Must be different files to get the length difference.
>
> Korn Script Snippet
>
> # ADSS is audio length in seconds (n.nn)
>
> # VDSS is video length in seconds (n.nn)
>
> typeset -F5 TEMPO=$(( $ADSS / $VDSS )) # calculates the correction factor
> for audio length, five digits precision
>
> #then I apply the rubberband filter to the AUDIO.mp3
>
> ffmpeg -y -i .AUDIO.mp3 -af rubberband=tempo=$TEMPO audio-corrected.mp3
>
> #Merging corrected audio and video
>
> ffmpeg -y -i .VIDEO.mp4 -i audio-corrected.mp3 TARGET.mp4
>
> #Note: rubberband has two nice options: tempo and pitch. Tempo makes the
> marching band play the same tune while running a marathon.
>
> #Pitch leaves the speed as it is while the cantor either sings with the
> whales or attracts all bats in the forest. Default is 1 for same tempo and/or
> same pitch.
>
>
> On 31.10.23 15:34, Joshua Grauman wrote:
>> I tried this and it doesn't help. The audio and video are still not in
>> sync, even when you don't use the fade-out...
>>
>> Josh
>>
>> On Tue, 31 Oct 2023, 凯迪软件(咨询、售后) via ffmpeg-user wrote:
>>
>>> ffmpeg -y -i "v1-ed.mp4" -i "a1-ed.wav" -filter_complex "[1]anull[aud];
>>> [0]fade=t=out:st=6673.87:n=24[out]" -strict experimental -shortest -map
>>> 0:v:0 -map 1:a:0 "lecture.mp4"
>>>
>>>
>>>
>>> ??????????????????????????????????????????
>>> You can try using this command to see if it can solve your problem.
>>>
>>> The translation in English is: "Try canceling the fade-in and fade-out
>>> effect you added."
>>>
>>>
>>> china kaidi
>>>
>>>
>>>
>>>
>>> ------------------ Original ------------------
>>> From: "FFmpeg user questions" <jnfo-d at grauman.com>;
>>> Date: Tue, Oct 31, 2023 07:31 AM
>>> To: "ffmpeg-user"<ffmpeg-user at ffmpeg.org>;
>>>
>>> Subject: [FFmpeg-user] Extracted Audio not in Sync with Video
>>>
>>>
>>>
>>> Hi all,
>>>
>>> My use case is that I want to extract audio from a mp4, edit the audio,
>>> and then put the audio and the video back together. It works fine, but
>>> over the course of the two hour video, the audio gets out of sync with
>>> the
>>> video and falls behind it (visibly, so you can see the mouth and sound
>>> aren't in sync).
>>>
>>> I extract the audio with a command like this:
>>> ffmpeg -y -i "v1-ed.mp4" -vn "a1.wav"
>>>
>>> I edit a1.wav with audacity to create a1-ed.wav.
>>>
>>> And then combine audio and video with a command like this:
>>> ffmpeg -y -i "v1-ed.mp4" -i "a1-ed.wav" -filter_complex "[1]anull[aud];
>>> [0]fade=t=out:st=6673.87:n=24[out]" -strict experimental -shortest -map
>>> [out] -map [aud] "lecture.mp4"
>>>
>>> Is there any easy way to make sure the audio stays sync'd through this
>>> process?
>>>
>>> Thanks,
>>>
>>> Josh
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-user
mailing list