首页 > 解决方案 > 为什么ffmpeg php转换0字节为空

问题描述

我正在尝试使用 php 和 ffmpeg 将 .wav 文件转换为 .ogg。ogg 文件一直被创建为 0 字节:

<?php
$ffmpeg = "/usr/local/bin/ffmpeg";
shell_exec("$ffmpeg -y -i clip.wav clip.ogg");
?>

我已经为 ogg 文件尝试了各种参数,但都没有。这个简单的转换应该有效,但它没有。

这是日志:

ffmpeg started on 2020-04-08 at 22:11:58
Report written to "ffmpeg-20200408-221158.log"
Command line:
/usr/local/bin/ffmpeg -y -i clip.wav clip.ogg -report
ffmpeg version N-71954-gbc6f84f Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
configuration: --prefix=/usr --enable-version3 --enable-gpl --enable-shared - 
-enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libvpx -- 
enable-libx264 --enable-libxvid --enable-libopencore-amrwb --enable- 
libopencore-amrnb --enable-postproc --enable-nonfree --enable-pthreads -- 
enable-x11grab --enable-libfaac --enable-libopenjpeg --enable-zlib --disable- 
doc
libavutil      54. 23.101 / 54. 23.101
libavcodec     56. 37.101 / 56. 37.101
libavformat    56. 31.102 / 56. 31.102
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5. 16.101 /  5. 16.101
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with 
argument '1'.
Reading option '-i' ... matched as input file with argument 'clip.wav'.
Reading option 'clip.ogg' ... matched as output file.
Reading option '-report' ... matched as option 'report' (generate a report) 
with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file clip.wav.
Successfully parsed a group of options.
Opening an input file: clip.wav.
[wav @ 0xe2fee0] Format wav probed with size=2048 and score=99
[wav @ 0xe2fee0] Before avformat_find_stream_info() pos: 44 bytes read:32768 
seeks:0
[wav @ 0xe2fee0] parser not found for codec pcm_s16le, packets or times may 
be invalid.
[wav @ 0xe2fee0] probing stream 0 pp:14
[wav @ 0xe2fee0] probing stream 0 pp:13
[wav @ 0xe2fee0] probing stream 0 pp:12
[wav @ 0xe2fee0] probing stream 0 pp:11
[wav @ 0xe2fee0] probing stream 0 pp:10
[wav @ 0xe2fee0] probing stream 0 pp:9
[wav @ 0xe2fee0] probing stream 0 pp:8
[wav @ 0xe2fee0] probing stream 0 pp:7
[wav @ 0xe2fee0] probing stream 0 pp:6
[wav @ 0xe2fee0] probing stream 0 pp:5
[wav @ 0xe2fee0] probing stream 0 pp:4
[wav @ 0xe2fee0] probing stream 0 pp:3
[wav @ 0xe2fee0] probing stream 0 pp:2
[wav @ 0xe2fee0] probing stream 0 pp:1
[wav @ 0xe2fee0] probed stream 0
[wav @ 0xe2fee0] parser not found for codec pcm_s16le, packets or times may 
be invalid.
[wav @ 0xe2fee0] All info found
[wav @ 0xe2fee0] After avformat_find_stream_info() pos: 204844 bytes 
read:213916 seeks:0 frames:50
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, wav, from 'clip.wav':
Duration: 00:00:01.11, bitrate: 1536 kb/s
Stream #0:0, 50, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 
Hz, 2 channels, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output file clip.ogg.
Successfully parsed a group of options.
Opening an output file: clip.ogg.
Successfully opened the file.
detected 32 logical cores
[AVFilterGraph @ 0xe25560] Error initializing threading.
[AVFilterGraph @ 0xe25560] Error creating filter 'anull'
Error opening filters!
[AVIOContext @ 0xe72180] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0xe2f560] Statistics: 213916 bytes read, 0 seeks

标签: phpffmpeg

解决方案


推荐阅读