Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

http live streaming - transcode and segment with ffmpeg

It appears that ffmpeg now has a segmenter in it, or at least there is a command line option

-f segment

in the documentation.

Does this mean I can use ffmpeg to realtime-transcode a video into h.264 and deliver segmented IOS compatible .m3u8 streams using ffmpeg alone? if so, what would a command to transcode an arbitrary video file to a segmented h.264 aac 640 x 480 stream ios compatible stream?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Absolutely - you can use -f segment to chop video into pieces and serve it to iOS devices. ffmpeg will create segment files .ts and you can serve those with any web server.

Working example (with disabled sound) - ffmpeg version N-39494-g41a097a:

./ffmpeg -v 9 -loglevel 99 -re -i sourcefile.avi -an 
-c:v libx264 -b:v 128k -vpre ipod320  
-flags -global_header -map 0 -f segment -segment_time 4 
-segment_list test.m3u8 -segment_format mpegts stream%05d.ts

Tips:

  • make sure you compile ffmpeg from most recent repository
  • compile with libx264 codec
  • -map 0 is needed

How I compiled FFMPEG - with extra rtmp support to get feeds from

export PKG_CONFIG_PATH="/usr/lib/pkgconfig/:../rtmpdump-2.3/librtmp"    

./configure --enable-librtmp --enable-libx264 
--libdir='../x264/:/usr/local/lib:../rtmpdump-2.3' 
--enable-gpl --enable-pthreads --enable-libvpx 
--disable-ffplay --disable-ffserver --disable-shared --enable-debug

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...