あなたのiOSコードはうまくいきますし、主にm3u8プレイリストの生成に関して、そして恐らくそれが参照するtsファイルをホストしているかどうかに関して、問題の原因となっているのはサーバーサイドのコードです。
残念ながら私の例のコードは1年前に書きましたが(コードはPythonです)、それはあなたが求めている以上のものです(正しいm3u8/tsにビデオをライブトランスコードしています)もの)しかしそれはテストされ、機能的です。
あなたがここにコードを見てとることができます。
を私はあなたの便宜のためにここに関連するメソッドの一部を貼り付けます。私はそれがあなたの役に立てば幸い:
def start_transcoding(self, videoPath):
if DISABLE_LIVE_TRANSCODE:
print "Live transcoding is currently disabled! There is a problem with your configuration."
return
print "Initiating transcode for asset at path: "+videoPath
videoPath = unquote(videoPath)
video_md5 = md5.new(videoPath).hexdigest()
if self.sessions.has_key(video_md5): # Session already exists?
return self.m3u8_bitrates_for(video_md5)
transcodingSession = TranscodeSession(self, videoPath)
if transcodingSession.can_be_decoded():
self.sessions[transcodingSession.md5] = transcodingSession
return self.m3u8_bitrates_for(transcodingSession.md5)
else:
return "Cannot decode this file."
def m3u8_segments_for(self, md5_hash, video_bitrate):
segment = string.Template("#EXTINF:$length,\n$md5hash-$bitrate-$segment.ts\n")
partCount = math.floor(self.sessions[md5_hash].duration/10)
m3u8_segment_file = "#EXTM3U\n#EXT-X-TARGETDURATION:10\n"
for i in range(0, int(partCount)):
m3u8_segment_file += segment.substitute(length=10, md5hash=md5_hash, bitrate=video_bitrate, segment=i)
last_segment_length = math.ceil((self.sessions[md5_hash].duration - (partCount * 10)))
m3u8_segment_file += segment.substitute(length=last_segment_length, md5hash=md5_hash, bitrate=video_bitrate, segment=i)
m3u8_segment_file += "#EXT-X-ENDLIST"
return m3u8_segment_file
def m3u8_bitrates_for(self, md5_hash):
m3u8_fudge = string.Template(
"#EXTM3U\n"
# "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=384000\n"
# "$hash-384-segments.m3u8\n"
# "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=512000\n"
# "$hash-512-segments.m3u8\n"
"#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=768000\n"
"$hash-768-segments.m3u8\n"
# "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1024000\n"
# "$hash-1024-segments.m3u8\n"
)
return m3u8_fudge.substitute(hash=md5_hash)
def segment_path(self, md5_hash, the_bitrate, segment_number):
# A segment was requested.
path = self.sessions[md5_hash].transcode(segment_number, the_bitrate)
if path:
return path
else:
raise "Segment path not found"
プロジェクトは現在、すべてのオープンソースであり、ここで見つけることができる:https://github.com/DFTi/ScribbeoServer/tree/python
バイナリはここで見つけることができます:http://scribbeo.com/server
幸運を!
アップルのhttpストリームバリデーターを試してみてください。 http://developer.apple.com/library/ios/#technotes/tn2235/_index.html – Till
@Till Hey私はそれを試しましたが、ストリームバリデーターは何の結果も与えません。また、私のm3u8ファイルのURLを与えるとそれはたくさん読み込まれ、ファイルやそのようなものを受け取ることができない書き込みをし、何が間違っているのか分かりません。 – Lukas
M3U8を慎重に検査し、含まれているURLに実際に到達可能かどうかを確認してください。 – Till