Eu tenho uma entrada de áudio e vídeo para transcodificar em libx264
e libfdk_aac
.
Para fazer isso, preparei esta frase ffmpeg:
ffmpeg -i temp/filename.wav -i temp/filename.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -map 0:0 -map 1:0 -fflags +genpts -vcodec libx264 -threads 0 -b:a 128k temp/filename.mp4'
Por qualquer motivo, a sentença funciona quando eu a executo diretamente no console, mas se eu a executar usando php, ela não funciona por nenhum motivo.
Alguém poderia me ajudar a identificar qual poderia ser o problema?
Obrigado por conselhos.
EDIT 1
Eu atualizei a sentença ffmpeg para esta devido a um erro com o libfdk_aac.
ffmpeg -i temp/filename.wav -i temp/filename.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -map 0:0 -map 1:0 -fflags +genpts -c:v libx264 -preset ultrafast -qp 0 -c:a libvo_aacenc -b:a 128k temp/filename.mp4'
Atendendo à solicitação de ely Estou postando todas as etapas para o processo:
Um arquivo JavaScript captura o vídeo e o áudio com mediastream (ambos separados da camara e do microfone) e eu os carrego para o servidor via AJAX em um formData (script php):
function uploadVideo(url, data, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
callback(xhr.responseText);
}
};
xhr.open('POST', url);
xhr.send(data);
}
function upload() {
var formData = new FormData(), path,audioBlob, videoBlob;
path = 'video/chromeAnswer';
formData.append('filename', video_temp_name);
formData.append('audio-blob', source.recordRTC[0].getBlob());
formData.append('video-blob', source.recordRTC[1].getBlob());
uploadVideo(path, formData, function (ffmpeg_output) {
window.console.log(ffmpeg_output);
});
}
Mova o vídeo para uma pasta de instâncias temporárias de instância do Azure da instância e processe-o com a próxima função:
public function chromeFFmpeg($filename) {
$cmd = 'ffmpeg -i temp/filename.wav -i temp/filename.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -map 0:0 -map 1:0 -fflags +genpts -vcodec libx264 -threads 0 -b:a 128k temp/filename.mp4'
exec(escapeshellcmd($cmd), $out, $return);
unlink(TEMP . $filename . '.webm');
unlink(TEMP . $filename . '.wav');
if ($return === false)
{
return false;
}
return true;
}
O processo é concluído corretamente e não há registros de erros. No entanto, também estou colando a análise ffprobe
para o vídeo .webm
, o .wav
audio e o .mp4
result:
ffmpeg version 2.7.3-0ubuntu0.15.10.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=$
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-g$
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, matroska,webm, from '../project/temp/92.webm':
Metadata:
encoder : whammy
Duration: 00:00:02.21, start: 0.000000, bitrate: 1408 kb/s
Stream #0:0: Video: vp8, yuv420p, 221x221, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn, 1k tbc (default)
At least one output file must be specified
[Wed Dec 16 20:44:09.121995 2015] [:error] [pid 5958] [client 130.117.93.205:47172] PHP Notice: Undefined offset: 1 in /var/www/html/dev1/project/models$
[Wed Dec 16 20:44:09.122037 2015] [:error] [pid 5958] [client 130.117.93.205:47172] PHP Notice: Undefined offset: 1 in /var/www/html/dev1/project/models$
[Wed Dec 16 20:44:09.122043 2015] [:error] [pid 5958] [client 130.117.93.205:47172] PHP Notice: Undefined offset: 2 in /var/www/html/dev1/project/models$
ffmpeg version 2.7.3-0ubuntu0.15.10.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=$
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-g$
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, matroska,webm, from '../project/temp/92.webm':
Metadata:
encoder : whammy
Duration: 00:00:02.21, start: 0.000000, bitrate: 1408 kb/s
Stream #0:0: Video: vp8, yuv420p, 221x221, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn, 1k tbc (default)
[swscaler @ 0x21c7d40] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '../project/temp/92.jpg':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Video: mjpeg, yuvj420p(pc), 221x221 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 1k fps, 1k tbn, 1k tbc (default)
Metadata:
encoder : Lavc56.41.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=3.7 Lsize=N/A time=00:00:00.02 bitrate=N/A
video:6kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffmpeg version 2.7.3-0ubuntu0.15.10.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=$
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-g$
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from '../project/temp/92.wav':
Duration: 00:00:02.23, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Input #1, matroska,webm, from '../project/temp/92.webm':
Metadata:
encoder : whammy
Duration: 00:00:02.21, start: 0.000000, bitrate: 1408 kb/s
Stream #1:0: Video: vp8, yuv420p, 221x221, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn, 1k tbc (default)
[libx264 @ 0x7f5080] using SAR=1/1
[libx264 @ 0x7f5080] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7f5080] profile High 4:4:4 Predictive, level 3.2, 4:2:0 8-bit
[libx264 @ 0x7f5080] 264 - core 146 r2555 0c21480 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 r$
Output #0, mp4, to '../project/temp/92.mp4':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
Metadata:
encoder : Lavc56.41.100 libvo_aacenc
Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 220x220 [SAR 1:1 DAR 1:1], q=-1--1, 1k fps, 16k tbn, 1k tbc (default)
Metadata:
encoder : Lavc56.41.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> aac (libvo_aacenc))
Stream #1:0 -> #0:1 (vp8 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 304 fps=0.0 q=0.0 size= 287kB time=00:00:00.33 bitrate=7011.9kbits/s dup=292 drop=0 ^Mframe= 665 fps=621 q=0.0 size= 574kB time=00:0$
video:1893kB audio:36kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.600680%
[libx264 @ 0x7f5080] frame I:9 Avg QP: 0.00 size: 26600
[libx264 @ 0x7f5080] frame P:2201 Avg QP: 0.00 size: 772
[libx264 @ 0x7f5080] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x7f5080] mb P I16..4: 1.5% 0.0% 0.0% P16..4: 1.5% 0.0% 0.0% 0.0% 0.0% skip:97.0%
[libx264 @ 0x7f5080] coded y,uvDC,uvAC intra: 98.6% 97.2% 97.0% inter: 1.5% 1.6% 1.6%
[libx264 @ 0x7f5080] i16 v,h,dc,p: 34% 65% 0% 0%
[libx264 @ 0x7f5080] i8c dc,h,v,p: 2% 61% 38% 0%
[libx264 @ 0x7f5080] kb/s:7014.78
O principal problema é que o vídeo está congelando.