Skip to content

Change segment text before processing #5017

@shorts7wound

Description

@shorts7wound

What do you want to do with Hls.js?
so due to some sec reason i want to add some extra text to .ts file in the begining of so when parsing it causes buffering issues
to fix this i decided to removed that 'extra' text i added before processing the segment issue is i dont know how to manipulate arraybuffer so i can remove that text since i am not that knowledgable on js
What have you tried so far?


i tried many things including just download hlsjs file directly then edit readystatechange
  // >= HEADERS_RECEIVED
    if (readyState >= 2) {
....
          if (isArrayBuffer) 
          {
            console.log(xhr.response);
            var ress = xhr.response;
            //console.log(ress.replace('FFmpeg','')); 
            var enc = new TextDecoder('ASCII'); 
            var seg = enc.decode(ress);
            
  //var binaryArray = new Uint8Array(this.response.slice(0)); // use UInt8Array for binary
  //var blob = new Blob([seg], { type: "video/MP2T" }); 
            var enc = new TextEncoder(); // always utf-8 
            var newww = enc.encode(enc.encode(seg)); 
            var ddd = newww.buffer; 
            console.debug( newww );  
            console.debug( newww.buffer);  
            //dec = dec.replace('ÿØÿà �JFIF','') ; 
            //xhr.response = Array.from(newww) ;
            data = ddd;
            len = data.byteLength;

the idea was to convert arraybuffer to string remove that text then convert it back to arraybuffer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions