Vitor Silva de Deus
Vitor Silva de Deus

Reputation: 35

Segment stream and dump to different output file formats with ffmpeg

I am trying to segment the same stream of data into two file formats(mp4 and ts) using ffmpeg.Dump to one file format each time works just fine:

ffmpeg -loglevel panic -i /dev/dvb/adapter0/dvr0 -f segment -segment_time 240 "outf-%3d.ts"

and

ffmpeg -loglevel panic -i /dev/dvb/adapter0/dvr0 -f segment -segment_time 240 segment_format mp4 "outf-%3d.mp4"

How can I dump the segmented stream to outf.ts and outf.mp4 at the same time(In the same ffmpeg command)?

Upvotes: 1

Views: 1015

Answers (1)

Gyan
Gyan

Reputation: 93369

If you want to keep the default encoder selection - mpeg2video and mp2 for TS and H264 and AAC for MP4, use

ffmpeg -loglevel panic -i /dev/dvb/adapter0/dvr0 \
       -f segment -segment_time 240 "outf-%3d.ts" \
       -f segment -segment_time 240 "outf-%3d.mp4"

If you want to encode only once, use

ffmpeg -loglevel panic -i /dev/dvb/adapter0/dvr0 \
       -map 0:v? -map 0:a? -c:v libx264 -c:a aac
       -f tee \ 
       "[f=segment:segment_time=240]outf-%3d.ts| \
        [f=segment:segment_time=240]outf-%3d.mp4"

Upvotes: 2

Related Questions