我想在bash脚本中存储一个.ogg文件,然后在脚本中播放它。我试过:
\x置于十六进制的每两个字符之前,使用printf打印十六进制并将其放入ogg123 ( ogg player)中。\x置于十六进制的每两个字符之前,使用printf打印十六进制,将输出导入7za e -si,并将输出放入ogg123 ( ogg player)。这些都不管用。我所经历的最成功的方法是:
ogg123 <<< cat sound.ogg但是,我确实希望不将文件写入磁盘(希望将所有文件保存在我的脚本中),如果可能的话,不要使用变量来存储任何原始数据。
另一个问题是,ogg123不支持从stdin读取数据,因此我无法将任何原始的ogg数据输送到其中。
我尝试过的命令:(当然,十六进制和base64被截断了)
$ ogg123 <<< printf 'xae\x0f\x00\xad\x83' # .ogg data
/usr/local/bin/ogg123: Argument list too long
$ ogg123 <(printf 'xae\x0f\x00\xad\x83') # .ogg data
Error opening /dev/fd/63 using the oggvorbis module. The file may be corrupted.
$ S=<<SOUND
dGhpcyBiYXNlNjQgd291bGQgYmUgdGhlIGJhc2U2NCBvZiBteSBvZ2cgZmlsZQ==
SOUND
$ ogg123 <(echo $S | openssl base64 -d)
Error opening /dev/fd/63 using the oggvorbis module. The file may be corrupted.
$ ogg123 <<< echo $S | openssl base64 -d
5?w?k譸?我确实尝试过其他几个命令,但是我意外地退出了终端,这两个命令是保存在我的.bash_history中的唯一命令。不过,相信我,我所做的一切都无济于事(我已经在这上面花了3.5个小时,但没有成功)。
使用macOS High塞拉利昂10.13.6,bash 3.2.57(1)-release,ogg123 from vorbis-tools 1.4.0,7za 16.02 (x64),openssl base64 (LibreSSL 2.2.7)。
发布于 2019-07-11 20:48:41
不是一个完整的修复程序,但我确实让它使用了以下方法:
mplayer <(openssl base64 -d <<SND
dGhpcyBiYXNlNjQgd291bGQgYmUgdGhlIGJhc2U2NCBvZiBteSBvZ2cgZmlsZQ==
SND
)支持mplayer读取这样的原始数据(也可以从stdin!)
https://stackoverflow.com/questions/56979748
复制相似问题