Discussion:
[FFmpeg-user] Generate .ts file parallel, resume option, offset HLS
Diogo Serrano
2014-08-20 14:23:17 UTC
Permalink
I have a mp4 file or other file (non mp4 format) and i need generate ts
files and m3u8 playlist.
ffmpeg -i foo.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment
-segment_list out.m3u8 -segment_time 10 out%03d.ts

Now I need to generate many ts simultaneous so i need a "resume option".

Please see the example below:

One thread (first 20 seconds (0-20))
ffmpeg -i foo.mp4 -codec copy -vbsf h264_mp4toannexb ................
Seconds thread (20 seconds to 40 seconds)
ffmpeg -i foo.mp4 ......
Third thread (40 seconds to 60 seconds)
ffmpeg -i foo.mp4 ......
I have lots of core processor to do this jobs.

In resume i need generate .ts files and m3u8 fastest way possible

I need help or advises to resolve my problem.

Thanks for your help
Andrew Sinclair
2014-08-24 11:02:02 UTC
Permalink
Not sure I completely understand what you are trying but is it to encode in
paralell? Please explain further and provide full commands and output

You can do this by creating multiple TS files but you will likely need to
join them back together before creating the m3u8, though may be possible to
generate before hand if you needed to get the stream out really fast.

Note if you have lot's of processors on a single box then ffmpeg should use
this if you have a proper build
Post by Diogo Serrano
I have a mp4 file or other file (non mp4 format) and i need generate ts
files and m3u8 playlist.
ffmpeg -i foo.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment
-segment_list out.m3u8 -segment_time 10 out%03d.ts
Now I need to generate many ts simultaneous so i need a "resume option".
One thread (first 20 seconds (0-20))
ffmpeg -i foo.mp4 -codec copy -vbsf h264_mp4toannexb ................
Seconds thread (20 seconds to 40 seconds)
ffmpeg -i foo.mp4 ......
Third thread (40 seconds to 60 seconds)
ffmpeg -i foo.mp4 ......
I have lots of core processor to do this jobs.
In resume i need generate .ts files and m3u8 fastest way possible
I need help or advises to resolve my problem.
Thanks for your help
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Diogo Serrano
2014-08-25 10:30:36 UTC
Permalink
Hi, Andrew Sinclair thanks for your reply.

I did a litlle script that generates all the ffmpeg commands to create ts
files and i give the arguments of range of time.

Basicaly i want to create a single .ts giving in the arguments the range of
time, after that i need to join all .ts files and generate the m3u8
playlist.

The ffmpeg command list bellow are a prove of concept to resolve my
problem, but when a generate the m3u8 playlist the video is not fluid,
because the cut is not very precise
fmpeg -ss 0.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v copy
-bsf h264_mp4toannexb -flags -global_header -map 0 -f segment -segment_time
10 -segment_start_number 1 -segment_list 0001_test.m3u8 -segment_format
mpegts 1stream%05d.ts
ffmpeg -ss 10.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 2 -segment_list 0002_test.m3u8
-segment_format mpegts 2stream%05d.ts
ffmpeg -ss 20.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 3 -segment_list 0003_test.m3u8
-segment_format mpegts 3stream%05d.ts
ffmpeg -ss 30.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 4 -segment_list 0004_test.m3u8
-segment_format mpegts 4stream%05d.ts
ffmpeg -ss 40.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 5 -segment_list 0005_test.m3u8
-segment_format mpegts 5stream%05d.ts
ffmpeg -ss 50.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 6 -segment_list 0006_test.m3u8
-segment_format mpegts 6stream%05d.ts
ffmpeg -ss 60.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 7 -segment_list 0007_test.m3u8
-segment_format mpegts 7stream%05d.ts
ffmpeg -ss 70.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 8 -segment_list 0008_test.m3u8
-segment_format mpegts 8stream%05d.ts
ffmpeg -ss 80.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 9 -segment_list 0009_test.m3u8
-segment_format mpegts 9stream%05d.ts
ffmpeg -ss 90.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 10 -segment_list 0010_test.m3u8
-segment_format mpegts 10stream%05d.ts
ffmpeg -ss 100.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v
copy -bsf h264_mp4toannexb -flags -global_header -map 0 -f segment
-segment_time 10 -segment_start_number 11 -segment_list 0011_test.m3u8
-segment_format mpegts 11stream%05d.ts
...........
.........................
....................................
(the list continue depending the time of the video)
Claudiu Rad
2014-08-25 13:08:26 UTC
Permalink
Post by Diogo Serrano
Basicaly i want to create a single .ts giving in the arguments the range of
time, after that i need to join all .ts files and generate the m3u8
playlist.
The ffmpeg command list bellow are a prove of concept to resolve my
problem, but when a generate the m3u8 playlist the video is not fluid,
because the cut is not very precise
fmpeg -ss 0.000 -i "/home/USER/vagrant/files/rod.mp4" -t 10.000 -c:v copy
-bsf h264_mp4toannexb -flags -global_header -map 0 -f segment -segment_time
10 -segment_start_number 1 -segment_list 0001_test.m3u8 -segment_format
mpegts 1stream%05d.ts
...........
.........................
....................................
(the list continue depending the time of the video)
i think that in order for this to work you should have keyframes in the
input video at each 10s exactly if you use -c:v copy.
cut should be done at keyframe.
--
Claudiu
Loading...