ffmpeg 查看音频轨道时长
时间: 2023-07-01 16:15:29 浏览: 60
要查看音频轨道时长,可以使用以下命令:
```
ffmpeg -i input.mp4 -map 0:a -c copy -f null -
```
其中:
- `-i input.mp4`:指定输入文件为 `input.mp4`。
- `-map 0:a`:只选择第一个输入文件中的音频流。
- `-c copy`:选择音频编码为原始编码,不进行转码。
- `-f null`:指定输出格式为 null,即不输出实际的媒体文件。
- `-`:表示输出到标准输出。
执行该命令后,会输出类似以下的信息:
```
...
[aac @ 0x7f9f9a023000] Qavg: 229.926
Last message repeated 1 times
[aac @ 0x7f9f9a023000] 2 frames left in the queue on closing
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2021-08-18T13:55:41.000000Z
com.android.version: 12
Duration: 00:00:10.07, start: 0.000000, bitrate: 1502 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 1375 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2021-08-18T13:55:41.000000Z
handler_name : VideoHandle
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 123 kb/s (default)
Metadata:
creation_time : 2021-08-18T13:55:41.000000Z
handler_name : SoundHandle
...
```
其中,`Duration` 行的信息即为音频轨道的时长。例如上述输出中,音频轨道时长为 `00:00:10.07`。