IPhone HTTP Streaming .m3u8 and .ts files – how to create using ffmpeg

ffmpegiphonevideo streamingvideo-encoding

I'm trying to get apple-validated http media streams using ffmpeg and am getting errors. Here are some error examples:

WARNING: Playlist Content-Type is 'application/x-mpegurl', but should
be one of 'application/vnd.apple.mpegurl', 'audio/x-mpegurl' or
'audio/mpegurl'.

WARNING: 258 samples (88.966 %) do not have timestamps in track 256
(avc1). 4: us2-1.ts
~~~~~~~~

WARNING: Media segment duration outside of expected duration by 47.733
% (5.23 vs. 10.00 seconds, limit is 20 %). 40: us2-19.ts
~~~~~~~~~

Average segment duration: 10.16 seconds
Average segment bitrate: 320.12 kbit/s
Average segment structural overhead: 175.89 kbit/s (54.94 %)

Video codec: avc1
Video resolution: 320x320 pixels
Video frame rate: 29.72, 29.78, 29.82, 30.00, 29.64 fps
Average video bitrate: 100.66 kbit/s
H.264 profile: Baseline
H.264 level: 3.0

Audio codec: aac 
Audio sample rate: 48000 Hz
Average audio bitrate: 43.57 kbit/s

Here is the end file I've been submitting: http://files.chesscomfiles.com/images_users/using/us2.m3u8

Here is the file I used to create this: http://files.chesscomfiles.com/images_users/using/using-computers-1.mp4

I've tried these commands, among others:

ffmpeg -i using-computers-1.mp4 -f mpegts -acodec libfaac -ar 48000
-ab 64k -s 320×320 -vcodec libx264 -vbsf h264_mp4toannexb -b 96k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 2 -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 -g 30 -async 2 us2.ts

ffmpeg -i using-computers-1.mp4 -f mpegts -acodec libfaac -ar 48000
-ab 64k -s 320×320 -vcodec libx264 -vbsf h264_mp4toannexb -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 -g 30 -async 2 us1.ts

ffmpeg -i using-computers-1.mp4 -vbsf h264_mp4toannexb -acodec copy -vcodec copy -f mpegts output.ts

If someone can help me figure out what ffmpeg commands I should be running I'd really appreciate it!

Best Answer

Regarding the first warning:

WARNING: Playlist Content-Type is 'application/x-mpegurl', but should be one of 'application/vnd.apple.mpegurl', 'audio/x-mpegurl' or 'audio/mpegurl'.

It could be from the server setup. Follow the instructions from Step 4 of this Ion Cannon post:

Prepare the HTTP server Upload a set of files that represent the stream and a stream definition file (ts and m3u8). 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" )

Related Topic