osmf-hls-plugin icon indicating copy to clipboard operation
osmf-hls-plugin copied to clipboard

Error: Error #2030: End of file was encountered.

Open sstankov opened this issue 11 years ago • 4 comments

Error while playing stream: http://player.webvideocore.net/9ekqwlx9hcg8.m3u8

Error: Error #2030: End of file was encountered.
    at flash.utils::ByteArray/readUnsignedShort()
    at HTTPStreamingMP2PESAudio/processES()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processES()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processPacket()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processFileSegment()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSStreamSource/doSomeProcessingAndGetBytes()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSStreamSource/getBytes()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSNetStream/onMainTimer()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
Error: Error #2030: End of file was encountered.
    at flash.utils::ByteArray/readUnsignedShort()
    at HTTPStreamingMP2PESAudio/processES()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processES()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processPacket()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPStreamingMP2TSFileHandler/processFileSegment()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSStreamSource/doSomeProcessingAndGetBytes()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSStreamSource/getBytes()
    at org.denivip.osmf.net.httpstreaming.hls::HTTPHLSNetStream/onMainTimer()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick() 

I;m not sure if the file do the bad thing, but please take a look.

Edit: here are more streams, that give me errors:

  • http://hls31.webvideocore.net:8082/6.m3u8
  • http://hls31.webvideocore.net:8082/5.m3u8
  • http://player.webvideocore.net/60yxuukuhpgk.m3u8 (btw here with your old plugin : http://hls32.webvideocore.net:8082/flu/t2/StrobeMediaPlayback.html?src=http://player.webvideocore.net/60yxuukuhpgk.m3u8 it is playing)

sstankov avatar Jan 06 '14 12:01 sstankov

I'll see what the problem in last changes.

D3adKnight avatar Jan 07 '14 15:01 D3adKnight

Just to confirm this one does not have sound http://hls31.webvideocore.net:8082/5.m3u8 but it plays fine here http://osmfhls.kutu.ru/ Will appreciate if you could solve these issues soon.

dido78 avatar Jan 08 '14 19:01 dido78

btw here with your old plugin

How old? Current version has some troubles in audio-decoder.

D3adKnight avatar Jan 16 '14 14:01 D3adKnight

I;m not sure, but I think it was with this class. I cannot say from what your repo version:

