mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 06:42:25 -05:00 
			
		
		
		
	[feature] Enable basic video support (mp4 only) (#1274)
* [feature] basic video support * fix missing semicolon * replace text shadow with stacked icons Co-authored-by: f0x <f0x@cthu.lu>
This commit is contained in:
		
					parent
					
						
							
								0f38e7c9b0
							
						
					
				
			
			
				commit
				
					
						2bbc64be43
					
				
			
		
					 39 changed files with 6276 additions and 93 deletions
				
			
		
							
								
								
									
										68
									
								
								vendor/github.com/abema/go-mp4/write.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								vendor/github.com/abema/go-mp4/write.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,68 @@ | |||
| package mp4 | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"io" | ||||
| ) | ||||
| 
 | ||||
| type Writer struct { | ||||
| 	writer  io.WriteSeeker | ||||
| 	biStack []*BoxInfo | ||||
| } | ||||
| 
 | ||||
| func NewWriter(w io.WriteSeeker) *Writer { | ||||
| 	return &Writer{ | ||||
| 		writer: w, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (w *Writer) Write(p []byte) (int, error) { | ||||
| 	return w.writer.Write(p) | ||||
| } | ||||
| 
 | ||||
| func (w *Writer) Seek(offset int64, whence int) (int64, error) { | ||||
| 	return w.writer.Seek(offset, whence) | ||||
| } | ||||
| 
 | ||||
| func (w *Writer) StartBox(bi *BoxInfo) (*BoxInfo, error) { | ||||
| 	bi, err := WriteBoxInfo(w.writer, bi) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	w.biStack = append(w.biStack, bi) | ||||
| 	return bi, nil | ||||
| } | ||||
| 
 | ||||
| func (w *Writer) EndBox() (*BoxInfo, error) { | ||||
| 	bi := w.biStack[len(w.biStack)-1] | ||||
| 	w.biStack = w.biStack[:len(w.biStack)-1] | ||||
| 	end, err := w.writer.Seek(0, io.SeekCurrent) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	bi.Size = uint64(end) - bi.Offset | ||||
| 	if _, err = bi.SeekToStart(w.writer); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if bi2, err := WriteBoxInfo(w.writer, bi); err != nil { | ||||
| 		return nil, err | ||||
| 	} else if bi.HeaderSize != bi2.HeaderSize { | ||||
| 		return nil, errors.New("header size changed") | ||||
| 	} | ||||
| 	if _, err := w.writer.Seek(end, io.SeekStart); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return bi, nil | ||||
| } | ||||
| 
 | ||||
| func (w *Writer) CopyBox(r io.ReadSeeker, bi *BoxInfo) error { | ||||
| 	if _, err := bi.SeekToStart(r); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if n, err := io.CopyN(w, r, int64(bi.Size)); err != nil { | ||||
| 		return err | ||||
| 	} else if n != int64(bi.Size) { | ||||
| 		return errors.New("failed to copy box") | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue