python - 无法使用 ffmpeg 从 mp4 文件创建音频文件

标签 python ffmpeg

我无法使用 ffmpeg 从 mp4 文件创建单声道音频文件,使用以下 python 代码

command_line = "ffmpeg -i "+full_file_path+" -ac 1 -ar 16000  -vn "+full_file_path[:-4]+".wav"        
args = shlex.split(command_line)
这是我的 mp4 文件的媒体信息
from pydub.utils import mediainfo
print(mediainfo(full_file_path))

Output

{'index': '0', 'codec_name': 'h264', 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'profile': 'High', 'codec_type': 'video', 'codec_time_base': '1/48', 'codec_tag_string': 'avc1', 'codec_tag': '0x31637661', 'width': '1920', 'height': '1080', 'coded_width': '1920', 'coded_height': '1088', 'has_b_frames': '2', 'sample_aspect_ratio': '1:1', 'display_aspect_ratio': '16:9', 'pix_fmt': 'yuv420p', 'level': '40', 'color_range': 'unknown', 'color_space': 'unknown', 'color_transfer': 'unknown', 'color_primaries': 'unknown', 'chroma_location': 'left', 'field_order': 'unknown', 'timecode': 'N/A', 'refs': '1', 'is_avc': 'true', 'nal_length_size': '4', 'id': 'N/A', 'r_frame_rate': '24/1', 'avg_frame_rate': '24/1', 'time_base': '1/12288', 'start_pts': '0', 'start_time': '0.000000', 'duration_ts': '107520', 'duration': '8.750000', 'bit_rate': '1036420', 'max_bit_rate': 'N/A', 'bits_per_raw_sample': '8', 'nb_frames': '210', 'nb_read_frames': 'N/A', 'nb_read_packets': 'N/A', 'DISPOSITION': {'default': '1', 'dub': '0', 'original': '0', 'comment': '0', 'lyrics': '0', 'karaoke': '0', 'forced': '0', 'hearing_impaired': '0', 'visual_impaired': '0', 'clean_effects': '0', 'attached_pic': '0', 'timed_thumbnails': '0'}, 'TAG': {'language': 'und', 'handler_name': 'VideoHandler', 'major_brand': 'isom', 'minor_version': '512', 'compatible_brands': 'isomiso2avc1mp41', 'encoder': 'Lavf58.26.101'}, 'filename': './sample_dataset_FaceForensic/fake/abc.mp4', 'nb_streams': '1', 'nb_programs': '0', 'format_name': 'mov,mp4,m4a,3gp,3g2,mj2', 'format_long_name': 'QuickTime / MOV', 'size': '1133585', 'probe_score': '100'}

最佳答案

您的 MP4 文件没有音频,所以 ffmpeg无法从中提取任何音频。

关于python - 无法使用 ffmpeg 从 mp4 文件创建音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64469292/

相关文章:

python - 在python中导入全局命名空间

ffmpeg - 通过将 SDP 文件作为内联数据传递来加入 ffmpeg 中的视频流

powershell - 批处理脚本期间重启环境和脚本

python - 如何忽略传递给数据类的额外参数?

python - Python 中最长的递增子序列(For vs While 循环)

python - PySpark DataFrame 上的 Sum 操作在类型正常时给出 TypeError

select - FFMPEG场景检测: overlay original frame number

linux - RTMP_ReadPacket,读取RTMP包头失败 rtmp ://a. rtmp.youtube.com/live2: Unknown error occurred

ruby-on-rails - ffmpeg 转换为 flash 文件

python - Pyside 在 QtabWidget 中获取小部件