/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the at.matthew.httpstreaming package.
 *
 * The Initial Developer of the Original Code is
 * Matthew Kaufman.
 * Portions created by the Initial Developer are Copyright (C) 2011
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */
 
 package org.denivip.osmf.net.httpstreaming.hls
{
    import __AS3__.vec.Vector;
    
    import flash.utils.ByteArray;
    
    import org.osmf.logging.Log;
    import org.osmf.logging.Logger;
    import org.osmf.net.httpstreaming.flv.FLVTagAudio;
    internal class HTTPStreamingMP2PESAudio extends HTTPStreamingMP2PESBase
    {
        private var _state:int;
        private var _haveNewTimestamp:Boolean = false;
        private var _audioTime:Number;
        private var _audioTimeIncr:Number;
        private var _profile:int;
        private var _sampleRateIndex:int;   
        private var _channelConfig:int;
        private var _frameLength:int;
        private var _remaining:int; 
        private var _adtsHeader:ByteArray;
        private var _needACHeader:Boolean;
        private var _audioData:ByteArray;
        
        public function HTTPStreamingMP2PESAudio():void
        {
            _state = 0;
            _adtsHeader = new ByteArray();
            _needACHeader = true;   // need more than this, actually... 
        }
        
        
        private var srMap:Array = [ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 ];
        
        private function getIncrForSRI(srIndex:uint):Number
        {
        
            var rate:Number = srMap[srIndex];
            
            return 1024000.0/rate;  // t = 1/rate... 1024 samples/frame and srMap is in kHz
        }
        
        override public function processES(pusi:Boolean, packet:ByteArray, flush:Boolean = false): ByteArray {
            if(pusi)
            {
                // start of a new PES packet
                
                // Start code prefix and packet ID.
                
                value = packet.readUnsignedInt();
                packet.position -= 4;
                
                var startCode:uint =  packet.readUnsignedInt();
                if(startCode  0x1DF && startCode != 0x1bd)
                {
                        throw new Error("PES start code not found or not AAC/AVC");
                }
                // Ignore packet length and marker bits.
                packet.position += 3;
                // need PTS only
                var flags:uint = (packet.readUnsignedByte() & 0xc0) >> 6;
                if(flags != 0x02 && flags != 0x03)
                { 
                    throw new Error("No PTS in this audio PES packet");
                }
                var length:uint = packet.readUnsignedByte();
                var pts:Number =
                    ((packet.readUnsignedByte() & 0x0e) > 1);
                var timestamp:Number = Math.round(pts/90);
                _haveNewTimestamp = true;
                
                if(!_timestampReseted){
                    _offset += timestamp - _prevTimestamp;
                }
                _timestamp = _initialTimestamp + _offset;
                _prevTimestamp = timestamp;
                _timestampReseted = false;
                
                length -= 5;
                // no comp time for audio
                // Skip other header data.
                packet.position += length;
            }
        
            var value:uint;
            var tag:FLVTagAudio;
            var tagData:ByteArray = new ByteArray();
                        
            if(!flush)
            {
                var dStart:uint = packet.position;
            }
            
            if(flush)
            {
                ;
                CONFIG::LOGGING
                {
                    logger.info("audio flush at state "+_state.toString());
                }
            }
            else while(packet.bytesAvailable > 0)
            {
                
                
                if(_state > 6) & 0x03;
                        _sampleRateIndex = (value >> 2) & 0x0f;
                        _audioTimeIncr = getIncrForSRI(_sampleRateIndex);
                        // one private bit
                        _channelConfig = (value & 0x01) > 6) & 0x03; // rest of channel config
                        // orig/copy bit
                        // home bit
                        // copyright id bit
                        // copyright id start
                        _frameLength = (value & 0x03) > 5;
                        _remaining = _frameLength - 7;  // XXX crc issue?
                        // buffer fullness
                        break;
                    case 6:
                        _state = 7;
                        dStart = packet.position;
                        _audioData = new ByteArray();
                        // 6 more bits of buffer fullness
                        //2  bits number of raw data blocks in frame (add one to get count)
                        
                        if(_needACHeader)
                        {
                            tag = new FLVTagAudio();
                            tag.timestamp = _audioTime;
                            tag.soundFormat = FLVTagAudio.SOUND_FORMAT_AAC;
                            tag.soundChannels = FLVTagAudio.SOUND_CHANNELS_STEREO;
                            tag.soundRate = FLVTagAudio.SOUND_RATE_44K; // rather than what is reported
                            tag.soundSize = FLVTagAudio.SOUND_SIZE_16BITS;
                            tag.isAACSequenceHeader = true;
                            /*
                            var acHeader:ByteArray = new ByteArray();
                            acHeader[0] = (_profile + 1)> 1;
                            acHeader[1] = (_sampleRateIndex & 0x01) = _remaining)
                        {
                            packet.position += _remaining;
                            _remaining = 0;
                        }
                        else
                        {
                            var avail:uint = packet.length - dStart;
                            packet.position += avail;
                            _remaining -= avail;
                            _audioData.writeBytes(packet, dStart, packet.position-dStart);
                        }
                        if(_remaining > 0)
                        {
                            //
                        }
                        else
                        {
                            _audioData.writeBytes(packet, dStart, packet.position - dStart);
                            
                            _state = 0;
                            
                            tag = new FLVTagAudio();
                            tag.timestamp = _audioTime;
                            _audioTime += _audioTimeIncr;
                            tag.soundChannels = FLVTagAudio.SOUND_CHANNELS_STEREO;
                            tag.soundFormat = FLVTagAudio.SOUND_FORMAT_AAC;
                            tag.isAACSequenceHeader = false;
                            tag.soundRate = FLVTagAudio.SOUND_RATE_44K; // rather than what is reported
                            tag.soundSize = FLVTagAudio.SOUND_SIZE_16BITS;
                            tag.data = _audioData;
                            
                            tag.write(tagData); // unrolled out the vector for audio tags
                        }
                        break;
                } // switch
            } // while
            
            tagData.position = 0;
            
            return tagData;
        }
        
        CONFIG::LOGGING
        {
            private var logger:Logger = Log.getLogger('org.denivip.osmf.net.httpstreaming.hls.HTTPStreamingMP2PESAudio') as Logger;
        }
    }
}

sstankov avatar Jan 23 '14 21:01 sstankov