user12777: I need to replace video in a larger mp4 file with a smaller mp4 clip - but leaving the original (larger clip) audio intact.
So for example I might want the first 2 seconds of SmallClip.mp4 to replace the video in LargeClip.mp4 starting at (say) 10 seconds in to LargeClip.mp4.
The format of both clips is likely to be identical, so I'm hoping I can copy instead of decoding for speed etc (I'll have to do it a lot).
Finally, I might want to do exactly the same thing but in several places in LargeClip.mp4 - all places in the output getting the video replaced with the same input clip's video.  I'd be happy to do this in multiple oerations if neccessary but if it were possible on one command so much the better :)
I'm reading up on the options for ffmpeg but I'm new to it and haven't figured it out yet.  Any help much appreciated!

user1871: You can use the concat demuxer in ffmpeg to do this. For accurate splicing, re-encoding is needed which is what the commands below do.
Step 1 Prepare the concat text file
You must first create a plaintext file, say, concat.txt, like this
file 'LargeClip.mp4'
inpoint 0.0
duration 10.0
file 'SmallClip.mp4'
inpoint 0.0
outpoint 2.0
file 'LargeClip.mp4'
inpoint 12.0
duration 5.0
file 'SmallClip.mp4'
inpoint 23.0
duration 4.0
file 'LargeClip.mp4'
inpoint 21.0

This shows the first 10 seconds of LargeClip, then the first two seconds of smallclip, then resumes the Largeclip at 12:00, shows it for 5 seconds, then splices in 23:00 to 27:00 of small clip, switches back to LargeClip at its 21:00 and keeps it till its end. These timecodes, in seconds, refer to the source file timecode, not of the assembled output.
Make sure that the sync of LargeClip isn't broken, i.e. after switching to SmallClip for 12 seconds, you want to resume LargeClip 12 seconds later from where you left it off.
Step 2 Concat the video streams
This command will skip the audio since we don't to splice the audio streams.
ffmpeg -f concat -i concat.txt -an -c:v libx264 -crf 23 -fflags +genpts spliced-vid.mp4

Step 3 Insert the audio from LargeClip
ffmpeg -i spliced-vid.mp4 -i LargeClip.mp4 -c copy -map 0:v -map 1:a Final.mp4 


12777: <p>I need to replace video in a larger mp4 file with a smaller mp4 clip - but leaving the original (larger clip) audio intact.</p>

<p>So for example I might want the first 2 seconds of SmallClip.mp4 to replace the video in LargeClip.mp4 starting at (say) 10 seconds in to LargeClip.mp4.</p>

<p>The format of both clips is likely to be identical, so I'm hoping I can copy instead of decoding for speed etc (I'll have to do it a lot).</p>

<p>Finally, I might want to do exactly the same thing but in several places in LargeClip.mp4 - all places in the output getting the video replaced with the same input clip's video.  I'd be happy to do this in multiple oerations if neccessary but if it were possible on one command so much the better :)</p>

<p>I'm reading up on the options for ffmpeg but I'm new to it and haven't figured it out yet.  Any help much appreciated!</p>
 1871: <p>You can use the concat demuxer in ffmpeg to do this. For accurate splicing, re-encoding is needed which is what the commands below do.</p>

<p><strong>Step 1</strong> Prepare the concat text file</p>

<p>You must first create a plaintext file, say, <code>concat.txt</code>, like this</p>

<pre><code>file 'LargeClip.mp4'
inpoint 0.0
duration 10.0
file 'SmallClip.mp4'
inpoint 0.0
outpoint 2.0
file 'LargeClip.mp4'
inpoint 12.0
duration 5.0
file 'SmallClip.mp4'
inpoint 23.0
duration 4.0
file 'LargeClip.mp4'
inpoint 21.0
</code></pre>

<p>This shows the first 10 seconds of LargeClip, then the first two seconds of smallclip, then resumes the Largeclip at 12:00, shows it for 5 seconds, then splices in 23:00 to 27:00 of small clip, switches back to LargeClip at its 21:00 and keeps it till its end. These timecodes, in seconds, refer to the source file timecode, not of the assembled output.</p>

<p>Make sure that the sync of LargeClip isn't broken, i.e. after switching to SmallClip for 12 seconds, you want to resume LargeClip 12 seconds later from where you left it off.</p>

<p><strong>Step 2</strong> Concat the video streams</p>

<p>This command will skip the audio since we don't to splice the audio streams.</p>

<pre><code>ffmpeg -f concat -i concat.txt -an -c:v libx264 -crf 23 -fflags +genpts spliced-vid.mp4
</code></pre>

<p><strong>Step 3</strong> Insert the audio from LargeClip</p>

<pre><code>ffmpeg -i spliced-vid.mp4 -i LargeClip.mp4 -c copy -map 0:v -map 1:a Final.mp4 
</code></pre>
