iPhone HTTP Streaming with FFMpeg and an Open Source Segmenter

With the release of the iPhone OS 3 update came the ability to do live streaming. There are a few types of streaming and each requires a certain encoding and segmentation. I've put together a cheat sheet on how I went about building a static stream using FFMpeg and an example segmenter that someone has posted. I'm not covering windowed streams in this post but if you are thinking about implementing a windowed stream the following will help you make a step in that direction.

Before getting started it is best to read over the Apple documentation on HTTP live streaming. Start out with the iPhone streaming media overview. This document covers the basics of how the streaming works and has some nice diagrams.

If you want even more information after reading the overview you can take a look at the HTTP Live streaming draft proposal that was submitted to the IETF by Apple. It covers the streaming protocol in complete detail and has examples of the stream file format for reference.

Once you are ready to start grab a decent quality video clip to use. If you don't have one handy I found a nice list of downloadable HD clips in various formats for testing.

Step 1: Grab the latest version of FFMpeg

You may be able to get away with anything after FFMpeg 0.5 but you might as well pull down a more recent version. The FFMpeg download page has instructions on getting the latest version. I pulled the version I used out of git.

I used the following command to configure FFMpeg:

configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264

One of the main things to note is the --enable-libx264 flag.

Step 2: Encode your video for the iPhone

Once you have a working version of FFMpeg it is time to create an X264 encoded stream that will work with the iPhone. There are a few things to note before diving in:

  1. The supported bitrates for streaming are: 100 Kbps to 1.6 Mbps
  2. The suggested bitrates for streaming are*:
    • Low – 96 Kbps video, 64 Kbps audio
    • Medium – 256 Kbps video, 64 Kbps audio
    • High – 800 Kbps video, 64 Kbps audio
  3. The iPhone screen size is: 480×320

* See step 7 for more information on what I think are better bitrates.

Taking all that into account someone on the iPhone developer forums suggested the following and it works well for me:

ffmpeg -i <in file> -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320x240 -vcodec libx264 -b 96k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 <output file>

If you want some more detail on some of these commands check out the X264 encoding guide and in general the FFMpeg documentation to see what all the flags mean.

Note that I have the bitrate set to 96k in the above example. That can be changed to fit your needs. Use the script that I have created later in the post or just make sure you change the -b, -maxrate, and -bufsize values.

Step 3: Download and build the segmenter

Now you have a complete video but you don't want to toss the entire thing up or you wouldn't be reading about HTTP streaming. What you need is a way to segment the video stream into smaller chunks. You can download Apple's segmenter (see the overview above for more information on where to find it) or you can download one created by the forum user corp186.

There is an SVN repository set up for the segmenter source. It is only a couple files and it is easy to build. The trouble you may run into is that the Makefile that it comes with won't build the binary correctly. Don't worry it just takes some extra link flags to make it work. The following is what I needed in the Makefile to get it to build on my system:

all:
        gcc -Wall -g segmenter.c -o segmenter -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad

clean:
        rm segmenter

After compiling the segmenter you are ready to create your first HTTP streaming content.

The format of the segmenter command is:

segmenter <input MPEG-TS file> <segment duration in seconds> <output MPEG-TS file prefix> <output m3u8 index file> <http prefix>

Following is an example used to create a stream from a video file created with the above FFMpeg command split into 10 second intervals:

segmenter sample_low.ts 10 sample_low stream_low.m3u8 http://www.ioncannon.net/

Step 4: Prepare the HTTP server

At this point you should have a set of files that represent the stream and a stream definition file. Those files can be uploaded to a web server at this point but there is another important step to take that ensures they will be download correctly and that is setting up mime types. There are two mime types that are important for the streaming content:

.m3u8 application/x-mpegURL
.ts video/MP2T

If you are using Apache you would want to add the following to your httpd.conf file:

AddType application/x-mpegURL .m3u8
AddType video/MP2T .ts

