【发布时间】:2018-02-26 10:31:41
【问题描述】:
我有一个 C++ 应用程序,它从我的默认输入设备录制音频,以 AAC 格式对其进行编码并写入 .aac 文件。我想使用 HTTP Live Streaming 来直播这个 AAC 文件。根据this question,我必须创建一个FFMPEG 脚本来将我的音频文件拆分为几个.ts 文件。
# bitrate, width, and height, you may want to change this
BR=512k
WIDTH=432
HEIGHT=240
input=${1}
# strip off the file extension
output=$(echo ${input} | sed 's/\..*//' )
# works for most videos
ffmpeg -y -i ${input} -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s ${WIDTH}x${HEIGHT} -vcodec libx264 -b ${BR} -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 0 -refs 0 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate ${BR} -bufsize ${BR} -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 30 -qmax 51 -qdiff 4 -level 30 -aspect ${WIDTH}:${HEIGHT} -g 30 -async 2 ${output}-iphone.ts
(在我的情况下略有不同,因为我只处理音频)
我可以在 C++ 中以编程方式执行此操作吗?如果可以,我是否必须使用第三方库或 macOS 是否提供本机函数来执行此操作?
【问题讨论】:
标签: macos ffmpeg http-live-streaming