0

I have a single mpeg-ts input stream, http://192.168.1.100/stream0, and I wish to do two things with this stream. One output is to be a hls multipart stream with m3u8 so apache can serve to local clients in a browser. The other output is to copy the stream into a mp4 container that is 5 minutes long. The goal being to have a constant live stream that can be viewed, whilst also a number of 5 min long mp4 files saved to disk.

The command below accomplishes part of what I need:

ffmpeg -re -i http://192.168.1.100/stream0 -c:v copy -c:a copy -preset veryfast \
       -f hls -hls_time 3 -segment_list_flags +live \
           -hls_flags second_level_segment_index\
                      +second_level_segment_size\
                      +second_level_segment_duration \
                      -hls_flags delete_segments \
                      -hls_segment_filename \
                      /var/www/html/live-%1d.ts \
                      /var/www/html/live.m3u8 \
        -f mpegts -c:v copy -c:a copy -y -t 300 \
            /store/archive/archive.$(date +%Y%m%d-%H%M%S).mp4"

The problem is the 2nd part, creates just one file and doesn't continue to create multiple files.

I can run one ffmpeg to create the live stream, then run another instance using that live stream as the input within a loop so the it creates multiple files. Ideally I think I need to use Pipes, but I either end up with out multiple mp4 files, or a live stream that keeps freezing.

What would be the best way to approach this ?

Regards Jon

New contributor
Jon37 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • 1
    Use the segment muxer for the 2nd output.
    – Gyan
    Commented 2 days ago
  • perhaps I'm missing something, I need to create multiple standalone 5 minute long mp4 files. Using -f segment -segment_time I seem to get error "Output file does not contain any stream" -f segment -segment_time 00:05:00 -f mpegts -c:v copy -c:a copy -t 300 \ /store/archive/archive.$(date +%Y%m%d-%H%M%S).mp4
    – Jon37
    Commented 7 hours ago
  • -f mpegts overrides the earlier -f segment. -t 300 will stop processing after the first 300 seconds. Remove these. You will also need to set -strftime 1 if you are going to have datetime specifiers in the output pattern.
    – Gyan
    Commented 6 hours ago

0

You must log in to answer this question.

Browse other questions tagged .