Jelajahi Sumber

解决部分视频播放时声音有杂音的问题

huihui 4 tahun lalu
induk
melakukan
76009beac1

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+
+bin32/VideoPlayer.ilk
+VideoPlayer.pro.user

TEMPAT SAMPAH
bin32/VideoPlayer.exe


TEMPAT SAMPAH
bin32/VideoPlayer.pdb


+ 5 - 2
module/VideoPlayer/src/VideoPlayer/VideoPlayer.cpp

@@ -180,10 +180,11 @@ int VideoPlayer::openSDL()
     int samplerate = 44100;
 
     wanted_spec.channels = wanted_nb_channels;
+    wanted_spec.samples = FFMAX(512, 2 << av_log2(wanted_spec.freq / 30));
     wanted_spec.freq = samplerate;
     wanted_spec.format = AUDIO_S16SYS; // 具体含义请查看“SDL宏定义”部分
     wanted_spec.silence = 0;            // 0指示静音
-    wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;  // 自定义SDL缓冲区大小
+//    wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;  // 自定义SDL缓冲区大小
     wanted_spec.callback = sdlAudioCallBackFunc;  // 回调函数
     wanted_spec.userdata = this;                  // 传给上面回调函数的外带数据
 
@@ -380,7 +381,9 @@ void VideoPlayer::readVideoFile()
             in_ch_layout = aCodecCtx->channel_layout;
 
             //输出的采样率
-            out_sample_rate = 44100;
+//            out_sample_rate = 44100;
+            out_sample_rate = aCodecCtx->sample_rate;
+
             //输出的声道布局
 
             audio_tgt_channels = 2; ///av_get_channel_layout_nb_channels(out_ch_layout);

+ 1 - 1
module/VideoPlayer/src/VideoPlayer/VideoPlayer.h

@@ -98,7 +98,7 @@ private:
     float mVolume; //音量 0~1 超过1 表示放大倍数
 
     /// 跳转相关的变量
-    int             seek_req; //跳转标志
+    int             seek_req = 0; //跳转标志
     int64_t         seek_pos; //跳转的位置 -- 微秒
     int             seek_flag_audio;//跳转标志 -- 用于音频线程中
     int             seek_flag_video;//跳转标志 -- 用于视频线程中

+ 1 - 1
src/Widget/SetVideoUrlDialog.ui

@@ -68,7 +68,7 @@
         </size>
        </property>
        <property name="text">
-        <string>rtmp://202.69.69.180:443/webcast/bshdlive-pc</string>
+        <string>rtmp://58.200.131.2:1935/livetv/hunantv</string>
        </property>
       </widget>
      </item>