The quality factor Q characterizes the absorption and attenuation of seismic waves as they spread through underground media.It is an important indicator of hydrocarbon accumulation.Estimating Q based on time-frequency analysis has emerged as one of the most common and effective methods in seismic data analysis.The short-time Fourier transform(STFT)is a popular time-frequency localization technique with a predetermined size and geometry of the time window.However,the fixed window function limits its adaptability.In order to accurately capture both low and high-frequency components of the signal,it is necessary to adjust the window width based on the signal's characteristics.A wider time window is needed to represent low-frequency components,whereas a narrower time window is required for high-frequency components.We propose an adaptive window length method for the short-time Fourier transform to calculate instantaneous frequency and determine the Q value using the peak-frequency shift meth-od.The core idea is to employ a large window for the short-time Fourier transform to extract the instantaneous center frequency as the initial frequency,which is then used to dynamically select the optimal window length for subsequent calculation.By adapting the window length based on the initial frequency,a better balance between frequency resolution and time resolution is achieved.Both synthetic data tests and field data application demonstrate that the short-time Fourier transform with adaptive window length out-performs the traditional fixed-window short-time Fourier transform in Q estimation with higher vertical resolution and lateral con-sistency.Our approach enhances the accuracy and reliability of Q-value estimation,which may lead to comprehensive understanding of underground media and potential oil and gas resources.