gpt4 book ai didi

python - 如何找出使用ffmpeg和python提取音轨的文件扩展名?

转载 作者:行者123 更新时间:2023-11-28 19:08:13 25 4
gpt4 key购买 nike

我希望我的 python 程序在不更改音频编解码器的情况下从各种视频文件中提取音轨。为此,我调用以下命令:

ffmpeg -i "input" -vn -acodec copy "output.???"

然而,这仅在输出文件的文件扩展名已知的情况下有效。有没有办法找出对应的文件扩展名?

最佳答案

可以使用ffprobe返回音频信息:

ffprobe videofilexample.mp4 会返回如下内容:

ffprobe version 4.0 Copyright (c) 2007-2018 the FFmpeg developers
built with gcc 8.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tidalsunday3-2018-05-20_19.43.45':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:44:13.40, start: 0.000000, bitrate: 1035 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 782 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 247 kb/s (default)
Metadata:
handler_name : SoundHandler

关于python - 如何找出使用ffmpeg和python提取音轨的文件扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44123532/

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