This is a follow-up question from my previous question: FFmpeg split video and merge back
I need to concat the files as suggested. I was using the last one which worked on .avi, but not on .mp4.
Using the first method, when I want to trim audio as well, it throws an error:
Stream specifier ':a' in filtergraph description [0:a]trim=0:15,setpts=PTS-STARTPTS[a0]; [1:a]trim=0:5,setpts=PTS-STARTPTS[a1]; [0:a]trim=20:30,setpts=PTS-STARTPTS[a2]; [a0][a1][a2]concat=n=3:a=1:a=0[out] matches no streams.
I tried another replacement file (which is a cut of the original file), but that throws a different error:
ffmpeg -i sample.mp4 -i ad2.mp4 -filter_complex "[0:v]trim=0:15,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0:15,asetpts=PTS-STARTPTS[a0]; [1:v]trim=0:5,setpts=PTS-STARTPTS[v1]; [1:a]atrim=0:5,asetpts=PTS-STARTPTS[v1]; [0:v]trim=20:30,setpts=PTS-STARTPTS[v2]; [0:a]atrim=20:30,asetpts=PTS-STARTPTS[a2]; [v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4
Error is:
[Parsed_asetpts_7 @ 0x1831320] Media type mismatch between the 'Parsed_asetpts_7' filter output pad 0 (audio) and the 'Parsed_concat_12' filter input pad 2 (video)
[AVFilterGraph @ 0x17fd720] Cannot create the link asetpts:0 -> concat:2
Error initializing complex filters.
Invalid argument
How can I fix it?
Using the second method, how can I do that for audio? So I need to save it as a separate audio file, correct?
Using the third method is good. However, I need to keep the FPS and GOP. But it messes around with the fps and in spite both videos are 25 fps, the output is 23.58xxx. Any ways I can keep the GOP and fps?