0

I am using FFMPEG for giving effects to video.

I tried to give effect to video using below commands.

ffmpeg -i Input1.mp4 -i Input2.mp4 -filter_complex xfade=transition=circleopen:duration=5:offset=0 OutPutVideo.mp4

My command runs fine but output video is not running even in VLC media player.

I got these commands from location: https://ottverse.com/crossfade-between-videos-ffmpeg-xfade-filter/

My videos are at location: https://drive.google.com/drive/folders/1SLsrRUjyGH3eM7Oe3cptU_YPkga7EoCO?usp=sharing

Please advise what is the issue?

Kind Regards,

Dan Mašek
  • 17,852
  • 6
  • 57
  • 85
D.B.
  • 89
  • 1
  • 8
  • Show the complete log from your ffmpeg command. – llogan May 11 '21 at 16:05
  • Please find the complete logs below. – D.B. May 11 '21 at 16:32
  • Please find the complete logs below. I have changed the offset to 302 as first video is of size 302 sec. See logs at url in log.txt: https://drive.google.com/file/d/12oogkvSbB36ooSU1OOa3oMGxvseIG3Gv/view?usp=sharing – D.B. May 11 '21 at 16:39

1 Answers1

2

It is outputting a non-compatible pixel format (yuv444p). Add the format filter to make it output yuv420p which is widely supported:

ffmpeg -i Input1.mp4 -i Input2.mp4 -filter_complex "[0:v][1:v]xfade=transition=circleopen:duration=5:offset=297,format=yuv420p;[0:a][1:a]acrossfade=d=5" OutPutVideo.mp4
llogan
  • 121,796
  • 28
  • 232
  • 243
  • Many Many thanks for this. There are some issues: My output video 00:05:10 min where as my first video is 5.02 min and next video is 5.10 min. After adding video the output I am expecting to be 10.13 It is taking first 2 sec of first video and rest it has taken from second video. The output video length is same as second video. I have uploaded output video with file name: OutPutVideo_111.mp4 https://drive.google.com/drive/folders/1SLsrRUjyGH3eM7Oe3cptU_YPkga7EoCO?usp=sharing Please advise. – D.B. May 11 '21 at 17:30
  • @D.B. Your command is automatically choosing the audio from the longest input, but your player may not like that the output video is longer than the audio. See updated answer. I added acrossfade to deal with the audio so the video and audio should have about the same length. I also fixed the xfade offset. See [Merging multiple video files with ffmpeg and xfade filter](https://stackoverflow.com/a/63570355/) for how to calculate offset. – llogan May 11 '21 at 17:39
  • Many Many thanks. It works great. I have One query on this. 1. The output video is of length 00:10:08. If I have to calculate the length of video programitacally then how will I come to length of video. I was expecting length of video to be 00:10:12 (First video: 00:05:02, Second video 00:05:10) Also, I wanted to give effects to multiple videos likewise you gave example. I tried and I am getting error. Posted another question on this at url: https://stackoverflow.com/questions/67492740/cannot-allocate-memory-ffmpeg Please advise. – D.B. May 11 '21 at 18:54
  • @D.B. The fade effect takes up some time, so the offset must be subtracted from the total, so in this example 00:05:02 + 00:05:10 - 00:00:05 = 00:10:07. I recommend deleting your new question and re-asking at [su]. Stack Overflow is nominally for programming questions only, and a particular user is constantly downvoting offtopic ffmpeg questions and answers here on Stack Overflow. It is why both of your questions and my answer all have -1. – llogan May 11 '21 at 19:11
  • Many Many thanks for your input. This was very helpful. New question posted at: https://superuser.com/questions/1648409/cannot-allocate-memory-ffmpeg – D.B. May 11 '21 at 19:43