If you are using lighttpd you would want to put this in your configuration file (if you have other mime types defined make sure you just add these and don't set them):

mimetype.assign = ( ".m3u8" => "application/x-mpegURL", ".ts" => "video/MP2T" )

Step 5: Test the stream

The video is encoded for the iPhone, segmented for streaming, and the server is configured. The only thing left to do is test the stream and the fastest way to do that is to use the new HTML5 video tag. Here is an example of how to set it up:

<html>
  <head>
    <title>Video Test</title>
    <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
  </head>
  <body style="background-color:#FFFFFF; ">
    <center>
      <video width='150' height='150' src="stream-128k.m3u8" />
    </center>
  </body>
</html>

If everything has been done correctly you should see the video.

If you want to test the stream out in an application then download the MoviePlayer iPhone demo application from the iPhone developer site. Build and run it in the simulator or put it on an actual phone and then type the URL in for the server you uploaded your stream to.

That is all there is to building a single static HTTP stream. A good number of steps but if you have some experience using FFMpeg it isn't too hard to set up. The only pitfalls I ran into revolve around trying to segment the stream without the segmeter code. I don't know enough about how the segmentation works to know why this is so difficult to do but I believe it could have something to do with synchronization points in the stream. Of course when you stray from the path the stream just doesn't work and you get a generic error message so that is just my best guess. I'll also guess that Apple may tighten up the player over time and make it work better with miss-formatted streams.

Step 6: Automating the stream encoding and segmentation

Here is a little script I put together that first encodes an input file and then segments it into 10 second chunks:

#!/bin/sh

BR=800k

ffmpeg -i $1 -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320x240 -vcodec libx264 -b $BR -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate $BR -bufsize $BR -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 sample_$BR_pre.ts

segmenter sample_$BR_pre.ts 10 sample_$BR stream-$BR.m3u8 http://www.ioncannon.net/

rm -f sample_$BR_pre.ts

The script could use some work but it does a good enough job for testing.

Step 7: Create a variable rate HTTP stream

Once you have creating a single stream down you need to try out creating a variable bitrate stream. There isn't much to it, just create different bitrate encoded streams and link to their stream definition files in a separate stream definition file. Here is an example:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=96000
http://192.168.132.15/ipv/stream-96k.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=256000
http://192.168.132.15/ipv/stream-256k.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=800000
http://192.168.132.15/ipv/stream-800k.m3u8

I gave the above a try using both the iPhone's 3G connection and a WIFI connection. The following log shows the two different attempts (first 3G then WIFI):

6.x.x.x ioncannon.net - [20:49:13] "GET /varpl.m3u8 HTTP/1.1" 304 0 "-" "..."
6.x.x.x ioncannon.net - [20:49:14] "GET /varpl.m3u8 HTTP/1.1" 206 288 "-" "..."
6.x.x.x ioncannon.net - [20:49:15] "GET /varpl.m3u8 HTTP/1.1" 200 288 "-" "..."
6.x.x.x ioncannon.net - [20:49:16] "GET /stream-96k.m3u8 HTTP/1.1" 200 719 "-" "..."
6.x.x.x ioncannon.net - [20:49:18] "GET /s_96k-00001.ts HTTP/1.1" 200 334828 "-" "..."
6.x.x.x ioncannon.net - [20:49:21] "GET /s_96k-00002.ts HTTP/1.1" 200 377880 "-" "..."
6.x.x.x ioncannon.net - [20:49:30] "GET /s_96k-00003.ts HTTP/1.1" 200 383520 "-" "..."
6.x.x.x ioncannon.net - [20:49:32] "GET /stream-256k.m3u8 HTTP/1.1" 200 730 "-" "..."
6.x.x.x ioncannon.net - [20:49:39] "GET /s_256k-00003.ts HTTP/1.1" 200 716844 "-" "..."
6.x.x.x ioncannon.net - [20:49:49] "GET /s_256k-00004.ts HTTP/1.1" 200 705564 "-" "..."
6.x.x.x ioncannon.net - [20:49:57] "GET /stream-96k.m3u8 HTTP/1.1" 200 719 "-" "..."
6.x.x.x ioncannon.net - [20:49:59] "GET /s_96k-00004.ts HTTP/1.1" 200 368668 "-" "..."
6.x.x.x ioncannon.net - [20:50:03] "GET /s_96k-00005.ts HTTP/1.1" 200 371300 "-" "..."
6.x.x.x ioncannon.net - [20:50:13] "GET /s_96k-00006.ts HTTP/1.1" 200 398936 "-" "..."
6.x.x.x ioncannon.net - [20:50:16] "GET /stream-256k.m3u8 HTTP/1.1" 200 730 "-" "..."
6.x.x.x ioncannon.net - [20:50:22] "GET /s_256k-00006.ts HTTP/1.1" 200 758016 "-" "..."
6.x.x.x ioncannon.net - [20:50:36] "GET /s_256k-00007.ts HTTP/1.1" 200 737524 "-" "..."
6.x.x.x ioncannon.net - [20:50:40] "GET /s_256k-00008.ts HTTP/1.1" 200 773244 "-" "..."
6.x.x.x ioncannon.net - [20:50:46] "GET /s_256k-00009.ts HTTP/1.1" 200 717032 "-" "..."
6.x.x.x ioncannon.net - [20:50:57] "GET /s_256k-00010.ts HTTP/1.1" 200 768920 "-" "..."
6.x.x.x ioncannon.net - [20:51:06] "GET /s_256k-00011.ts HTTP/1.1" 200 611000 "-" "..."

1.x.x.x ioncannon.net - [20:52:23] "GET /varpl.m3u8 HTTP/1.1" 304 0 "-" "..."
1.x.x.x ioncannon.net - [20:52:24] "GET /varpl.m3u8 HTTP/1.1" 206 288 "-" "..."
1.x.x.x ioncannon.net - [20:52:25] "GET /varpl.m3u8 HTTP/1.1" 200 288 "-" "..."
1.x.x.x ioncannon.net - [20:52:25] "GET /stream-96k.m3u8 HTTP/1.1" 200 719 "-" "..."
1.x.x.x ioncannon.net - [20:52:26] "GET /s_96k-00001.ts HTTP/1.1" 200 334828 "-" "..."
1.x.x.x ioncannon.net - [20:52:27] "GET /s_96k-00002.ts HTTP/1.1" 200 377880 "-" "..."
1.x.x.x ioncannon.net - [20:52:28] "GET /stream-800k.m3u8 HTTP/1.1" 200 730 "-" "..."
1.x.x.x ioncannon.net - [20:52:31] "GET /s_800k-00002.ts HTTP/1.1" 200 1774156 "-" "..."
1.x.x.x ioncannon.net - [20:52:34] "GET /s_800k-00003.ts HTTP/1.1" 200 1916096 "-" "..."
1.x.x.x ioncannon.net - [20:52:38] "GET /s_800k-00004.ts HTTP/1.1" 200 1831872 "-" "..."
1.x.x.x ioncannon.net - [20:52:41] "GET /s_800k-00005.ts HTTP/1.1" 200 1831496 "-" "..."
1.x.x.x ioncannon.net - [20:52:46] "GET /s_800k-00006.ts HTTP/1.1" 200 1967608 "-" "..."
1.x.x.x ioncannon.net - [20:52:50] "GET /s_800k-00007.ts HTTP/1.1" 200 1676208 "-" "..."
1.x.x.x ioncannon.net - [20:52:54] "GET /s_800k-00008.ts HTTP/1.1" 200 2094132 "-" "..."
1.x.x.x ioncannon.net - [20:52:58] "GET /s_800k-00009.ts HTTP/1.1" 200 1860260 "-" "..."
1.x.x.x ioncannon.net - [20:53:08] "GET /s_800k-00010.ts HTTP/1.1" 200 2008404 "-" "..."
1.x.x.x ioncannon.net - [20:53:19] "GET /s_800k-00011.ts HTTP/1.1" 200 1400224 "-" "..."

Notice that there is a decent bit of indecisiveness on the part of what stream to pick when using 3G. For my test it actually caused the player to pause while it switched from the 256k stream back to the 96k stream. The stream on the WIFI connection starts out low but then jumps right to the highest quality and stays there. Overall it seems like the variable rate streaming works decently and again Apple may be able to tweak it down the road to get even better results.

The bitrate jump between 96k and 256k is probably too large even though that is what Apple seems to recommend. I believe with some testing a better set of bitrates could be found. The video quality of the 256k bitrate looks pretty good so I would say that 96k, 128k and 384k would potentially be a better choice.

Some parting notes

If you are interested in how the segmenter works you can find out more on how to use libavformat at the following resources: an older libavformat tutorial, some sample libavformat code, How to Write a Video Player in Less Than 1000 Lines, and more sample libavformat code.

The next step for this is to do a windowed live stream. I've done a little experimenting so far and with a modified segmeter I can generate a live stream. I will need to heavily modify the segmeter to get a live windowed stream so it may take a little while to get it done. My intent of course will be to combine the modifications with something fun like S3 and cloudfront since I believe that would be a sweat combination.

198 thoughts on “iPhone HTTP Streaming with FFMpeg and an Open Source Segmenter

  1. Srini

    Can somebody post the segmenter binary for leopard? I am simply not able to build it :(

    Thanks.

  2. TonyPel

    If someone has the compiled binaries of the Segmenter for Fedora 11 (i586) I would really appreciate it. Thanks.

  3. jonathan

    fwiw, on my Ubuntu 9.04 system, the segmenter Makefile line that worked was:

    gcc -Wall -g segmenter.c -o segmenter -lavformat -lavcodec -lavutil -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread

    (I had to add -lpthread, and remove -lbz2)

  4. mOlind

    to build segmenter on mac os x leopard or snow leopard
    install ffmpeg from macports
    sudo port install ffmpeg +x264 +lame +faac
    then change segmenter Makefile to
    all:
    gcc -Wall -g segmenter.c -o segmenter -L/opt/local/lib -I/opt/local/include -lavformat -lavcodec -lavutil
    and segmenter will works fine.

    but i'm have trouble with video encoding. i'm always got "Incorrect frame size"
    error.

  5. ahefner

    I am also having the same problem. "Incorrect frame size" not sure what else to try. Have scoured over Google but haven't come up with anything that work.

    My segmenter works fine but can't seem to get ffmpeg to work correctly.

    Anyone have any ideas?

  6. ahefner

    After much research and tons of trail and error I have been able to get the ffmpeg encoder to create a ts file that can be streamed. Below is my config.

    ffmpeg -i input-file -f mpegts -acodec libmp3lame -ar 48000 -ab 1000k -s 320×240 -vcodec libx264 -b 96k -flags +loop -cmp +chroma -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 output-file

  7. Andrew Myers

    Thanks for this excellent article.

    Just one note – when I cut and pasted the code for the ffmpeg command I found that the "x" characters didn't work with my system.

    ie. the "x" in 320×240 and the "x"s in +parti4×4+partp8×8+partb8×8

    This gave the "Incorrect frame size" error, and it took me quite a while to figure out what the cause was.

    I thought I'd let folks know as perhaps this will assist others experiencing the same issue.

  8. Pingback: HTTP streaming. Segen oder Fluch? Flegen. | Nikolai Longolius - Ideen aus der Cloud

  9. Pingback: Brincando com a libavcodec e libavformat | Blog do PacMan

  10. Matthias Subik

    Great tutorial, I try to get our community tv station to the iPhone.
    But I feel there is something wrong with the timestamps. I hardly get a lipsync video,
    (skipping forward, reloading, never on the first load), and I get the
    (just a few of this) [mpegts @ 0x8071be0]dts = 12852879
    Warning: Could not write frame of stream

    So I assume my timestamps get messed up.
    I use a hardware mpeg2 encoder, transcode with vlc, receive with vlc, feed via pipe to segmenter
    Is there anyway to regenerate proper times in the segmenter, or the vlc before that? It seems that different people have comments that lead to problems with dts/pts.

  11. Henk Schoneveld

    You say, like others:
    Now you have a complete video but you don't want to toss the entire thing up or you wouldn't be reading about HTTP streaming.

    Could you explain why I wouldn't "toss the entire thing up"

    Sorry for stupid questions.

    Henk Schoneveld

  12. Henk Schoneveld

    Answering my own question.

    It's because of the limitations of the iPhone/iPod-Touch client.

    I read it in Apple's FAQ.

    Is this a real-time delivery system?

    No. It has inherent latency corresponding to the size and duration of the media files containing stream segments. At least one segment must fully download before it can be viewed by the client,

  13. Ricc

    great work, mate! :-)

    I've been playing around with FFMpeg. I'm running it on Windows and I haven't worked out the segmented part yet, my priority [was] the quality.

    My target video was 3G only with bitrate <384kbps for audio+video. which was ok when I was compressing video using the same settings on different applications.

    I did make a few changes to your parameters to try and produce a video that would look slightly better on the iPhone, however, either using your command line or mine, the output will play on the iPhone but just audio, no video. Any suggestions?

    ffmpeg -v 1 -i InputVideo.avi -y -f mpegts -acodec libfaac -ar 48000 -ac 2 -ab 64k -s 480x320 -vtag mp4v -vcodec libx264 -b 300k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 24 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 300k -bufsize 512k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 OutputVideo.ts

  14. Robert

    I would like to use the segmenter on windows server 2003 OS, but have never compiled anything in my life. I don't even know if the open source segmenter is written in C or C++. Can someone post detailed "instructions for dummies" how to compile it to work on windows 2003 server? I may already have or can get all compiling tools if you tell me what I need.

    Or, can someone post a link to a working copy of compiled segmenter for windows?

  15. Phil

    I am trying to get the http_streamer and live_segmenter up and running .. but it seems i am having a problem with ffmpeg

    I am using the ffmpeg command seen below …

    ==============================================
    FFMPEG COMMAND****************************************************
    phil@ubuntu:~/segmenter$ ffmpeg -er 4 -y -i /home/phil/Desktop/test.avi -f mpegts -s 320×240 -vcodec libx264 -b 128k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 128k -maxrate 128k -bufsize 128k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 /home/phil/Desktop/output.ts
    FFMPEG COMMAND****************************************************

    FFmpeg version SVN-r20263, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    built on Oct 17 2009 13:35:15 with gcc 4.3.3
    configuration: –enable-gpl –enable-nonfree –enable-pthreads –enable-libfaac –enable-libfaad –enable-libmp3lame –enable-libtheora –enable-libx264
    libavutil 50. 3. 0 / 50. 3. 0
    libavcodec 52.37. 0 / 52.37. 0
    libavformat 52.39. 2 / 52.39. 2
    libavdevice 52. 2. 0 / 52. 2. 0
    libswscale 0. 7. 1 / 0. 7. 1
    Input #0, avi, from '/home/phil/Desktop/test3_no_audio.avi':
    Duration: 00:00:30.03, start: 0.000000, bitrate: 30437 kb/s
    Stream #0.0: Video: dvvideo, yuv411p, 720×480, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Stream #0.1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    [libx264 @ 0x9fd8040]using SAR=1/1
    [libx264 @ 0x9fd8040]using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
    [libx264 @ 0x9fd8040]profile Baseline, level 3.0
    Output #0, mpegts, to '/home/phil/Desktop/output.ts':
    Stream #0.0: Video: libx264, yuv420p, 320×240 [PAR 1:1 DAR 4:3], q=10-51, 128 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: mp2, 48000 Hz, 2 channels, s16, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Press [q] to stop encoding

    ERROR HERE************************************************************
    [mpegts @ 0x9fd6eb0]dts < pcr, TS is invalidime=3.47 bitrate= 257.9kbits/s
    ERROR HERE************************************************************

    frame= 900 fps= 75 q=-1.0 Lsize= 966kB time=30.03 bitrate= 263.4kbits/s
    video:473kB audio:235kB global headers:0kB muxing overhead 36.513419%
    Last message repeated 1370 times
    [libx264 @ 0x9fd8040]frame I:31 Avg QP:30.12 size: 2307
    [libx264 @ 0x9fd8040]frame P:869 Avg QP:36.83 size: 475
    [libx264 @ 0x9fd8040]mb I I16..4: 74.7% 0.0% 25.3%
    [libx264 @ 0x9fd8040]mb P I16..4: 6.3% 0.0% 0.3% P16..4: 19.3% 8.1% 1.1% 0.0% 0.0% skip:64.9%
    [libx264 @ 0x9fd8040]coded y,uvDC,uvAC intra: 18.7% 21.1% 8.1% inter: 7.8% 5.8% 0.1%
    [libx264 @ 0x9fd8040]i16 v,h,dc,p: 24% 45% 21% 9%
    [libx264 @ 0x9fd8040]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 17% 27% 7% 8% 6% 6% 6% 6%
    [libx264 @ 0x9fd8040]kb/s:128.94

    ==============================================

    does anyone have any ideas .. thanks

  16. Zen of Linux

    I've got major dts < pcr issues here while letting a very recent ffmpeg encode the mpeg ts stream. An older version of ffmpeg does not produce this.
    Could you please share your exact ffmpeg revision number?

  17. Phil

    Sorry to get back to this so late .. It shows in my last post what version of FFMPEG I have …

    FFmpeg version SVN-r20263

    So if I used an older version of FFMPEG, that should alleviate this problem?

  18. Sagar

    I used http://ubuntuforums.org/showpost.php?p=8345112&postcount=636
    to get the ffmpeg running on my ubuntu system.

    then did : make install for ffmpeg

    Used this to encode the mp4 files :
    ffmpeg -i "$1" -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320×240 -vcodec libx264 -b 96k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 "$2"

    And, got the segmenter from
    http://svn.assembla.com/svn/legend/segmenter/

    And changed the gcc line of make file to:
    gcc -Wall -g segmenter.c -o segmenter -L/home/Desktop/ffmpeg/libavformat -lavformat -L/home/Desktopffmpeg/libavcodec -lavcodec -L/home/Desktop/ffmpeg/libavutil -lavutil -I/home/Desktop/ffmpeg/ -lm -lmp3lame -lxvidcore -lx264 -lfaad -lfaac -lbz2 -lpthread -lz

    Don't know why it needed all libs but it finally worked for me :)

  19. Phil

    That is where I got my version of ffmpeg from to .. but I am not converting to mp4 files. When I convert to mp4 I have no problems. I am converting to an mpeg-ts file and when I do that, that is when I get the error …

    dts < pcr, TS is invalid

    and I have not been able to figure out why I get this error.

  20. Pingback: HTTP Live Streaming to the iPhone | Zen of Linux

  21. Mark

    I'm in the same boat as the rest of the dts < pcr, TS is invalid people ——- Anyone know a fix for this? Alternatively who actually develops the segmenter is there a forum for this somewhere?

  22. Clint J.

    Two questions:

    1. I'm curious about cleaning up the .ts files? My cameras run live 24×7, I need to make sure only the current .ts files are in the file system.

    2. AND does anyone have a real-time implementation where you only segment when at least one user is accessing the web directory similar to a streaming server ?

    I need to allow access to hundreds of cameras….

  23. Clint J.

    Never mind my first question previously posted, after looking closely at the segmenter I see it now supports windowed streams, and seems to work fine when I tested it on Ubuntu Linux.

    At this point I really need to run a segmenter on a Windows server because I'm encoding hundreds of Windows Media streams.

    I was succesful compiling segmenter.c on Windows using MinGW and MSys and of course the FFmpeg libraries, however the behavior is not right.

    On Windows I'm seeing two m3u8 files, one called stream.m3u8 and one .stream.m3u8, and the .ts file cleanup doesn't take place when adding a windowing size.

    I don't have any experience porting applications from *nix to Windows, has anyone successfully ported the segmenter ?

  24. Peter S.

    I'm currently working on a Java based Wrapper for ffmpeg and the segmenter. Therefore I also ported the segmenter to Windows. I have the same issue like Clint, and that's why I removed the playlist creation from segmenter code and it's now being done in Java. My Project also serves a http server for distributing the files. That's all running quite well now, but I have problems that the Iphone stops playback after at about half an hour. I also have to mention, that I specify the muxrate manually in the Segmenter code, because ffmpeg calculates a too low muxrate. The ffmpeg command from carson didn't work for me. The Iphone stopped playing after a few minutes.
    I specified the muxrate by summing up the audio bitrate and the video bitrate and added 10% of that value. But as i mentioned, the stream still stops after at about half an hour.
    Any suggestions?

  25. Ricc

    @Peter S.: You've managed to get the segmenter to work on Win32? I've been trying to compile it unsucessfully. Mingw returns so many errors! Please mate, give me some clues.

    @Carson & everyone: I've been looking for a solution to the segmenter.
    Imagine the scenario: you're transcoding a 3 hour lenth video with ffmpeg, let's say FFMPEG has just started transcoding it, the segmenter should check the (ts) output, slice whatever has been done, sit and wait 5 seconds, and do it all again, either carrying on from where it stopped or right from the start without rewriting the previous segments.
    In regards to the m3u8 file it DOES NOT have to be generated by the segmenter as it will be generated by php at the request point. On my project php checks the original avi length and generates the .m3u8. file. ffmpeg will have already started to trascode and the segmenter to slice. The viewer starts to get content in less than a minute.
    It works flawlessly if I put things to spin manually… ahmm not completely as the Segmenter is still not playing ball. Any help would be more than welcome! riccardoquintan@gmail.com

  26. Peter S.

    @Ricc: Take a look at http://ffmpeg.arrozcru.com/. I used Visual Studio C++ Express for doing the job. On the Website everything is explained in detail.

    @Alberto: Definely the specification of a higher muxrate fixes the problem in ffmpeg. But you still have the issue on the iphone. If you specify a higher (wrong) muxrate in the segmenter, the iphone stops playing after a while, or if it's too high it even doesn't play it. I also have to say, that I have different results with aac or mp3 ecnoding. By specifying the normal aac in ffmpeg I even get no sound. Sound is just played with libfaac.

  27. Clint J

    I've been trying to use VLC to transcode a live Windows Media stream to H.264 and then segment for iPhone on Ubuntu 9.10

    Windows Media 9 Streaming Video –> VLC –> segmenter

    I'm using a mkfifo pipe to transmit the stream to the segmenter

    mkfifo /tmp/streampipe

    vlc -vvv http://myserver.com/publishingpoint01 –sout '#transcode{vcodec=h264,vb=200,scale=1,acodec=none}:std{access=file,mux=ts,dst=/tmp/streampipe}'

    segmenter /tmp/streampipe 10 stream stream.m3u8 http://myserver.com/ 5

    I believe my VLC Stream is fine, but the segmenter produces .ts files that do not show motion video despite the seemingly large file sizes (approx. 500k), occasionally I see a still image from one of the .ts files.

    I do get this error on the console from segmenter:

    [NULL @ 0x172b830]non-existing PPS referenced
    [h264 @ 0x172b830]B picture before any references, skipping
    [h264 @ 0x172b830]decode_slice_header error
    [h264 @ 0x172b830]no frame!
    [mpegts @ 0x1717180]max_analyze_duration reached
    [mpegts @ 0x1717180]Estimating duration from bitrate, this may be inaccurate
    Output #0, mpegts, to '/var/www/stream':
    Stream #0.0: Video: libx264, yuv420p, 320×240, q=2-31, 90k tbn, 30 tbc
    [mpegts @ 0x172bc80]st:0 error, non monotone timestamps 7389740048 >= 7389740048
    Warning: Could not write frame of stream
    [mpegts @ 0x172bc80]st:0 error, non monotone timestamps 7389758138 >= 7389758138
    Warning: Could not write frame of stream
    [mpegts @ 0x172bc80]st:0 error, non monotone timestamps 7389770108 >= 7389770108
    Warning: Could not write frame of stream
    [mpegts @ 0x172bc80]st:0 error, non monotone timestamps 7389788108 >= 7389788108
    Warning: Could not write frame of stream
    [mpegts @ 0x172bc80]st:0 error, non monotone timestamps 7389803138 >= 7389803138
    Warning: Could not write frame of stream

    Does this have anything to do with the (dts < pcr, TS) issue you are talking about ?

  28. Alberto

    Regarding my comment above, this guy came up with some change in "/libavformat/mpegtsenc.c" so I followed his advice and I compiled the new mpegtsenc.c (modified) and I was able to run ffmpeg to create a " .ts video file". I was able to run this video file with vlc player without a problem. BUT … When I compile the segmenter with the new AV format library (mpegtsenc.c -> modified), I still get the " dts < pcr, TS" error.

    This is the link with bug/patch:
    http://roundup.ffmpeg.org/roundup/ffmpeg/issue1279

    This patch /bug is actually not fixing the whole " dts < pcr, TS" error but is somewhere in the right direction. It has to do with the muxrate.

    Carson from ioncannon, since you were successful with this test, could you please tell us what FFMPEG revision # did you use for this whole experiment? and also what x264. month-day-snapshot did u compile it with? I am using lame (mp3s) version 3.97 since the other newer version will crash the enconding process .

    I want to do a SVN with your revision number
    svn checkout -r 15761 svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg-svn
    and download the exact x264
    ftp://ftp.videolan.org/pub/videolan/x264/snapshots/

    Thank to all!!
    Alberto

  29. Phil

    Hey guys, I am trying to run the live_segmenter.c using the scp_dev transfer profile and I get the following error (seen below between the *) .. I have no idea why I get this error .. any help is appreciated .. thanks

    phil@ubuntu:~/segmenter$ ruby http_streamer.rb config-simple.yml
    I, [2009-12-18T21:43:32.829643 #3409] INFO — : HTTP Streamer started
    I, [2009-12-18T21:43:32.830139 #3409] INFO — : Transfer thread started
    I, [2009-12-18T21:43:32.830357 #3409] INFO — : Encoding thread started
    D, [2009-12-18T21:43:32.830719 #3409] DEBUG — : Executing: ffmpeg -er 4 -y -i /home/phil/Desktop/Untitled.avi -f mpegts -acodec libfaac -ar 48000 -ab 64k -s 240×160 -vcodec libx264 -b 128k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 128k -maxrate 128k -bufsize 128k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 240:160 -g 30 -async 2 – | ./live_segmenter 10 /tmp/ sample_ep_128k ep_128k
    D, [2009-12-18T21:43:34.870114 #3409] DEBUG — : Encoder ep_128k: FFmpeg version SVN-r20894, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    built on Dec 18 2009 21:28:09 with gcc 4.4.1
    configuration: –enable-gpl –enable-version3 –enable-nonfree –enable-pthreads –enable-libfaac –enable-libfaad –enable-libx264 –enable-x11grab
    libavutil 50. 7. 0 / 50. 7. 0
    libavcodec 52.43. 0 / 52.43. 0
    libavformat 52.44. 0 / 52.44. 0
    libavdevice 52. 2. 0 / 52. 2. 0
    libswscale 0. 7. 2 / 0. 7. 2
    Input #0, avi, from '/home/phil/Desktop/Untitled.avi':
    Duration: 00:00:30.03, start: 0.000000, bitrate: 30437 kb/s
    Stream #0.0: Video: dvvideo, yuv411p, 720×480, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Stream #0.1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
    [libx264 @ 0x9d4af30]using SAR=1/1
    [libx264 @ 0x9d4af30]using cpu capabilities: MMX2 Cache64
    [libx264 @ 0x9d4af30]profile Baseline, level 3.0
    Output #0, mpegts, to 'pipe:':
    Stream #0.0: Video: libx264, yuv420p, 240×160 [PAR 1:1 DAR 3:2], q=10-51, 128 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: aac, 48000 Hz, 2 channels, s16, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Press [q] to stop encoding
    frame= 9 fps= 0 q=-10220098.7 size= 1kB time=0.47 bitrate= 9.6kbits/s
    D, [2009-12-18T21:43:44.420978 #3409] DEBUG — : Segment command ep_128k: *1, 1, 0, ep_128k*
    I, [2009-12-18T21:43:44.488070 #3409] INFO — : Transfer initiated
    D, [2009-12-18T21:43:44.488406 #3409] DEBUG — : 1, 1, 0, ep_128k
    D, [2009-12-18T21:43:44.488804 #3409] DEBUG — : Creating index
    D, [2009-12-18T21:43:44.528459 #3409] DEBUG — : Done creating index

    ************************************************************************
    E, [2009-12-18T21:43:45.663253 #3409] ERROR — : Error running transfer: Connection refused – connect(2)
    ************************************************************************

    I, [2009-12-18T21:43:45.663566 #3409] INFO — : Transfer done
    D, [2009-12-18T21:43:51.224592 #3409] DEBUG — : Segment command ep_128k: *1, 2, 0, ep_128k*
    I, [2009-12-18T21:43:51.225157 #3409] INFO — : Transfer initiated
    D, [2009-12-18T21:43:51.225311 #3409] DEBUG — : 1, 2, 0, ep_128k
    D, [2009-12-18T21:43:51.225551 #3409] DEBUG — : Creating index
    D, [2009-12-18T21:43:51.225975 #3409] DEBUG — : Done creating index

    ************************************************************************
    E, [2009-12-18T21:43:52.230655 #3409] ERROR — : Error running transfer: Connection refused – connect(2)
    ************************************************************************

    I, [2009-12-18T21:43:52.231133 #3409] INFO — : Transfer done

  30. Phil

    Update

    I fixed the problem I was having as mentioned in the post above this one .. it was due to the fact that I did not install ssh package for Ubuntu.

  31. John

    So I'm trying to get this streamer up and running using the scp protocol. I think im almost there but I am stuck and can not figure out how to fix it .. here is the problem

    i run .. ruby http_streamer.rb config-simple.yml

    and in the transfer profile of the config file i have…
    scp_dev:
    transfer_type: 'scp'
    remote_host: '192.168.1.125'
    user_name: 'root'
    directory: '/web/sites/test.com/html/streamingvideo'

    in terminal i get this …

    Press [q] to stop encoding
    frame= 25 fps= 0 q=-10219826.7 size= 1kB time=1.00 bitrate= 4.5kbits/s
    D, [2009-12-23T15:09:03.671393 #7404] DEBUG — : Segment command ep_128k: *1, 1, 0, ep_128k*
    I, [2009-12-23T15:09:03.672012 #7404] INFO — : Transfer initiated
    D, [2009-12-23T15:09:03.672204 #7404] DEBUG — : 1, 1, 0, ep_128k
    D, [2009-12-23T15:09:03.672381 #7404] DEBUG — : Creating index
    D, [2009-12-23T15:09:03.672780 #7404] DEBUG — : Done creating index
    E, [2009-12-23T15:09:04.532599 #7404] ERROR — : Error running transfer: root
    I, [2009-12-23T15:09:04.532825 #7404] INFO — : Transfer done

    now in the http_streamer.rb file if i replace transfer_config['user_name'] with transfer_config['root'] .. i get this error in the terminal ..

    Press [q] to stop encoding
    frame= 36 fps= 0 q=30.0 size= 5kB time=0.20 bitrate= 210.3kbits/s
    D, [2009-12-23T15:11:03.898999 #7462] DEBUG — : Segment command ep_128k: *1, 1, 0, ep_128k*
    I, [2009-12-23T15:11:03.899640 #7462] INFO — : Transfer initiated
    D, [2009-12-23T15:11:03.899831 #7462] DEBUG — : 1, 1, 0, ep_128k
    D, [2009-12-23T15:11:03.899988 #7462] DEBUG — : Creating index
    D, [2009-12-23T15:11:03.900380 #7462] DEBUG — : Done creating index
    E, [2009-12-23T15:11:04.724050 #7462] ERROR — : Error running transfer: Net::SSH::AuthenticationFailed
    I, [2009-12-23T15:11:04.724280 #7462] INFO — : Transfer done

    I have spent countless hours on this and have been unable to come up with a solution .. any help is greatly appreciated thank you…

  32. Phil

    So I'm trying to get this streamer up and running using the scp protocol. I think im almost there but I am stuck and can not figure out how to fix it .. here is the problem

    i run .. ruby http_streamer.rb config-simple.yml

    and in the transfer profile of the config file i have…
    scp_dev:
    transfer_type: 'scp'
    remote_host: '192.168.1.125'
    user_name: 'root'
    directory: '/web/sites/test.com/html/streamingvideo'

    in terminal i get this …

    Press [q] to stop encoding
    frame= 25 fps= 0 q=-10219826.7 size= 1kB time=1.00 bitrate= 4.5kbits/s
    D, [2009-12-23T15:09:03.671393 #7404] DEBUG – : Segment command ep_128k: *1, 1, 0, ep_128k*
    I, [2009-12-23T15:09:03.672012 #7404] INFO – : Transfer initiated
    D, [2009-12-23T15:09:03.672204 #7404] DEBUG – : 1, 1, 0, ep_128k
    D, [2009-12-23T15:09:03.672381 #7404] DEBUG – : Creating index
    D, [2009-12-23T15:09:03.672780 #7404] DEBUG – : Done creating index
    E, [2009-12-23T15:09:04.532599 #7404] ERROR – : Error running transfer: root
    I, [2009-12-23T15:09:04.532825 #7404] INFO – : Transfer done

    now in the http_streamer.rb file if i replace transfer_config['user_name'] with transfer_config['root'] .. i get this error in the terminal ..

    Press [q] to stop encoding
    frame= 36 fps= 0 q=30.0 size= 5kB time=0.20 bitrate= 210.3kbits/s
    D, [2009-12-23T15:11:03.898999 #7462] DEBUG – : Segment command ep_128k: *1, 1, 0, ep_128k*
    I, [2009-12-23T15:11:03.899640 #7462] INFO – : Transfer initiated
    D, [2009-12-23T15:11:03.899831 #7462] DEBUG – : 1, 1, 0, ep_128k
    D, [2009-12-23T15:11:03.899988 #7462] DEBUG – : Creating index
    D, [2009-12-23T15:11:03.900380 #7462] DEBUG – : Done creating index
    E, [2009-12-23T15:11:04.724050 #7462] ERROR – : Error running transfer: Net::SSH::AuthenticationFailed
    I, [2009-12-23T15:11:04.724280 #7462] INFO – : Transfer done

    I have spent countless hours on this and have been unable to come up with a solution .. any help is greatly appreciated thank you

  33. Trevor

    So after a lot of time this vacation, I was able to get the segmenter compiled on Windows 7 using MinGW/Msys. This is the gcc line that I used to compile:

    gcc -Wall -g segmenter.c -o segmenter.exe -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lpthread -lfaad -lgsm -lvorbis -lopencore-amrnb -lopencore-amrwb -ltheora -lspeex -lxvidcore -lwsock32 -L/mingw/lib -I/mingw/include

    I included all of the same libraries that I compiled into FFMPEG. Hope this helps everyone on the thread that was looking for a Windows version.

  34. Matt

    To fix the segmenter so it works properly in Windows, you need to add a line above the call to "rename". This is due to "rename" working slightly differently in windows than linux.

    about line 142 or so:

    fclose(index_fp);
    return rename(tmp_index, index);

    becomes

    fclose(index_fp);
    // windows rename fails if the destination file exists
    unlink(index);
    return rename(tmp_index, index);

  35. Ricc

    @Trevor: nah mate, still no joy with the compilation under Windows.

    I am currently running a small linux guest JUST for the segmenting task which I personally think it's a waste of resources as all of the other applications are running on Windows. my little media server is working ok but without linux running on VirtualBox I increase the average transcoding rate by 20 to 30 fps….

    I would be so grateful if you, or anyone else who had successfuly compiled this segmenter for Windows could share it. thanks in advance.

  36. Peter S.

    Have you guys ever tried to use the segmenter for a longer time? No matter what OS. It does not work for me… The Video stops playing after a while.

  37. Dan

    Hey – Maybe can someone "dumb" this topic down a notch for me…. I'm a bit slow.

    I want to setup VOD for the iPhone and eventually set-top boxes (tivo,roku,etc)

    I've got a bunch of videos (mov, mp4) – how do I get them encoded into a streaming format, segmented and create the streaming index files?

    My plan to host the final files in a AWS S3 bucket – since that is cheaper than running cloud server instance 7/24 –

    The Catch, I want to do this on the windows platform? (Don't want to tie up the mac, and have a bunch of old pc's sitting around – and an old tivo series 2 for that matter, if that could work for encoding? )

    Is there software to do all this? All this command line stuff is just too geeky… no seriously, I'm looking to build out a simple workflow.

    Any thoughts. (be kind!)

  38. 29 Steps

    Hi I followed the example here down to the last detail and compiled ffmpeg and segmenter on the OS X 10.5. The problem arose when trying to use the segmenter after ffmpeg produce the ts file:

    dts < pcr, TS is invalid

    If anyone has managed to get the segmenter to work without the following error above could you please englightened me? The other option is to get hold of the apple segmenter but you must be on the iphone developer program. Other options would be to use the Wowza Media Server to try it out

  39. Matt

    If you are using Windows you can use TSMuxer to split the file instead of the segmenter suggested. This saved me having to try and compile it under Windows.

    Only tried it on a small 10 second clip split at 3 seconds creating 4 files, and had to create the m3u8 myself but it worked for that, need to see if TSMuxer can now accept live input instead of a file.

  40. Arild

    I have a question on how the segmenter handles the ts files. I have it running, my setup is IP camera –> VLC –> ffmpeg –> segmenter –> Apache2

    It seem like the first ts segment have some kind of header which all the following ts files does not have. This means that When I open the IPhone and try to start streaming a while after I started publishing the stream to the web server it will not work. It has to start reading the first ts file.
    Is this something that can be fixed in the ffmpeg command or is it a limitation in the current implementation of the segmenter?
    I would like to start a live stream and jump into the stream at any time, any help would be fantastic, I have strugled a while to get it all running and now it is just this final puzzle which need to be placed.

  41. Bryan Murphy

    Just wanted to let you guys know that I got streaming working on an Ubuntu 9.10 64bit server after an annoying process of trial and elimination. Thankfully, git bisect is awesome.

    These are the revisions of the most recent versions of the software that I can get to successfully build. This setup is currently streaming to my 1g iphone as I type this.

    ffmpeg revision e880dd116dc28957fa663cd55703817bb72df431
    libswscale revision abcb4191ddc81061de1b0083ea06d364836d616d
    x264 revision 3daa02e9c79ec46fd980bcfcd317df45539c91f6
    lame 3.98

    I suspect a newer version of lame will work, but this isthe first combo I've managed to get working successfully. All of these revisions are from Nov '09.

    Bryan

  42. Dave

    Hi , Thanks for all the info in here ! I need some suport !

    1. After seek the video via https streaming , video and audio lip sync not match .What do we have to check ?

    2. First loading video take more than 8-10 sec even access via Wifi. What do I have to check ?

    Thanks in advance

  43. Peter S.

    @ Bryan:

    Did you try various videos? And what was your ffmpeg command. I tried the versions you suggested, but it also doenst work for me on Win 7/Mingw.

  44. Paolo

    Hi All,
    I'm using the segmenter in order to stream my IPcam.
    The system is made of . The output is then streamed to a local TCP socket. Then reads from the tcp:// socket and pipes to the .

    The system works, but I experience a delay of about 15s if I use a 3 chuncks window with each chunck of 1s. I'm working on a LAN so no bandwidth problems. It seems that 8/9 seconds delay are added by ffmpeg before starting the transcoding, while the other 4/5 come from the iPhone caching video.Thanks a lot guys,
    Paolo

  45. Jon

    I had an issue compiling segmenter the error was:

    segmenter.c:242: warning: ‘guess_format’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:764)

    So I edited line 242 of segmenter.c and changed guess_format to av_guess_format

    Works fine now.

  46. TW

    Hello,

    so far encoding works fine with SVN-r18709 ffmpeg build (strange behaviour with certain builds though). I cannot compile the segmenter.c and I'd be happy if someone could share his successful build. Meanwhile I went with TSMuxer workaround in order to test the whole procedure after all, even though it's a very low standard workaround and involves manual tasks.
    As said a build of the segmenter would be highly appreciated. I'm not the best developer around and I really couldn't get this thing compiled (using mingw and dev-cc from bloodshed).
    Greetings and thanks for all the knowledge provided on ioncannon! Great work!
    TW

  47. Matt

    I'm no longer getting the dts < pcr thing after reinstalling ffmpeg using macports, however, now i'm getting the following… I didn't see anyone else on here that posted this, any ideas? This is what i'm using to encode…

    ffmpeg -i pr.mov -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 640×360 -vcodec libx264 -b 96k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 640:360 -g 30 -async 2 prOUT.ts

    [libx264 @ 0x1808200]VBV underflow (-2928 bits)=33.30 bitrate= 188.8kbits/s
    [libx264 @ 0x1808200]VBV underflow (-4450 bits)
    [libx264 @ 0x1808200]VBV underflow (-197 bits)
    [libx264 @ 0x1808200]VBV underflow (-60045 bits)
    [libx264 @ 0x1808200]VBV underflow (-8034 bits)
    [libx264 @ 0x1808200]VBV underflow (-2994 bits)
    [libx264 @ 0x1808200]VBV underflow (-12946 bits)
    [libx264 @ 0x1808200]VBV underflow (-3898 bits)=33.87 bitrate= 193.9kbits/s
    [libx264 @ 0x1808200]VBV underflow (-13890 bits)
    [libx264 @ 0x1808200]VBV underflow (-6498 bits)
    [libx264 @ 0x1808200]VBV underflow (-11754 bits)
    [libx264 @ 0x1808200]VBV underflow (-5058 bits)
    [libx264 @ 0x1808200]VBV underflow (-7650 bits)
    [libx264 @ 0x1808200]VBV underflow (-12306 bits)
    [libx264 @ 0x1808200]VBV underflow (-7674 bits)
    [libx264 @ 0x1808200]VBV underflow (-2990 bits)

  48. Wei

    My segmenter does work, but it works so weird. The command line is like this (I don't have a server now, so put a local directory here):

    segmenter sample-96k.ts 10 sample_low stream_low.m3u8 ./
    [mpegts @ 0xf42180]max_analyze_duration reached
    Output #0, mpegts, to 'sample_low':
    Stream #0.0: Video: 0x001b, yuv420p, 320×240, q=2-31, 90k tbn, 90k tbc
    Stream #0.1: Audio: 0x0003, 48000 Hz, 2 channels, 64 kb/s
    [mpegts @ 0xf575f0]stream 0, bit rate is not set, this will cause problems

    It keep running without stop. And only one ts file is generated (sample_low-1.ts) and it's getting bigger and bigger. The input file is only 1MB, but the sample_low-1.ts can be more than 5GB (I don't know how big it can be because I have to stop the program). The generated m3u8 file is as follows:
    #EXTM3U
    #EXT-X-TARGETDURATION:10

    What's wrong? Can anybody give an answer?

Leave a Reply

Your email address will not be published. Required fields are marked *