Concatenation of two videos with a different frame rate using FFmpeg

I had a project that required some video processing features using FFMPEG. The app was created by another developer several years ago. The customer asked me to make video processing as faster as possible.

 

First of all, I've explored all FFMPEG commands and found the most difficult. I was trying ot do some optimization of these commands, but nothing helped. 

So than I decided to use GPU hardware acceleration. The app will run on PCs with different types of video cards. I've dicided to use OpenCL acceleration that supports all video cards procted after 2011.

 

Everything was perfect and the h264_qsv codec allowed me to have a good performance. But some combinations of video files become to rise errors in FFMPEG. There was "Current frame rate is unsupported" error message. This was strange because in other commands this frame rate was ok. Just this one command crashed:

 

ffmpeg -init_hw_device opencl:0.0 -filter_hw_device opencl0 -hwaccel opencl -threads 0 -hide_banner -loglevel panic -i "C:Users[username]AppDataLocalTemptmpD841.tmp" -i "C:Users[username]AppDataLocalTemptmp7CDE.tmp" -filter_complex "[0:v]trim=start=0:end=443.73,setpts=PTS-STARTPTS[firstclip]; [1:v]trim=start=2,setpts=PTS-STARTPTS[secondclip]; [0:v]trim=start=443.73,setpts=PTS-STARTPTS[fadeoutsrc]; [1:v]trim=start=0:end=2,setpts=PTS-STARTPTS[fadeinsrc]; [fadeinsrc]format=pix_fmts=yuva420p,fade=t=in:st=0:d=2:alpha=1[fadein]; [fadeoutsrc]format=pix_fmts=yuva420p,fade=t=out:st=0:d=2:alpha=1[fadeout]; [fadein]fifo[fadeinfifo]; [fadeout]fifo[fadeoutfifo]; [fadeoutfifo][fadeinfifo]overlay[crossfade]; [firstclip][crossfade][secondclip]concat=n=3[video]; [0:a][1:a]acrossfade=d=2[audio]" -map "[video]" -map "[audio]" -c:v h264_qsv -global_quality 40 -f mp4 -y "C:Users[username]AppDataLocalTemptmpA15F.tmp"

 

After several hours of searching and reading, I've found the solution. All files for video concatenation need to have the same frame rate.

So I've added a strong definition of frame rate to the previous steps of processing.

And this helped!

 

I'll be happy if my notes will help you in your work!