tanersener / react-native-ffmpeg

FFmpeg for react-native. Not maintained anymore. Superseded by FFmpegKit.
GNU General Public License v3.0
400 stars 51 forks source link

RNFFMpeg.executeAsync: Unable to create gif of a video with space(s) in it's source path #252

Closed SyedShehrozSohail closed 3 years ago

SyedShehrozSohail commented 3 years ago

Description Unable to make gif of a video which has space(s) in it's source directory. All the other video which don't have space(s), their gif is making fine. I had a video whose folder name had space and it was not making gif for it. I copied the same video to a folder without space in it's name, and it made gif for it successfully. Code snippet

RNFFmpeg.executeAsync(
          `-i ${source} -ss ${start} -t ${gifDuration}  -vf "fps=5,scale=160:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ${destination}`, (completedExecution) => {
            if (completedExecution.returnCode === 0) {
              resolve({ path: destination });
            } else {
              resolve({ error: "invalid Gif" });  // always this part executes for videos with space in their source path
            }
          }
        );

Expected behavior Regardless a video has or has not a space in it's path, it should make gif correctly and completedExecution.returnCode should be 0

Current behavior Currently, for all the videos having space in their source path, completedExecution.returnCode is always 1

Logs of the same video without space in folder name [Wed Jul 07 2021 12:23:56.377] LOG file:///storage/emulated/0/AirDroid/VID-20210620-WA0024.mp4 [Wed Jul 07 2021 12:23:56.511] LOG [Parsed_palettegen_3 @ 0x7d62eb5ec0] 255(+1) colors generated out of 249823 colors; ratio=0.001021 [Wed Jul 07 2021 12:23:56.672] LOG video:48kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: [Wed Jul 07 2021 12:23:56.673] LOG 0.041083% [Wed Jul 07 2021 12:23:56.722] LOG {"path": "/data/user/0/com.tbox.pantry/cache/1625642625930.gif"}

Logs of the same video with space in folder name [Wed Jul 07 2021 12:20:45.577] LOG file:///storage/emulated/0/FMWhatsApp/Media/FMWhatsApp Video/VID-20210620-WA0024.mp4 [Wed Jul 07 2021 12:20:45.998] LOG file:///storage/emulated/0/FMWhatsApp/Media/FMWhatsApp: No such file or directory [Wed Jul 07 2021 12:20:45.998] LOG Conversion failed! [Wed Jul 07 2021 12:20:45.999] LOG {"error": "invalid Gif"}

Environment

tanersener commented 3 years ago

Please try wrapping your paths with double quotes.

SyedShehrozSohail commented 3 years ago

@tanersener did you mean resolve({ "path": destination }); or -i "${source}" -ss ${start} -t ${gifDuration} -vf "fps=5,scale=160:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "${destination}" ?

tanersener commented 3 years ago

I'm talking about the command. "${source}" should fix your issue about space characters.

SyedShehrozSohail commented 3 years ago

Yes @tanersener , it fixes my issue. Thanks