我希望有人可以帮我解决这个问题。 我有一种情况需要将音频文件添加到已经开发的FLA文件中。 要做到这一点 - 我必须打开fla文件,创建一个新图层,将音频剪辑拖动到该图层,将所有图层扩展到音频剪辑的末尾,然后添加一个停止。
我希望使用JSFL为我做这件事。 我现在有它可以在库中选择音频剪辑,并运行我的JSFL脚本。 我将该声音剪辑添加到新图层。 它创建另一个图层并在最后一帧添加一个停止点。 我也可以扩展所有层,但我想要的帧数。 我的问题是我似乎无法弄清楚如何获得声音片段的长度,所以我知道延长所有层的时间。
任何帮助都会很棒。
由于
答案 0 :(得分:0)
快速查看JSFL documentation(pdf链接),您只有少数可用的属性:
Property Description
soundItem.bitRate A string that specifies the bit rate of a sound in the library. Available only for the MP3 compression type.
soundItem.bits A string that specifies the bits value for a sound in the library that has ADPCM compression.
soundItem.compressionType A string that specifies the compression type for a sound in the library.
soundItem.convertStereoToMono A Boolean value available only for MP3 and Raw compression types.
soundItem.fileLastModifiedDate Read-only; a string containing a hexadecimal number that represents the number of seconds that have elapsed between January 1, 1970, and the modification date of the original file (on disk) at the time the file was imported to the library.
soundItem.originalCompressionType Read-only; a string that specifies whether the specified item was imported as an MP3 file.
soundItem.quality A string that specifies the playback quality of a sound in the library. Available only for the MP3 compression type.
soundItem.sampleRate A string that specifies the sample rate for the audio clip.
soundItem.sourceFileExists Read-only; a Boolean value that specifies whether the file that was imported to the Library still exists in the location from where it was imported.
soundItem.sourceFileIsCurrent Read-only; a Boolean value that specifies whether the file modification date of the Library item is the same as the modification date on disk of the file that was imported.
soundItem.sourceFilePath Read-only; a string, expressed as a file:/// URI, that represents the path and name of the file that was imported into the Library.
soundItem.useImportedMP3Quality A Boolean value; if true, all other properties are ignored, and the imported MP3 quality is used
目前我只能想到几个hacky解决方法......两个版本中的一个:
FLfile.runCommandLine()
。命令行工具的一些示例是ffmpeg(例如ffmpeg -i yourAudioFile
)或MediaInfo。我相信那里还有其他人。这取决于您需要使用的操作系统以及是否可以轻松安装该工具。理想情况下,您将使用仅输出持续时间的内容,但如果您获得更多数据,则应该能够解析输出并获得持续时间。另请注意,该函数将返回1表示成功执行,否则返回0,因此您需要有一个命令,该命令也会将输出写入您可以使用jsfl读取的文本文件。
答案 1 :(得分:0)
如果您的音频文件使用恒定比特率进行编码,则最终可以使用FLfile.getSize()
方法获取文件的长度并计算其持续时间。
这是一个jsfl片段,用于计算并显示图书馆每个声音的帧持续时间:
var dom = fl.getDocumentDOM();
var lib = dom.library;
var soundsBitRate = 705;//specify here the bitrate of your files in Kbits/s
for (i = 0; i < lib.items.length; i++) {
if (lib.items[i].itemType == "sound") {
alert ("Duration of "+ lib.items[i].name + " : " + Math.ceil(FLfile.getSize(lib.items[i].sourceFilePath) / (soundsBitRate/8) / 1000 * dom.frameRate)+ " frames");
}
}