gpt4 book ai didi

ffmpeg - 如何从url录制aac音频?

转载 作者:行者123 更新时间:2023-12-04 22:46:16 25 4
gpt4 key购买 nike

我通过发送此命令成功地从似乎是 mp3 源的 URL 录制音频。

$ ffmpeg -y -t "00:01:00" -i $url1 -c copy url1.mp3
ffmpeg version N-93762-ge384f6f2f9 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7.4.0 (GCC)
configuration:
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 52.100 / 58. 52.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 50.100 / 7. 50.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
Input #0, mp3, from 'http://someurl1:1234':

现在,当我尝试从另一个似乎是 AAC 音频源的 URL 进行录制时,出现错误。

$ ffmpeg -y -t "00:01:00" -i $url2 -c copy url2.mp3
ffmpeg version N-93762-ge384f6f2f9 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7.4.0 (GCC)
configuration:
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 52.100 / 58. 52.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 50.100 / 7. 50.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
Input #0, aac, from 'http://someurl2:1234':
Metadata:
icy-notice1 : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2 : SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
icy-name : some name
icy-genre : Talk
icy-br : 48
icy-sr : 22050
icy-url :
icy-pub : 0
StreamTitle : some title
Duration: N/A, bitrate: 47 kb/s
Stream #0:0: Audio: aac (HE-AACv2), 44100 Hz, stereo, fltp, 47 kb/s
[mp3 @ 0x80003c280] Invalid audio stream. Exactly one MP3 audio stream is required.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Last message repeated 1 times

如果我尝试将其保存为 aac 文件,我会收到以下消息:

$ ffmpeg -y -t "00:01:00" -i $url2 -c copy url2.aac
ffmpeg version N-93762-ge384f6f2f9 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7.4.0 (GCC)
configuration:
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 52.100 / 58. 52.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 50.100 / 7. 50.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
Input #0, aac, from 'http://someurl2:1234':
Metadata:
icy-notice1 : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2 : SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
icy-name : some name
icy-genre : Talk
icy-br : 48
icy-sr : 22050
icy-url :
icy-pub : 0
StreamTitle : some title
Duration: N/A, bitrate: 48 kb/s
Stream #0:0: Audio: aac (HE-AACv2), 44100 Hz, stereo, fltp, 48 kb/s
Output #0, adts, to 'url2.aac':
Metadata:
icy-notice1 : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2 : SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
icy-name : some name
icy-genre : Talk
icy-br : 48
icy-sr : 22050
icy-url :
icy-pub : 0
StreamTitle : some title
encoder : Lavf58.27.103
Stream #0:0: Audio: aac (HE-AACv2), 44100 Hz, stereo, fltp, 48 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

当URL中的源音频是aac时如何录制?有没有办法在录制之前识别是mp3还是aac?提前致谢

最佳答案

在您的第一个命令中,使用 -c copy 是错误的,因为您需要从 aac (HE-AACv2) 重新编码为 mp3 .

参见 ffmpeg documentation :

a special value copy (output only) to indicate that the stream is not to be re-encoded

我建议你尝试一下:

ffmpeg -y -t "00:01:00" -i [stream URL] -codec:a libmp3lame output.mp3

不幸的是,我无法根据您在评论中提供的 URL 对其进行测试(http://dreamsiteradiocp4.com:8120/: 连接被拒绝),但它成功地与列出的 AAC 流配合使用fmstream.org .

引用:video.stackexchange.com

关于ffmpeg - 如何从url录制aac音频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63108442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com