ffmpeg conversão para MP4 não funciona

1
Eu sou um novato quando se trata de FFMPEG (com php), mas eu tenho estudado sobre isso nas últimas duas semanas. quando eu uso comandos shell como:

echo shell_exec('ffmpeg -i input.3gp output.ogg');

ou

echo shell_exec('ffmpeg -i input.flv output.ogv');

tudo funciona bem, mas quando eu uso um comando como:

echo shell_exec('ffmpeg -i input.flv output.mp4');

Eu recebo uma saída.mp4 com 0 bytes (recipiente vazio eu estou supondo),

Se eu tentar:

echo shell_exec("ffmpeg -i input.3gp  -c:a copy -c:v copy output.mp4");

Eu recebo um output.mp4 com 32 bytes (outro container, quase vazio, eu estou supondo?),

Se eu tentar:

echo shell_exec('ffmpeg -i input.flv -an output.mp4');

Eu recebo vídeo (sem áudio, é claro) e, se eu tentar:

echo shell_exec('ffmpeg -i input.flv -vn output.mp4');

Eu recebo áudio (sem vídeo, claro). Isso é bastante confuso para mim. Parece que não quer funcionar a menos que eu use -an, ou -vn.

Aqui está o relatório:

ffmpeg started on 2017-07-18 at 20:18:34
Report written to "ffmpeg-20170718-201834.log"
Command line:
ffmpeg -i small.flv outputTest.mp4 -report
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-opencl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --enable-libopencv --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'small.flv'.
Reading option 'outputTest.mp4' ... matched as output url.
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 report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url small.flv.
Successfully parsed a group of options.
Opening an input file: small.flv.
[file @ 0x16c3c00] Setting default whitelist 'file,crypto'
[flv @ 0x16c33c0] Format flv probed with size=2048 and score=100
[flv @ 0x16c33c0] Before avformat_find_stream_info() pos: 13 bytes read:32768 seeks:0 nb_streams:0
[flv @ 0x16c33c0] audio stream discovered after head already parsed
[flv @ 0x16c33c0] video stream discovered after head already parsed
[flv @ 0x16c33c0] All info found
[flv @ 0x16c33c0] Setting avg frame rate based on r frame rate
[flv @ 0x16c33c0] After avformat_find_stream_info() pos: 59830 bytes read:65536 seeks:0 frames:103
Input #0, flv, from 'small.flv':
  Metadata:
    encoder         : Lavf52.103.0
  Duration: 00:00:05.56, start: 0.000000, bitrate: 436 kb/s
    Stream #0:0, 62, 1/1000: Audio: mp3, 44100 Hz, mono, s16p, 62 kb/s
    Stream #0:1, 41, 1/1000: Video: flv1, yuv420p, 320x240, 25 fps, 25 tbr, 1k tbn
Successfully opened the file.
Parsing a group of options: output url outputTest.mp4.
Successfully parsed a group of options.
Opening an output file: outputTest.mp4.
[file @ 0x1741c80] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'video_size' to value '320x240'
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'time_base' to value '1/1000'
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:1 @ 0x16e6960] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:1 @ 0x16e6960] w:320 h:240 pixfmt:yuv420p tb:1/1000 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 0x16e7760] compat: called with args=[yuv420p|yuvj420p|yuv422p|yuvj422p|yuv444p|yuvj444p|nv12|nv16|nv21]
[format @ 0x16e7760] Setting 'pix_fmts' to value 'yuv420p|yuvj420p|yuv422p|yuvj422p|yuv444p|yuvj444p|nv12|nv16|nv21'
[AVFilterGraph @ 0x16c6640] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[graph 1 input from stream 0:0 @ 0x16e7c00] Setting 'time_base' to value '1/44100'
[graph 1 input from stream 0:0 @ 0x16e7c00] Setting 'sample_rate' to value '44100'
[graph 1 input from stream 0:0 @ 0x16e7c00] Setting 'sample_fmt' to value 's16p'
[graph 1 input from stream 0:0 @ 0x16e7c00] Setting 'channel_layout' to value '0x4'
[graph 1 input from stream 0:0 @ 0x16e7c00] tb:1/44100 samplefmt:s16p samplerate:44100 chlayout:0x4
[audio format for output stream 0:1 @ 0x16e84e0] Setting 'sample_fmts' to value 'fltp'
[audio format for output stream 0:1 @ 0x16e84e0] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[audio format for output stream 0:1 @ 0x16e84e0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
[AVFilterGraph @ 0x16e7e40] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x16eb700] [SWR @ 0x16ebac0] Using s16p internally between filters
[auto-inserted resampler 0 @ 0x16eb700] ch:1 chl:mono fmt:s16p r:44100Hz -> ch:1 chl:mono fmt:fltp r:44100Hz
[libx264 @ 0x16cb4a0] using mv_range_thread = 24
[libx264 @ 0x16cb4a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
Output #0, mp4, to 'outputTest.mp4':
  Metadata:
    encoder         : Lavf52.103.0
    Stream #0:0, 0, 0/0: Unknown: none
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Stream #0:1, 0, 0/0: Unknown: none
    Metadata:
      encoder         : Lavc57.48.101 aac
Stream mapping:
  Stream #0:1 -> #0:0 (flv1 (flv) -> h264 (libx264))
  Stream #0:0 -> #0:1 (mp3 (native) -> aac (native))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x1759280] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x16cbf80] Statistics: 65536 bytes read, 0 seeks
    
por Benjamin Hall 19.07.2017 / 01:56

0 respostas