FFMPEG:尽管中间音频块已损坏,但仍以准确的时序提取音频 [英] FFMPEG : Extract Audio with exact Timing despite corrupted intermediate audio chunks
问题描述
我有一个完整的自动化工具链,该工具链首先将视频块连接起来,并根据它调整用户事件.第一步使用3rd party软件,我在那里无法解决问题.在此过程的稍后部分,我将从视频中提取音频.有时它们之间有损坏的音频块.FFMPEG在提取时会忽略损坏的部分.因此,我得到了更短的音频(链接的事件取决于组织A/V的确切长度).如果只会在最后发生,这不会是一个大问题,我知道如何在此进行填充,但是在随机的情况下,我在完成这项工作的文档中没有找到任何选择.唯一有效的解决方案是(我知道很脏)将视频转换为带有已删除视频流的另一个视频容器,然后将文件重命名为MP3/AAC.它可以在Windows/Android上运行,但所有Mac-Browser都没有播放.
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.
-filter_complex -discard看起来很有希望,但是我没有找到正确语法的任何好例子.我发现Adobe Tool可以正确完成这项工作,因此希望也可以使用ffmpeg.
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
推荐答案
感谢Gyan,我能够通过以下方式解决缺少的时间:
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
但是我有很多音频剪辑.吉安(Gyan)建议使用"async = 3072"相反,但这对我不起作用.剪辑仍然存在.我尝试了其他值,min_hard_comp完成了这项工作.将其设置为0.2而不是0.01之后,修剪就消失了.生成的音频现在无法100%容纳,但对于6:51分钟的视频,它已从> 1:30min重播到30ms:
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)!
Thx Gyan!
这篇关于FFMPEG:尽管中间音频块已损坏,但仍以准确的时序提取音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!