0

I have an RTSP stream and I need to segment it with 2s segments with 1s overlaps.

i.e.

t(s): 0----1----2----3----4----5----6----7----8----9----10---->

vids: |--1.mp4--|--3.mp4--|--5.mp4--|--7.mp4--|--9.mp4--|
           |--2.mp4--|--4.mp4--|--6.mp4--|--8.mp4--|

I can split to 2s segments, every 2 seconds, but I can't see how I can split to 2s segments every one second.

So far I have used the below:

ffmpeg \
-i rtsp://192.168.1.124:8553/unicast \
-c copy -flags +global_header \
-f segment \
-segment_time 2 \
-segment_format_options movflags=+faststart \
-reset_timestamps 1 \
%d.mp4 \

The approach I was thinking was to copy the stream, delay by 1s and then segment that separately but this seems wasteful and there's no way to guarantee the overlap.

Any ideas?

1
  • would be interested why the downvote here. There's literally nothing on this from what I could find anywhere on stack or google. Commented Jan 25, 2017 at 16:33

1 Answer 1

1

I tried a bunch of stuff, including inbuilt tee filter as well as the split complex filter and trying to apply -muxdelay 1.

However, the best and most reliable performance turned out to be to pipe the output stream to two separate instances of ffmpeg (inefficient I know):

ffmpeg \
    -i rtsp://10.10.128.213:8553/unicast \
    -f nut - | tee >(ffmpeg -y -i - -f nut -c copy -f segment -segment_time 2 -reset_timestamps 1 $VID_DIR/test_1_%d.mp4) \
               >(ffmpeg -y -itsoffset 1 -i - -f nut -c copy -f segment -segment_time 2 -reset_timestamps 1 $VID_DIR/test_2_%d.mp4) \
         > /dev/null

All approaches except this one caused the segmentation to be wildly uneven.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.