admin管理员组文章数量:1357281
I'm building a screen recording software for Windows using Python. I use FFmpeg for recording and psutil to pause and resume the process.
Here is a sample of my code:
import psutil
import subprocess
process = subprocess.Popen([
'ffmpeg', '-y',
'-rtbufsize', '100M',
'-f', 'gdigrab',
'-thread_queue_size', '1024',
'-probesize', '50M',
'-r', '24',
'-draw_mouse', '1',
'-video_size', '1920x1080',
'-i', 'desktop',
'-f', 'dshow',
'-channel_layout', 'stereo',
'-thread_queue_size', '1024',
'-i', 'audio=Microphone (2- High Definition Audio Device)', # my audio device
'-c:v', 'h264_nvenc', # encoding via Nvidia
'-r', '24',
'-preset', 'p1',
'-pix_fmt', 'yuv444p',
'-fps_mode', 'cfr',
'-c:a', 'aac',
'-ac', '2',
'-b:a', '128k',
'output.mp4'])
ffmpeg_proc = psutil.Process(process.pid)
# pause
ffmpeg_proc.suspend()
# resume
ffmpeg_proc.resume()
The issue is that after resuming, the audio becomes choppy and delayed, while the video continues smoothly.
I have tried using following flags, but they didn't solve the issue:
-analyzeduration
-fflags +genpts
-async
-use_wallclock_as_timestamps
-af aresample=async=1
How can I properly pause and resume FFmpeg without causing audio delay? Is there any other method to handle this properly?
Thanks for any suggestions.
本文标签: pythonAudio delay after resuming FFmpeg on WindowsStack Overflow
版权声明:本文标题:python - Audio delay after resuming FFmpeg on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744068287a2585415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论