Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTC: Refine FFmpeg opus audio noisy issue. v5.0.197 v6.0.97 #3852

Merged
merged 6 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ jobs:
- name: Run SRS regression-test
run: |
docker run --rm srs:test bash -c './objs/srs -c conf/regression-test.conf && \
cd 3rdparty/srs-bench && ./objs/srs_test -test.v && ./objs/srs_gb28181_test -test.v'
cd 3rdparty/srs-bench && (./objs/srs_test -test.v || (cat ../../objs/srs.log && exit 1)) && \
./objs/srs_gb28181_test -test.v'
runs-on: ubuntu-20.04

coverage:
Expand Down
3 changes: 1 addition & 2 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ function parse_user_option() {
--ffmpeg-tool) SRS_FFMPEG_TOOL=$(switch2value $value) ;;

# use cache for build.
--build-cache) SRS_BUILD_CACHE=YES ;;
--without-build-cache) SRS_BUILD_CACHE=NO ;;
--build-cache) SRS_BUILD_CACHE=$(switch2value $value) ;;

*)
echo "$0: error: invalid option \"$option\""
Expand Down
1 change: 0 additions & 1 deletion trunk/research/players/js/srs.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function srs_get_player_height() { return srs_get_player_width() * 9 / 19; }
* update the navigator, add same query string.
*/
function update_nav() {
$("#srs_index").attr("href", "index.html" + window.location.search);
$("#nav_srs_player").attr("href", "srs_player.html" + window.location.search);
$("#nav_rtc_player").attr("href", "rtc_player.html" + window.location.search);
$("#nav_rtc_publisher").attr("href", "rtc_publisher.html" + window.location.search);
Expand Down
6 changes: 3 additions & 3 deletions trunk/research/players/srs_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a id="srs_index" class="brand" href="#">SRS</a>
<a class="brand" href="https://github.com/ossrs/srs" target="_blank">SRS</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a id="nav_srs_player" href="srs_player.html">LivePlayer</a></li>
Expand All @@ -29,11 +29,11 @@
<!--<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>-->
<!--li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
<!--<li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>-->
<li>
<!--<li>
<a href="https://github.com/ossrs/srs">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
</a>
</li>
</li>-->
</ul>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions trunk/research/players/whep.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a id="srs_index" class="brand" href="https://github.com/ossrs/srs">SRS</a>
<a class="brand" href="https://github.com/ossrs/srs" target="_blank">SRS</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">LivePlayer</a></li>
Expand All @@ -34,11 +34,11 @@
<!--<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>-->
<!--<li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
<!--<li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>-->
<li>
<!--<li>
<a href="https://github.com/ossrs/srs">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
</a>
</li>
</li>-->
</ul>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions trunk/research/players/whip.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a id="srs_index" class="brand" href="https://github.com/ossrs/srs">SRS</a>
<a class="brand" href="https://github.com/ossrs/srs" target="_blank">SRS</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a id="nav_srs_player" href="srs_player.html">LivePlayer</a></li>
Expand All @@ -34,11 +34,11 @@
<!--<li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>-->
<!--<li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>-->
<!--<li><a id="nav_gb28181" href="srs_gb28181.html">GB28181</a></li>-->
<li>
<!--<li>
<a href="https://github.com/ossrs/srs">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
</a>
</li>
</li>-->
</ul>
</div>
</div>
Expand Down
20 changes: 11 additions & 9 deletions trunk/src/app/srs_app_rtc_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ srs_error_t SrsAudioTranscoder::init_enc(SrsAudioCodecId dst_codec, int dst_chan
if (!enc_frame_) {
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not allocate audio encode in frame");
}
enc_frame_->format = enc_->sample_fmt;
enc_frame_->nb_samples = enc_->frame_size;
enc_frame_->channel_layout = enc_->channel_layout;

if (av_frame_get_buffer(enc_frame_, 0) < 0) {
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not get audio frame buffer");
}

enc_packet_ = av_packet_alloc();
if (!enc_packet_) {
Expand Down Expand Up @@ -381,26 +388,21 @@ srs_error_t SrsAudioTranscoder::encode(std::vector<SrsAudioFrame*> &pkts)
}

while (av_audio_fifo_size(fifo_) >= enc_->frame_size) {
enc_frame_->format = enc_->sample_fmt;
enc_frame_->nb_samples = enc_->frame_size;
enc_frame_->channel_layout = enc_->channel_layout;

if (av_frame_get_buffer(enc_frame_, 0) < 0) {
av_frame_free(&enc_frame_);
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not get audio frame buffer");
// make sure the frame is writable
if (av_frame_make_writable(enc_frame_) < 0) {
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not make writable frame");
xiaozhihong marked this conversation as resolved.
Show resolved Hide resolved
}

/* Read as many samples from the FIFO buffer as required to fill the frame.
* The samples are stored in the frame temporarily. */
if (av_audio_fifo_read(fifo_, (void **)enc_frame_->data, enc_->frame_size) < enc_->frame_size) {
av_frame_free(&enc_frame_);
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not read data from FIFO");
}

/* send the frame for encoding */
enc_frame_->pts = next_out_pts_;
next_out_pts_ += enc_->frame_size;
int error = avcodec_send_frame(enc_, enc_frame_);
av_frame_unref(enc_frame_);
if (error < 0) {
return srs_error_new(ERROR_RTC_RTP_MUXER, "Error sending the frame to the encoder(%d,%s)", error,
av_make_error_string(err_buf, AV_ERROR_MAX_STRING_SIZE, error));
Expand Down