mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
FFmpeg: Support build with FFmpeg native opus. v5.0.131 (#3140)
This commit is contained in:
parent
372390f8d1
commit
a27ce1d50f
7 changed files with 46 additions and 24 deletions
|
@ -86,6 +86,12 @@ else
|
||||||
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
|
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $SRS_FFMPEG_OPUS == YES ]]; then
|
||||||
|
srs_define_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
|
||||||
|
else
|
||||||
|
srs_undefine_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $SRS_SIMULATOR == YES ]]; then
|
if [[ $SRS_SIMULATOR == YES ]]; then
|
||||||
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
|
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
|
||||||
else
|
else
|
||||||
|
|
|
@ -528,7 +528,7 @@ fi
|
||||||
# libopus, for WebRTC to transcode AAC with Opus.
|
# libopus, for WebRTC to transcode AAC with Opus.
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# For cross build, we use opus of FFmpeg, so we don't build the libopus.
|
# For cross build, we use opus of FFmpeg, so we don't build the libopus.
|
||||||
if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD != YES ]]; then
|
if [[ $SRS_RTC == YES && $SRS_FFMPEG_OPUS != YES ]]; then
|
||||||
# Only build static libraries if no shared FFmpeg.
|
# Only build static libraries if no shared FFmpeg.
|
||||||
if [[ $SRS_SHARED_FFMPEG == NO ]]; then
|
if [[ $SRS_SHARED_FFMPEG == NO ]]; then
|
||||||
OPUS_OPTIONS="--disable-shared --disable-doc"
|
OPUS_OPTIONS="--disable-shared --disable-doc"
|
||||||
|
@ -559,11 +559,11 @@ fi
|
||||||
# ffmpeg-fit, for WebRTC to transcode AAC with Opus.
|
# ffmpeg-fit, for WebRTC to transcode AAC with Opus.
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
||||||
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
FFMPEG_CONFIGURE="env SRS_FFMPEG_FIT=on"
|
||||||
FFMPEG_CONFIGURE="./configure"
|
if [[ $SRS_FFMPEG_OPUS != YES ]]; then
|
||||||
else
|
FFMPEG_CONFIGURE="$FFMPEG_CONFIGURE PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/opus/lib/pkgconfig"
|
||||||
FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=${SRS_DEPENDS_LIBS}/opus/lib/pkgconfig ./configure"
|
|
||||||
fi
|
fi
|
||||||
|
FFMPEG_CONFIGURE="$FFMPEG_CONFIGURE ./configure"
|
||||||
|
|
||||||
# Disable all features, note that there are still some options need to be disabled.
|
# Disable all features, note that there are still some options need to be disabled.
|
||||||
FFMPEG_OPTIONS="--disable-everything"
|
FFMPEG_OPTIONS="--disable-everything"
|
||||||
|
@ -583,9 +583,9 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
||||||
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cross-prefix=$SRS_CROSS_BUILD_PREFIX"
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cross-prefix=$SRS_CROSS_BUILD_PREFIX"
|
||||||
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cc=${SRS_TOOL_CC} --cxx=${SRS_TOOL_CXX} --ar=${SRS_TOOL_AR} --ld=${SRS_TOOL_LD}"
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --cc=${SRS_TOOL_CC} --cxx=${SRS_TOOL_CXX} --ar=${SRS_TOOL_AR} --ld=${SRS_TOOL_LD}"
|
||||||
fi
|
fi
|
||||||
# For cross-build.
|
# For audio codec opus, use FFmpeg native one, or external libopus.
|
||||||
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
if [[ $SRS_FFMPEG_OPUS == YES ]]; then
|
||||||
# Note that the audio might be corrupted, if use FFmpeg native opus.
|
# TODO: FIXME: Note that the audio might be corrupted, see https://github.com/ossrs/srs/issues/3140
|
||||||
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=opus --enable-encoder=opus"
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=opus --enable-encoder=opus"
|
||||||
else
|
else
|
||||||
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus"
|
FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus"
|
||||||
|
|
|
@ -36,6 +36,8 @@ SRS_FFMPEG_STUB=NO
|
||||||
SRS_FFMPEG_TOOL=NO
|
SRS_FFMPEG_TOOL=NO
|
||||||
# FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
|
# FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
|
||||||
SRS_FFMPEG_FIT=RESERVED
|
SRS_FFMPEG_FIT=RESERVED
|
||||||
|
# Whether use FFmpeg native opus codec for RTC. If not, use libopus instead.
|
||||||
|
SRS_FFMPEG_OPUS=NO
|
||||||
# arguments
|
# arguments
|
||||||
SRS_PREFIX=/usr/local/srs
|
SRS_PREFIX=/usr/local/srs
|
||||||
SRS_DEFAULT_CONFIG=conf/srs.conf
|
SRS_DEFAULT_CONFIG=conf/srs.conf
|
||||||
|
@ -164,6 +166,7 @@ Features:
|
||||||
--cxx11=on|off Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
|
--cxx11=on|off Whether enable the C++11. Default: $(value2switch $SRS_CXX11)
|
||||||
--cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
|
--cxx14=on|off Whether enable the C++14. Default: $(value2switch $SRS_CXX14)
|
||||||
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
|
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
|
||||||
|
--ffmpeg-opus=on|off Whether enable the FFmpeg native opus codec. Default: $(value2switch $SRS_FFMPEG_OPUS)
|
||||||
--apm=on|off Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
|
--apm=on|off Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
|
||||||
|
|
||||||
--prefix=<path> The absolute installation path. Default: $SRS_PREFIX
|
--prefix=<path> The absolute installation path. Default: $SRS_PREFIX
|
||||||
|
@ -342,6 +345,7 @@ function parse_user_option() {
|
||||||
--generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
|
--generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
|
||||||
--single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
|
--single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
|
||||||
--ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
|
--ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
|
||||||
|
--ffmpeg-opus) SRS_FFMPEG_OPUS=$(switch2value $value) ;;
|
||||||
--gb28181) SRS_GB28181=$(switch2value $value) ;;
|
--gb28181) SRS_GB28181=$(switch2value $value) ;;
|
||||||
|
|
||||||
--cxx11) SRS_CXX11=$(switch2value $value) ;;
|
--cxx11) SRS_CXX11=$(switch2value $value) ;;
|
||||||
|
@ -502,6 +506,10 @@ function apply_auto_options() {
|
||||||
if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
|
if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
|
||||||
SRS_FFMPEG_FIT=YES
|
SRS_FFMPEG_FIT=YES
|
||||||
fi
|
fi
|
||||||
|
if [[ $SRS_CROSS_BUILD == YES && $SRS_FFMPEG_OPUS != YES ]]; then
|
||||||
|
echo "Enable FFmpeg native opus for cross building"
|
||||||
|
SRS_FFMPEG_OPUS=YES
|
||||||
|
fi
|
||||||
|
|
||||||
# Enable asan, but disable for Centos
|
# Enable asan, but disable for Centos
|
||||||
# @see https://github.com/ossrs/srs/issues/3347
|
# @see https://github.com/ossrs/srs/issues/3347
|
||||||
|
@ -616,6 +624,7 @@ function regenerate_options() {
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=$(value2switch $SRS_CXX14)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=$(value2switch $SRS_CXX14)"
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --backtrace=$(value2switch $SRS_BACKTRACE)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --backtrace=$(value2switch $SRS_BACKTRACE)"
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=$(value2switch $SRS_FFMPEG_FIT)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=$(value2switch $SRS_FFMPEG_FIT)"
|
||||||
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-opus=$(value2switch $SRS_FFMPEG_OPUS)"
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=$(value2switch $SRS_NASM)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=$(value2switch $SRS_NASM)"
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=$(value2switch $SRS_SRTP_ASM)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=$(value2switch $SRS_SRTP_ASM)"
|
||||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=$(value2switch $SRS_CLEAN)"
|
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=$(value2switch $SRS_CLEAN)"
|
||||||
|
|
12
trunk/configure
vendored
12
trunk/configure
vendored
|
@ -156,11 +156,17 @@ fi
|
||||||
|
|
||||||
# FFMPEG for WebRTC transcoding, such as aac to opus.
|
# FFMPEG for WebRTC transcoding, such as aac to opus.
|
||||||
if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
if [[ $SRS_FFMPEG_FIT == YES ]]; then
|
||||||
LibFfmpegRoot="${SRS_OBJS}/ffmpeg/include"; LibFfmpegFile="${SRS_OBJS}/ffmpeg/lib/libavcodec.a ${SRS_OBJS}/ffmpeg/lib/libswresample.a ${SRS_OBJS}/ffmpeg/lib/libavutil.a"
|
LibFfmpegRoot="${SRS_OBJS}/ffmpeg/include"
|
||||||
if [[ $SRS_CROSS_BUILD != YES ]]; then
|
LibFfmpegFile="${SRS_OBJS}/ffmpeg/lib/libavcodec.a ${SRS_OBJS}/ffmpeg/lib/libswresample.a ${SRS_OBJS}/ffmpeg/lib/libavutil.a"
|
||||||
|
if [[ $SRS_FFMPEG_OPUS != YES ]]; then
|
||||||
LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS}/opus/lib/libopus.a"
|
LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS}/opus/lib/libopus.a"
|
||||||
fi
|
fi
|
||||||
if [[ $SRS_SHARED_FFMPEG == YES ]]; then LibFfmpegFile="-L${SRS_OBJS}/ffmpeg/lib -lavcodec -lswresample -lavutil -L${SRS_OBJS}/opus/lib -lopus"; fi
|
if [[ $SRS_SHARED_FFMPEG == YES ]]; then
|
||||||
|
LibFfmpegFile="-L${SRS_OBJS}/ffmpeg/lib -lavcodec -lswresample -lavutil";
|
||||||
|
if [[ $SRS_FFMPEG_OPUS != YES ]]; then
|
||||||
|
LibFfmpegFile="$LibFfmpegFile -L${SRS_OBJS}/opus/lib -lopus"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# openssl-1.1.0e, for the RTMP complex handshake.
|
# openssl-1.1.0e, for the RTMP complex handshake.
|
||||||
|
|
|
@ -8,6 +8,7 @@ The changelog for SRS.
|
||||||
|
|
||||||
## SRS 5.0 Changelog
|
## SRS 5.0 Changelog
|
||||||
|
|
||||||
|
* v5.0, 2023-01-05, FFmpeg: Support build with FFmpeg native opus. v5.0.131 (#3140)
|
||||||
* v5.0, 2023-01-05, CORS: Refine HTTP CORS headers. v5.0.130
|
* v5.0, 2023-01-05, CORS: Refine HTTP CORS headers. v5.0.130
|
||||||
* v5.0, 2023-01-03, Add blackbox test for HLS and MP3 codec. v5.0.129
|
* v5.0, 2023-01-03, Add blackbox test for HLS and MP3 codec. v5.0.129
|
||||||
* v5.0, 2023-01-02, Merge [#3355](https://github.com/ossrs/srs/pull/3355): Test: Support blackbox test by FFmpeg. v5.0.128
|
* v5.0, 2023-01-02, Merge [#3355](https://github.com/ossrs/srs/pull/3355): Test: Support blackbox test by FFmpeg. v5.0.128
|
||||||
|
|
|
@ -17,12 +17,12 @@ static const AVCodec* srs_find_decoder_by_id(SrsAudioCodecId id)
|
||||||
} else if (id == SrsAudioCodecIdMP3) {
|
} else if (id == SrsAudioCodecIdMP3) {
|
||||||
return avcodec_find_decoder_by_name("mp3");
|
return avcodec_find_decoder_by_name("mp3");
|
||||||
} else if (id == SrsAudioCodecIdOpus) {
|
} else if (id == SrsAudioCodecIdOpus) {
|
||||||
const AVCodec* codec = avcodec_find_decoder_by_name("libopus");
|
#ifdef SRS_FFMPEG_OPUS
|
||||||
if (!codec) {
|
// TODO: FIXME: Note that the audio might be corrupted, see https://github.com/ossrs/srs/issues/3140
|
||||||
// TODO: FIXME: Note that the audio might be corrupted, if use FFmpeg native opus.
|
return avcodec_find_decoder_by_name("opus");
|
||||||
codec = avcodec_find_decoder_by_name("opus");
|
#else
|
||||||
}
|
return avcodec_find_decoder_by_name("libopus");
|
||||||
return codec;
|
#endif
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ static const AVCodec* srs_find_encoder_by_id(SrsAudioCodecId id)
|
||||||
if (id == SrsAudioCodecIdAAC) {
|
if (id == SrsAudioCodecIdAAC) {
|
||||||
return avcodec_find_encoder_by_name("aac");
|
return avcodec_find_encoder_by_name("aac");
|
||||||
} else if (id == SrsAudioCodecIdOpus) {
|
} else if (id == SrsAudioCodecIdOpus) {
|
||||||
const AVCodec* codec = avcodec_find_encoder_by_name("libopus");
|
#ifdef SRS_FFMPEG_OPUS
|
||||||
if (!codec) {
|
// TODO: FIXME: Note that the audio might be corrupted, see https://github.com/ossrs/srs/issues/3140
|
||||||
// TODO: FIXME: Note that the audio might be corrupted, if use FFmpeg native opus.
|
return avcodec_find_encoder_by_name("opus");
|
||||||
codec = avcodec_find_encoder_by_name("opus");
|
#else
|
||||||
}
|
return avcodec_find_encoder_by_name("libopus");
|
||||||
return codec;
|
#endif
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 5
|
#define VERSION_MAJOR 5
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 130
|
#define VERSION_REVISION 131
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue