Use FFMPEG to export audios with gaps filled

偶尔善良 提交于 2021-01-28 10:01:02

问题


I have a MKV file with gaps in the audio. That is, there are gaps in the MKV audio track timestamps. According to "ffmpeg", the AC3 audio length is 802 seconds, but when exporting the audio to WAV, the resulting file length is 801'53 seconds. That is, the "exported" audio is shorter.

Triaging the issue with

ffmpeg -i INPUT.mkv -af ashowinfo -map 0:2 -y -frames:a XXXX -f alaw /dev/null

I can confirm that the length difference is consistent with gaps in the timestamps of the original audio frames. There are a handful of missing audio frames. I guess those are replaced by silence in the player.

The command I use to export the audio is:

ffmpeg -i INPUT.mkv -map 0:1 -ac 2 OUTPUT.wav

My question is: How can I instruct FFMPEG to preserve the gaps in the original audio, zero (silence) filled?. The WAV file duration should be the same than the original AC3 audio.

Given my current workflow, I would rather prefer to not keep the original timestamps in the output file but generate a WAV with (tiny) silences instead. I could consider keeping timestamps if there is no other choice, but this could be quite a pain in my workflow.

Advice? Help?

Thanks a lot in advance!


回答1:


Use

ffmpeg -i INPUT.mkv -map 0:1 -af aresample=async=1 -ac 2 OUTPUT.wav

The aresample filter will insert silent samples within the gaps.



来源:https://stackoverflow.com/questions/52845150/use-ffmpeg-to-export-audios-with-gaps-filled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!