0

I am trying to convert the images to video with audio in the background in React Native. I had used ffmpeg but I am not getting the expected result. https://www.npmjs.com/package/react-native-ffmpeg Here is the code that I had tried!

RNFFmpeg.execute('-i http://192.168.43.4/ReactFirstProject/images/song.jpeg -i http://192.168.43.4/ReactFirstProject/screens/music/frog.wav -c:v mpeg4 output.mp4').then(result => (console.log("RESULT:",result)))

Can anyone suggest any other libraries for doing the same? Please help me out. I would be glad.

Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43

2 Answers2

0

Instead of suggesting another library I can give suggestions about your ffmpeg command:

ffmpeg -loop 1 -i http://192.168.43.4/ReactFirstProject/images/song.jpeg -i http://192.168.43.4/ReactFirstProject/screens/music/frog.wav -vf format=yuv420p -c:v libx264 -c:a aac -movflags +faststart -shortest output.mp4

Some assumptions are being made here given the lack of info provided ("not getting the expected result" isn't very informative), and the log from the ffmpeg command would have been very helpful.

I'm guessing you don't actually want the old, legacy, outdated MPEG-4 Part 2 video format so I changed the encoder to libx264 to output H.264 video.

I'm also assuming that song.jpeg has even values for width and height. Otherwise, see one of the many answers in FFmpeg: libx264 - height not divisible by 2.

llogan
  • 121,796
  • 28
  • 232
  • 243
0

Possible issues I faced with return code 1:

  1. output directory doesnot exist --> make sure directory exist before using ffmpeg (e.g create directory by RNFS.mkdir with react-native-fs, it will create dir if not exist and not return error if dir existed)
  2. output file already existing --> Use -y flag to overwrite existing file or prevent using same filename for output file.

Checkout FFmpeg Kit. I was using ffmpegkit but not react-native-ffmpeg, which is superseded by FFmpegKit.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 08 '21 at 07:23