잠시만 기다려 주세요

     '민주당이 분열되어야 정치개혁이 시작된다.'
전체검색 :  
이번주 로또 및 연금번호 발생!!   |  HOME   |  여기는?   |  바다물때표   |  알림 (19)  |  여러가지 팁 (1095)  |  추천 및 재미 (163)  |  자료실 (28)  |  
시사, 이슈, 칼럼, 평론, 비평 (789)  |  끄적거림 (142)  |  문예 창작 (719)  |  바람 따라 (75)  |  시나리오 (760)  |  드라마 대본 (248)  |  
살인!


    golang

golang - Serve a video with golang, 동영상, 미디어 파일 오픈, 열어서 브라우저에 보여주기, mp4
이 름 : 바다아이   |   조회수 : 9752         짧은 주소 : https://www.bada-ie.com/su/?101591924971
미디어 스트리밍의 원리가 되겠네요... ^^; 
요즘 대부분 브라우저가 html5 가 지원되니까요.... 
그리고 각종 미디어 플레이어들이 스트리밍을 잘 지원하니까..
아래를 참고하면 간단하게 스트리밍 서버를 만들 수 있습니다.


In my last two posts I've shown how to generate a mp4 video file. 
In this post I show some go code to serve the generated file via http. 
It basically boils down to a call of ServeContent in the http package.

package main

import (
	"flag"
	"log"
	"net/http"
	"os"
	"path"
	"time"
)

func main() {
    fileName := flag.String("f","","filename to stream")
    flag.Parse()
    if fileName==nil || *fileName=="" {
        log.Println("File needed")
        return
    }
    baseName := path.Base(*fileName)
    file,err := os.Open(*fileName)
    if err!=nil {
        log.Println("Couldn't open file",fileName)
        return
    }
    http.HandleFunc("/stream",func(w http.ResponseWriter, r *http.Request) {
        http.ServeContent(w,r,baseName,time.Unix(0,0),file)
    })
    log.Fatal(http.ListenAndServe(":8010",nil))
}

To start the program type ./prog -f cool_movie.mp4 and then enter 
http://192.168.0.1:8010/stream in a browser on your smartphone 
(assuming you PC has the IP 192.168.0.1). I've tested it with Firefox and Chrome. 
Both could play the file but Firefox has no full screen mode and thus leaves 
the navigation bars active. A resized and shrinked video isn't what you want when playing 
around with cardboard VR.
출처 : https://jluger.de/blog/20160118_serve_a_video_with_golang.html
| |





      1 page / 6 page
번 호 카테고리 제 목 이름 조회수
180 golang golang ... 바다아이 107
179 golang golang , ... 바다아이 2686
178 golang golang , map . 바다아이 2075
177 golang Golang (, , data ) , ... 바다아이 2391
176 golang golang sort ... 바다아이 2775
175 golang golang html.EscapeString html.UnescapeString input value ... 바다아이 2693
174 golang golang go.mod go.sum . GOPATH SRC not module, 1.16 . 바다아이 6213
173 golang go 1.16 ... is not in GOROOT.. GOPATH .... . 바다아이 7364
172 golang , String Formatting 바다아이 8688
171 golang rand.Intn , random, , . 바다아이 8209
170 golang golang ... 바다아이 11956
169 golang golang gopath, goroot .. golang 바다아이 8938
168 golang golang ... Force download file example 바다아이 10953
167 golang golang , , cpu, memory, disk 바다아이 12024
166 golang golang , ... GOOS, GOARCH 바다아이 9682
165 golang golang checkbox ... 바다아이 9535
164 golang golang , , http .... 바다아이 9365
163 golang golang nil , nil , nil ... 바다아이 9442
162 golang 2 golang, go , .... golang .... 바다아이 12689
161 golang golang postgresql, mysql, mariadb ... ` Grave () .. .. 바다아이 9999
160 golang golang postgresql mysql, mariadb scan , null .. 바다아이 10057
159 golang golang , iconv 바다아이 12872
158 golang golang quote escape, unquote 바다아이 10302
157 golang golang , http errorLog , , ... 바다아이 10680
156 golang golang interface , 바다아이 9756
155 golang golang struct .... 바다아이 10483
154 golang golang map map , 바다아이 9973
153 golang golang map .... .... 바다아이 9296
152 golang golang slice copy 바다아이 9484
151 golang golang goto 바다아이 10676
| |









Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb ]
서버위치 : 오라클 클라우드 춘천  실행시간 : 0.2013
to webmaster... gogo sea. gogo sea.