问题
I have a full automated tool chain which first concatenate video chunks and adjusts user events to it. This first step uses 3rd party software, I am not able to fix the problem there. Later in the process I extract the audio from the video. Sometimes there are corrupted audio chunks inbetween. FFMPEG ignores the corrupted parts on extraction. So I got a mutch shorter audio (the linked events rely on the exact length of the org A/V). It wouldnt be a big issue if it would only happen at the end, I know how to pad it there, but at random poistions, I didnt find an option at the documentation doing the job. The only solution that worked was (pretty dirty I know) to convert the video to another video container with removed video stream and rename the file to MP3/AAC. It was working at windows/Android but all Mac-Browser didnt play it.
The -filter_complex -discard looks promising but I didnt find any good example for the correct syntax. I have found an Adobe Tool doing the job correctly so I hope there is a way to do with ffmpeg, too.
General
Complete name : C:\tmp123\video.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 57.8 MiB
Duration : 6 min 51 s
Overall bit rate : 1 177 kb/s
Writing application : Lavf58.26.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L4
Format settings, CABAC : No
Format settings, RefFrames : 2 frames
Format settings, GOP : M=1, N=30
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 6 min 51 s
Bit rate : 1 003 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 30.303 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.016
Stream size : 49.2 MiB (85%)
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 6 min 51 s
Bit rate mode : Constant
Bit rate : 168 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 8.22 MiB (14%)
Default : Yes
Alternate group : 1
回答1:
Thanks to Gyan I was able to fix the missing time by:
ffmpeg -i x.mp4 -y -vn -af aresample=async=1:first_pts=0:min_hard_comp=0.01 -acodec libfdk_aac x.aac
But I had a lot of audio clipping. Gyan suggest to use "async=3072" instead, but it was not working for me. The clipping was still present. I played around with the other values and min_hard_comp did the job. After setting it to 0.2 instead of 0.01 the clipping was gone. The generated audio does not fit 100% now, but it was redused from >1:30min to 30ms for a 6:51min video:
ffmpeg -i video.mp4 -y -vn -af aresample=async=1:first_pts=0:min_hard_comp=0.2 audioout1.mp3
Thx Gyan!
来源:https://stackoverflow.com/questions/64606142/ffmpeg-extract-audio-with-exact-timing-despite-corrupted-intermediate-audio-ch