|
|
@@ -66,6 +66,12 @@ interface FFprobeStream {
|
|
|
sample_rate?: string; // 采样率
|
|
|
bit_rate?: string; // 比特率
|
|
|
disposition?: StreamDisposition; // 添加disposition属性
|
|
|
+
|
|
|
+ bits_per_raw_sample?: string; // 位深
|
|
|
+ channels?: string; // 声道数
|
|
|
+ channel_layout?: string; // 声道布局
|
|
|
+ start_time?: string; // 起始播放
|
|
|
+
|
|
|
}
|
|
|
|
|
|
interface StreamDisposition {
|
|
|
@@ -811,22 +817,29 @@ export class Utility {
|
|
|
},
|
|
|
}).then(async () => {
|
|
|
try {
|
|
|
- let videoItem:VideoItem = new VideoItem('',inputPath,inputPath,type,0,'')
|
|
|
const metadata: FFprobeMetadata = JSON.parse(outputJson);
|
|
|
const format = metadata.format;
|
|
|
console.log(`onecold outputJson:${outputJson}`);
|
|
|
let file = fs.openSync(inputPath, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE)
|
|
|
console.info('readMetaInfoFFmpeg asset file.path: ', file.path);
|
|
|
- videoItem = new VideoItem(file.name,inputPath,inputPath,type,0,'')
|
|
|
+ let videoItem = new VideoItem(file.name,inputPath,inputPath,type,0,'')
|
|
|
await fs.stat(file.fd).then(async (stat: fs.Stat) => {
|
|
|
|
|
|
// 获取音频流的采样率
|
|
|
- let sampleRate = '';
|
|
|
+ let sampleRate:string|undefined = '';
|
|
|
+ let bits_per_raw_sample:string|undefined = '';
|
|
|
+ let channels:string|undefined = '';
|
|
|
+ let channel_layout:string|undefined = '';
|
|
|
+ let start_time:string|undefined = '';
|
|
|
if (metadata.streams && metadata.streams.length > 0) {
|
|
|
// 查找第一个音频流
|
|
|
const audioStream = metadata.streams.find(stream => StrUtil.isNotEmpty(stream.sample_rate));
|
|
|
- if (audioStream&&audioStream.sample_rate) {
|
|
|
+ if (audioStream) {
|
|
|
sampleRate = audioStream.sample_rate;
|
|
|
+ bits_per_raw_sample = audioStream.bits_per_raw_sample
|
|
|
+ channel_layout = audioStream.channel_layout
|
|
|
+ channels = audioStream.channels
|
|
|
+ start_time = audioStream.start_time
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -889,6 +902,12 @@ export class Utility {
|
|
|
videoItem.lyricContent = tags.LYRICS || tags.lyrics || tags.USLT || tags.UNSYNCEDLYRICS || '';
|
|
|
videoItem.genre = tags.genre||tags.GENRE|| Utility.resourceToString(context, $r('app.string.unknown'));
|
|
|
videoItem.track = tags.track||tags.TRACK|| Utility.resourceToString(context, $r('app.string.unknown'));
|
|
|
+
|
|
|
+ videoItem.bits_per_raw_sample = bits_per_raw_sample ||'1'
|
|
|
+ videoItem.channel_layout = channel_layout || ''
|
|
|
+ videoItem.channels = channels ||'0'
|
|
|
+ videoItem.start_time = start_time || '00:00'
|
|
|
+
|
|
|
videoItem.mimeType = format.format_name
|
|
|
// 检查是否有封面图片流
|
|
|
const hasCover = metadata.streams.some(stream =>
|