yangjie10930/EpMedia

failed to open file path with white spaces

knowamit opened this issue · 11 comments

Failed to open file having white spaces in file path. Tried to replace white space with %20 but not working.

/storage/emulated/0/download/My Video/Hello Hello_.mp4

I have updated version of EpMedia 0.9.5 still facing this issue, please help

Did you manage to solve this issue?

Try Uri.fromFile(new File(uriFi))

Please send logs only then I can suggest to you.

Actually i have found out the problem. The main problem is that my audio is shorter in length than video.
I am using this command to Merge Audio and Video With volume control

"-i " + FilePath.getPath(SavingActivity.this, MyApplication.getVideoUri()) + " -i " + FilePath.getPath(SavingActivity.this, MyApplication.getAudioUri()) + " -filter_complex [0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume="+ MyApplication.getVideoVolume() + "[a1];[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=" + MyApplication.getAudioVolume() + "[a2];[a1][a2]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[out] -c:v copy -map 0:v -map [out] -y " + destination.getAbsolutePath()

So if the audio length is longer then video, this command works perfectly and cuts the audio at the end of the video and makes a perfect video. But when the audio length is shorter then video, than this error comes.

(Logs)
I/FFmpeg_EpMedia: frame= 21 fps=0.0 q=-1.0 size= 19kB time=00:00:00.67 bitrate= 234.6kbits/s speed=1.35x
I/FFmpeg_EpMedia: frame= 56 fps= 56 q=-1.0 size= 49kB time=00:00:01.85 bitrate= 216.4kbits/s speed=1.85x
I/FFmpeg_EpMedia: frame= 98 fps= 65 q=-1.0 size= 108kB time=00:00:03.29 bitrate= 267.7kbits/s speed=2.19x
I/FFmpeg_EpMedia: frame= 150 fps= 75 q=-1.0 size= 151kB time=00:00:04.99 bitrate= 247.3kbits/s speed=2.48x
I/FFmpeg_EpMedia: frame= 213 fps= 85 q=-1.0 size= 204kB time=00:00:07.10 bitrate= 235.6kbits/s speed=2.83x
I/FFmpeg_EpMedia: frame= 281 fps= 93 q=-1.0 size= 263kB time=00:00:09.35 bitrate= 230.4kbits/s speed= 3.1x
E/FFmpeg_EpMedia: Error while filtering
Failed to inject frame into filter network: Out of memory
Error while processing the decoded data for stream #0:1

I/FFmpeg_EpMedia: Qavg: 441.719
W/FFmpeg_EpMedia: 2 frames left in the queue on closing
I/FFmpeg_EpMedia: Conversion failed!

as soon as the audio is finished, the command stops working and conversion failed come.

SO can you please help me in editing this command to make it working with shorter audios behind videos. ? I would be eternally grateful. Thanks

As per logs there out of memory error this can be device storage issue or filter problem.
But if the issue is related to audio length then there is no such command which can do this for you automatically. You have to do this manually.

  1. Calculate the length of video and audio.
  2. If audio length is smaller than video, you have to concatenate audio files in such a maths that it will become = or greater than video length. For example, if your video is of 2 mins and audio is of 1 min then you have to concatenate 2 audio files 1 min + 1 min = 2 min audio file and then apply that final audio in your command.
  3. To concatenate audio files you can use EpmediaMerge as well as any other custom command.

Hope this will solve your problem! Happy coding !!!

I have changed my command to this in order to avoid this problem.

String commandThen = "-i " + FilePath.getPath(SavingActivity.this, MyApplication.getVideoUri()) + " -filter_complex amovie=" + FilePath.getPath(SavingActivity.this, MyApplication.getAudioUri()) + ":loop=999,asetpts=N/SR/TB,aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.2[a1];[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a2];[a1][a2]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[out] -c:v copy -map 0:v -map [out] -y " + destination.getAbsolutePath();

Now it works as if the audio length is smaller, it is repeated again and again until the video is finished.

Now my problem is that i want the audio to simple end after it is finished and let the video play alone if the audio is finished before it. Can you help me in this brother?

If you don't want audio to be repeated then simple remove "shortest" from the following command :

This command will do the rest

String[] complexCommandWithTrack = {"ffmpeg", "-y", "-i", inputVideoFile.mp4, "-i", inputAudio.mp3, "-c:v", "copy", "-filter_complex", "[0:a]aformat=fltp:44100:stereo,volume=2,apad[0a];[1]aformat=fltp:44100:stereo,volume=2,[1a];[0a][1a]amerge[a]", "-map", "0:v", "-map", "[a]", "-ac", "2", "-shortest", outfile.mp4};

Made it work by editing it a little to be used in EpMedia

This is the command I Used

String commandThen = "-i " + FilePath.getPath(SavingActivity.this, MyApplication.getVideoUri()) + " -i " + FilePath.getPath(SavingActivity.this, MyApplication.getAudioUri()) + " -filter_complex [0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume="+ MyApplication.getVideoVolume() + "[a1];[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=" + MyApplication.getAudioVolume() + ",apad[a2];[a1][a2]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[out] -c:v copy -map 0:v -map [out] -y " + destination.getAbsolutePath();

Thanks A lot brother. You have made my life easy. Thanks again. Happy Coding