PHP-FFMpeg / PHP-FFMpeg

An object oriented PHP driver for FFMpeg binary
MIT License
4.85k stars 888 forks source link

Cannot convert from mp4 to wav. Encoding failed error #800

Closed Fhyrel closed 3 years ago

Fhyrel commented 3 years ago

I cannot convert a mp4 file to wav. I'm working on Laravel. The strange thing is that i can convert the video in another video format like mkv or wmv, but not in audio (mp3 or wav).

Here is my code:

$converted = FFMpeg::fromDisk('news')
 ->open($video->file_path);
 $format = new Wav();
 $converted->save($format, '/public/storage/temp/');

This is the error reported by catch (EncodingException $exception):

exception: "FFMpeg\Exception\RuntimeException"
file: "**_PATH_**\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Media\AbstractVideo.php"
line: 106
message: "Encoding failed"

Using Laravel sintax:

 $converted = FFMpeg::fromDisk('news')
                        ->open($video->file_path)
                        ->export()
                        ->toDisk('temp')
                        ->inFormat(new \FFMpeg\Format\Audio\Wav())
                        ->save('test.wav');

Here is the error Log:

Error in GnuTLS initialization: Failed to acquire random data.
ffmpeg version 4.3.2-2021-02-27-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '**_FILEPATH_**':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf57.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 1569 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1566 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Output #0, wav, to '**_PATH_**/app/public/temp/test.wav':
Output file #0 does not contain any stream
Fhyrel commented 3 years ago

The error is generated from a file video without audio. Solved.