1

I'm using FFmpeg to convert and compress a video. Everything converts/compresses fine, but my video has no sound when I try to play it on a mobile device. But it has sound when I play it on a desktop. I don't know if this has to do with the codec that I am using, I don't know. Can someone help me? I appreciate it. Thank you.

The format that I am using in FFmpeg:

$request->video->move(public_path('/app'), $filename);
        $name_file=uniqid().'intro_video.mp4';
     $ffp=FFMpeg::open($filename)
->addFilter(function ($filters) {
    $filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new \FFMpeg\Format\Audio\Aac)
->save($name_file);

2 Answers2

0

For FFmpeg version 4.0 you need to change the code from

inFormat(new \FFMpeg\Format\Audio\Aac)

to

inFormat(new \FFMpeg\Format\Video\X264('aac', 'libx264'))

I hope this helps.

0
    // Audio compress
    $inputAudio = public_path('/audio/myaudio.mp3');
    $outputAudio = public_path('/output/outputAudio.mp3');
    exec("ffmpeg -i $inputAudio -ab 64 $outputAudio");

    // Video compress
    $inputVideo = public_path('/video/myvideo.mp4');
    $outputVideo = public_path('/output/outputVideo.mp4');
    exec("ffmpeg -i $inputVideo -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 $outputVideo");

For reference https://ostechnix.com/20-ffmpeg-commands-beginners/

also run this command

sudo apt install ffmpeg

aakash rajput
  • 81
  • 1
  • 3