[FFmpeg-user] HTML5 live streaming

Ricardo Kleemann ricardo at americasnet.com
Mon Apr 22 05:11:08 CEST 2013


Alright...

but back to my original question. I got the ffmpeg segmenter to work. I can
playback via VLC.

But it still does not work for HTML5 <video> tag. I keep getting "cannot
decode" in iPad.

:-/

On Sun, Apr 21, 2013 at 8:05 PM, Ricardo Kleemann
<ricardo at americasnet.com>wrote:

> I did get the segmenter to work with h.264, I needed to add this to the
> command prior to -f segment:
>
> -vbsf h264_mp4toannexb -flags -global_header
>
>
>
> On Sun, Apr 21, 2013 at 5:43 PM, Ricardo Kleemann
> <ricardo at americasnet.com>wrote:
>
> > That's great, I didn't realize it.
> >
> > I'm trying to convert the input to h.264 + AAC and output to the
> segmenter
> > but it's not working. Can you help me find the error in the command?
> >
> > ffmpeg -loglevel debug -threads 4 -i "rtmp://server1/live/livestream1"
> > -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 63 -qdiff 4 -trellis 0 -vcodec
> > libx264 -s 480x270 -b:v 512k -b:a 56k -ar 22050 -map 0 -f segment
> > -segment_time 10 -segment_list live.m3u8 -segment_list_flags +live
> > live_%05d.ts
> >
> > The debug output is too large, but here is the end section:
> >
> > Successfully opened the file.
> > Parsing a group of options: output file live_%05d.ts.
> > Applying option vcodec (force video codec ('copy' to copy stream)) with
> > argument libx264.
> > Applying option s (set frame size (WxH or abbreviation)) with argument
> > 480x270.
> > Applying option b:v (video bitrate (please use -b:v)) with argument 512k.
> > Applying option b:a (video bitrate (please use -b:v)) with argument 56k.
> > Applying option ar (set audio sampling rate (in Hz)) with argument 22050.
> > Applying option map (set input stream mapping) with argument 0.
> > Applying option f (force format) with argument segment.
> > Successfully parsed a group of options.
> > Opening an output file: live_%05d.ts.
> > Successfully opened the file.
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'video_size' to value
> > '490x270'
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'pix_fmt' to value
> '0'
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'time_base' to value
> > '1/1000'
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'pixel_aspect' to
> value
> > '1/1'
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'sws_param' to value
> > 'flags=2'
> > [graph 0 input from stream 0:0 @ 0x153eb20] Setting 'frame_rate' to value
> > '30000/1001'
> > [graph 0 input from stream 0:0 @ 0x153eb20] w:490 h:270 pixfmt:yuv420p
> > tb:1/1000 fr:30000/1001 sar:1/1 sws_param:flags=2
> > [scaler for output stream 0:0 @ 0x153fc40] Setting 'w' to value '480'
> > [scaler for output stream 0:0 @ 0x153fc40] Setting 'h' to value '270'
> > [scaler for output stream 0:0 @ 0x153fc40] Setting 'flags' to value '0x4'
> > [scaler for output stream 0:0 @ 0x153fc40] w:480 h:270 flags:'0x4'
> interl:0
> > [format @ 0x160a2a0] compat: called with
> > args=[yuv420p|yuvj420p|yuv422p|yuv444p]
> > [format @ 0x160a2a0] Setting 'pix_fmts' to value
> > 'yuv420p|yuvj420p|yuv422p|yuv444p'
> > [AVFilterGraph @ 0x1535020] query_formats: 5 queried, 4 merged, 0 already
> > done, 0 delayed
> > [scaler for output stream 0:0 @ 0x153fc40] w:490 h:270 fmt:yuv420p
> sar:1/1
> > -> w:480 h:270 fmt:yuv420p sar:49/48 flags:0x4
> > [graph 1 input from stream 0:1 @ 0x1533300] Setting 'time_base' to value
> > '1/44100'
> > [graph 1 input from stream 0:1 @ 0x1533300] Setting 'sample_rate' to
> value
> > '44100'
> > [graph 1 input from stream 0:1 @ 0x1533300] Setting 'sample_fmt' to value
> > 's16p'
> > [graph 1 input from stream 0:1 @ 0x1533300] Setting 'channel_layout' to
> > value '0x4'
> > [graph 1 input from stream 0:1 @ 0x1533300] tb:1/44100 samplefmt:s16p
> > samplerate:44100 chlayout:0x4
> > [audio format for output stream 0:1 @ 0x1536b40] Setting 'sample_fmts' to
> > value 's16'
> > [audio format for output stream 0:1 @ 0x1536b40] Setting 'sample_rates'
> to
> > value '22050'
> > [audio format for output stream 0:1 @ 0x1536b40] Setting
> 'channel_layouts'
> > to value '0x4|0x3'
> > [audio format for output stream 0:1 @ 0x1536b40] auto-inserting filter
> > 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the
> > filter 'audio format for output stream 0:1'
> > [AVFilterGraph @ 0x153d200] query_formats: 4 queried, 9 merged, 3 already
> > done, 0 delayed
> > [auto-inserted resampler 0 @ 0x153b540] ch:1 chl:mono fmt:s16p r:44100Hz
> ->
> > ch:1 chl:mono fmt:s16 r:22050Hz
> > [libx264 @ 0x1635460] using mv_range_thread = 24
> > [libx264 @ 0x1635460] using SAR=49/48
> > [libx264 @ 0x1635460] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1
> > Cache64
> > [libx264 @ 0x1635460] profile High, level 2.1
> > [libx264 @ 0x1635460] 264 - core 130 r2274 c832fe9 - H.264/MPEG-4 AVC
> codec
> > - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options:
> > cabac=1
> > ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
> psy_rd=1.00:0.00
> > mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0
> deadzone=21,11
> > fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2
> > sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
> > constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1
> > weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
> > intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=512 ratetol=1.0
> > qcomp=0.60 qpmin=10 qpmax=63 qpstep=4 ip_ratio=1.41 aq=1:1.00
> > [segment @ 0x15d4080] Selected stream id:0 type:video
> > [mpegts @ 0x23f2cc0] muxrate VBR, pcr every 2 pkts, sdt every 200,
> pat/pmt
> > every 40 pkts
> > Output #0, segment, to 'live_%05d.ts':
> >   Metadata:
> >     author          :
> >     copyright       :
> >     description     :
> >     keywords        :
> >     rating          :
> >     title           :
> >     presetname      : Custom
> >     creationdate    : Sun Apr 21 16:31:28 2013
> >                     :
> >     videodevice     : AV/C Tape Recorder/Player
> >     avclevel        : 30
> >     avcprofile      : 66
> >     videokeyframe_frequency: 3
> >     audiodevice     : AV/C Tape Recorder/Player
> >     audiochannels   : 1
> >     audioinputvolume: 10
> >     encoder         : Lavf55.3.100
> >     Stream #0:0, 0, 1/90000: Video: h264, yuv420p, 480x270 [SAR 49:48 DAR
> > 49:27], 1001/30000, q=10-63, 512 kb/s, 90k tbn, 29.97 tbc
> >     Stream #0:1, 0, 1/90000: Audio: mp2, 22050 Hz, mono, s16, 56 kb/s
> > Stream mapping:
> >   Stream #0:0 -> #0:0 (h264 -> libx264)
> >   Stream #0:1 -> #0:1 (mp3 -> mp2)
> > Press [q] to stop, [?] for help
> > *** 1 dup!
> > *** drop!
> >     Last message repeated 106 times
> > [libx264 @ 0x1635460] frame=   0 QP=28.46 NAL=3 Slice:I Poc:0   I:510
>  P:0
> >    SKIP:0    size=4440 bytes
> > [segment @ 0x15d4080] segment:'live_00000.ts' starts with packet stream:0
> > pts:0 pts_time:0 frame:0
> > [mpegts @ 0x23f2cc0] H.264 bitstream malformed, no startcode found, use
> the
> > h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
> > [AVIOContext @ 0x23ea6a0] Statistics: 0 seeks, 0 writeouts
> > av_interleaved_write_frame(): Invalid argument
> > Statistics: 287291 bytes read, 0 seeks
> > [rtmp @ 0x153d800] Deleting stream...
> >
> >
> >
> >
> > On Sun, Apr 21, 2013 at 5:00 PM, Vlad Kroutik <vkroutik at gmail.com>
> wrote:
> >
> > > You do not need m3u8-segmenter as ffmpeg support segmented output and
> its
> > > built it. Look at the ffmpeg docs or example:
> > > /usr/local/bin/ffmpeg -i hi.ts -loglevel debug
> > > -analyzeduration 6M  -map 0 -c copy -f segment -segment_time 10
> > > -segment_list hi.m3u8 hi_%05d.ts
> > >
> > >
> > >
> > > On Sun, Apr 21, 2013 at 2:53 PM, Ricardo Kleemann
> > > <ricardo at americasnet.com>wrote:
> > >
> > > > On Sat, Apr 20, 2013 at 10:21 PM, JoelB <onephatcat at earthlink.net>
> > > wrote:
> > > >
> > > > > Should work for Roku and anything that supports HLS, I think
> android
> > > > does,
> > > > > various flash players, QuickTime 7 for Mac, safari(?) supposedly
> > > supports
> > > > > it as well. Generally, you want to encode h.264 video with AAC
> audio.
> > > > >
> > > > > Joel
> > > > >
> > > > > Sent from my iPhone
> > > > >
> > > >
> > > > So that's what I'm doing... I'm encoding to 264 and AAC, and piping
> to
> > > the
> > > > segmenter.
> > > >
> > > > I see the m3u8 file being written as well as all the other ts files.
> > > >
> > > > But if I try to access from an iPad it gives me different errors,
> > > sometimes
> > > > it says "cannot decode", sometimes it says cannot find the file.
> > > >
> > > > I'm assuming that the m3u8 file is supposed to be served up by a
> > standard
> > > > web server (apache). Do I need any special configuration in apache
> for
> > > > this?
> > > >
> > > > Here's my ffmpeg command:
> > > >
> > > > ffmpeg -threads 4 -i "rtmp://server1/live/livestream1" -f mpegts
> > > -i_qfactor
> > > > 0.71 -qcomp 0.6 -qmin 10 -qmax 63 -qdiff 4 -trellis 0 -vcodec libx264
> > -s
> > > > 480x270 -b:v 512k -b:a 56k -ar 22050 - | m3u8-segmenter -i - -d 10 -p
> > > > cidadeviva/live -m /shared/media/videos/cidadeviva/live.m3u8 -u
> > > > http://web1.americasnet.com/videos/
> > > >
> > > > It succeeds in reading the rtpm stream and does pipe the output to
> the
> > > > segmenter since I see all of the m3u8 and ts files being written.
> > > >
> > > > I'm able to access the m3u8 file via http, although I see apache
> often
> > > > complains that it can't find the file. Could that be because the file
> > is
> > > > constantly being written?
> > > >
> > > > Ricardo
> > > >
> > > >
> > > > > On Apr 20, 2013, at 8:56 PM, Ricardo Kleemann <
> > ricardo at americasnet.com
> > > >
> > > > > wrote:
> > > > >
> > > > > > Hi Joel,
> > > > > >
> > > > > > Thanks, I'll play around with that.
> > > > > >
> > > > > > Another question... is the segmenter only for iOS? Would other
> > > devices
> > > > > also
> > > > > > work with this?
> > > > > >
> > > > > > Ricardo
> > > > > >
> > > > > > On Sat, Apr 20, 2013 at 8:45 PM, JoelB <onephatcat at earthlink.net
> >
> > > > wrote:
> > > > > >
> > > > > >> Usually a segmented stream URL ends with .m3u8 so for ios, you
> > just
> > > > give
> > > > > >> the user a link to that m3u8 playlist URL and if you have a
> valid
> > > > > stream,
> > > > > >> the phone will just play it.
> > > > > >>
> > > > > >> http://inodes.org/bigbuck/big_buck.m3u8
> > > > > >>
> > > > > >> Would probably be the res
> > > > > >>
> > > > > >>
> > > > > >> Joel
> > > > > >> Sent from my iPhone
> > > > > >>
> > > > > >> On Apr 20, 2013, at 5:35 PM, Ricardo Kleemann <
> > > > ricardo at americasnet.com>
> > > > > >> wrote:
> > > > > >>
> > > > > >>> Hi,
> > > > > >>>
> > > > > >>> I've been searching around for solutions to use ffmpeg to do
> live
> > > > > >> streaming
> > > > > >>> to html5.
> > > > > >>>
> > > > > >>> I understand that for iOS I need a segmenter?
> > > > > >>>
> > > > > >>> I've installed the latest ffmpeg and also m3u8-segmenter from
> > git,
> > > > but
> > > > > >> I'm
> > > > > >>> not really sure how to use it. The m3u8-segmenter site has an
> > > example
> > > > > >> like
> > > > > >>> this:
> > > > > >>>
> > > > > >>> ffmpeg -loglevel quiet  -i big_buck_bunny.ogv -f mpegts - | \
> > > > > >>> m3u8-segmenter -i - -d 10 -p tmp/big_buck_bunny -m
> > > tmp/big_buck.m3u8
> > > > > >>> -u http://inodes.org/bigbuck/
> > > > > >>>
> > > > > >>> But in terms of an HTML5 page source, how would I access the
> > stream
> > > > > that
> > > > > >> is
> > > > > >>> being generated by the segmenter?
> > > > > >>>
> > > > > >>> Is there a simpler way to use ffmpeg for live streaming?
> > > > > >>>
> > > > > >>> thanks
> > > > > >>> Ricardo
> > > > > >>> _______________________________________________
> > > > > >>> ffmpeg-user mailing list
> > > > > >>> ffmpeg-user at ffmpeg.org
> > > > > >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > > > > >> _______________________________________________
> > > > > >> ffmpeg-user mailing list
> > > > > >> ffmpeg-user at ffmpeg.org
> > > > > >> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > > > > >>
> > > > > >>
> > > > > >> ------------------------------------------------------
> > > > > >> Powered by Xeams. Visit xeams.com for more information
> > > > > >> ------------------------------------------------------
> > > > > > _______________________________________________
> > > > > > ffmpeg-user mailing list
> > > > > > ffmpeg-user at ffmpeg.org
> > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > > > > _______________________________________________
> > > > > ffmpeg-user mailing list
> > > > > ffmpeg-user at ffmpeg.org
> > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > > > >
> > > > >
> > > > > ------------------------------------------------------
> > > > > Powered by Xeams. Visit xeams.com for more information
> > > > > ------------------------------------------------------
> > > > >
> > > > _______________________________________________
> > > > ffmpeg-user mailing list
> > > > ffmpeg-user at ffmpeg.org
> > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > > >
> > > _______________________________________________
> > > ffmpeg-user mailing list
> > > ffmpeg-user at ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > >
> > >
> > > ------------------------------------------------------
> > > Powered by Xeams. Visit xeams.com for more information
> > > ------------------------------------------------------
> > >
> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> >
> > ------------------------------------------------------
> > Powered by Xeams. Visit xeams.com for more information
> > ------------------------------------------------------
> >
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
>
> ------------------------------------------------------
> Powered by Xeams. Visit xeams.com for more information
> ------------------------------------------------------
>


More information about the ffmpeg-user mailing list