0

I have an audio and video input that I have to transcode into libx264 and libfdk_aac.

To do that, I've prepared this ffmpeg sentence:

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'

For any reason, the sentence works when I execute it directly on the console, but if I execute it using php it doesn't work for any reason.

Could someone help me identifying what could be the problem?

Thanks in advice.

EDIT 1

I have updated the ffmpeg sentence to this one due to I got an error with the 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'

Attending to the request of ely I'm posting all the steps to do the process:

  1. A JavaScript file captures the video and audio with mediastream (both separated from the camara and the microphone) and I upload it to the server via AJAX packed into a formData (php script):

    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); }); }

  2. Move the video to a A2 azure instance temp instance folder and process it with the next function:

    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; }

The process finish correctly and there are no error logs, however I'm also pasting the ffprobe analysis for the .webm video, the .wav audio and the .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

The main problem is that the video is freezing.

2
  • What's weird is that ffmpeg reports the video to be running at 1000fps. Is that intended ? The result is 304 frames for a duration of only 33ms. Have you tried playing the separate .webm and .wav ? How do they look/sound ?
    – Ely
    Dec 18, 2015 at 6:29
  • Actually it isn't. I just pick the video and audio as it comes. What I've showed is a real webm . If I play both files in a separated way, they look normal and even synchronized! but mp4 messes all.. Dec 18, 2015 at 6:43

0

You must log in to answer this question.

Browse other questions tagged .