1

This is the original command, it removes the part between the start and end which will be specified in command:

ffmpeg -i input.ext -vf "select='not(between(t,start,end))', setpts=N/FRAME_RATE/TB" -af "aselect='not(between(t,start,end))', asetpts=N/SR/TB" output.ext

Are there better options that doesn't re-encode? Or at least is faster?

Keep in mind I am want the command to remove the part between the start and end not return it.

So this for example isn’t what I am looking for:

ffmpeg -ss start -i input.mp4 -c copy -t end output.mp4

1 Answer 1

1

Without re-encode, split by key frames using segment format, then concat 1st and last segments:

ffmpeg -i "input.mp4" -c copy -f segment -segment_times 5,25 -reset_timestamps 1 %d.mp4 -y
echo "file 0.mp4" > 1.txt
echo "file 2.mp4" >> 1.txt
ffmpeg -f concat -i 1.txt -c copy out.mp4 -y

If partial re-encode, work with middle part only, then concat 1st, converted, last parts.

-segment_times seek keyframe after specified time, for example → will cut to 8.4444444 sec, then from 25.333333 sec.


Edit: Yesh, variant with outpoint inpoint without re-encoding split by key frames:

echo "file input.mp4
outpoint 5
file input.mp4
inpoint 25" > 2.txt
ffmpeg -f concat -i 2.txt -c copy out2.mp4

To add edited middle segment just add line file edited.mp4 between 1st and last inputs.

Outpoint will cut nearly at 5 sec, inpoint will cut, for example, at 16.888889 sec, and may have wrong time while playing

So, try to find next keyframe:

f="2024-06-06_14꞉30꞉10.MOV"
o="out.mp4"
ofs=$(ffprobe -read_intervals 25%35 -skip_frame nokey -select_streams v:0 -show_entries frame=pts_time -of default=nw=1:nk=1 -v quiet "$f" | head -n 2 | tail -n 1)
echo "file '$f'
outpoint 5
file '$f'
inpoint $ofs" > 1.txt
cat 1.txt
ffmpeg -f concat -safe 0 -i 1.txt -c copy "$o" -y
mpv --ab-loop-a=4 --ab-loop-b=6 --ab-loop-count=inf --no-config "$o"
2
  • Why the intermediate files? Just set inpoint and outpoint in the text file.
    – Gyan
    Commented Jun 9 at 4:41
  • Forgot about this one :) but as @Gyan said it would be better to use the text file syntax Commented Jun 9 at 5:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .