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.

  1. 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?

  1. Using the second method, how can I do that for audio? So I need to save it as a separate audio file, correct?

  2. 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?

  • 1
    Please try to keep your question limited to one particular problem. As for the errors, please show the entire command along with the command line output, not just the error itself. I assume the problem is that one of the input files does not have an audio stream at all. Regarding your question 2), I added that to my answer – it works similarly to the trim approach. Regarding question 3), I saw you edited my post, but that command won't necessarily work with all source material. This is, again, another problem, for which you may want to ask a different question (and show the command/output).
    – slhck
    Aug 8 '17 at 7:10
  • @slhck for 3) you are right. My edit doesn't always work. Let me test out and will post the answers. Thanks.
    – Ariana
    Aug 8 '17 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.