예제 #1
0
//export OpenMediaFile
func OpenMediaFile(filename string) {
	println("try openning the media file ")
	println(filename)
	cfilename := C.CString(filename)

	C.avcodec_register_all()
	C.av_register_all()
	ctx := C.avformat_alloc_context()

	result := C.av_open_input_file(&ctx, cfilename, nil, 0, nil)
	println(result)
	result = C.av_find_stream_info(ctx)
	C.free(unsafe.Pointer(cfilename))
	C.av_close_input_file(ctx)
	//C.free(unsafe.Pointer(ctx));
}
예제 #2
0
func init() {
	fmt.Println("Register all Formats")
	C.av_register_all()

	//  C.av_log_set_level(48);
}
예제 #3
0
파일: format.go 프로젝트: Dim0N22/gmf
func init() {
	C.av_register_all()
	C.avformat_network_init()
	C.avdevice_register_all()
}
예제 #4
0
func main() {

	var (
		fmt_ctx          *C.AVFormatContext
		video_stream_idx C.int
		pkt              C.AVPacket
		fn               string
	)
	flag.StringVar(&fn, "i", fn, "Input filename")
	flag.Parse()
	if fn == "" {
		flag.PrintDefaults()
		os.Exit(1)
	}
	cfn := C.CString(fn)
	defer C.free(unsafe.Pointer(cfn))
	C.av_register_all()
	if err := C.avformat_open_input(&fmt_ctx, cfn, nil, nil); err < 0 {
		log.Fatalf("Could not open source file %s, %d\n", fn, err)
	}
	// The smd codecs aren't too happy with missing PTS
	fmt_ctx.flags |= C.AVFMT_FLAG_GENPTS
	defer C.avformat_close_input(&fmt_ctx)
	if err := C.avformat_find_stream_info(fmt_ctx, nil); err < 0 {
		log.Fatalf("Could not find stream information: %d", err)
	}
	if err := open_codec_context(&video_stream_idx, fmt_ctx, C.AVMEDIA_TYPE_VIDEO); err < 0 {
		log.Fatalf("Could not open codec context: %d", err)
	}
	log.Printf("fmt_ctx: %+v", fmt_ctx)
	streams := (*[32]*C.AVStream)(unsafe.Pointer(fmt_ctx.streams))
	log.Printf("video stream codec: %+v", streams[video_stream_idx].codec.codec_id)

	log.Printf("time_base: %+v", streams[video_stream_idx].time_base)
	num := 1000000 * float64(streams[video_stream_idx].time_base.num)
	den := float64(streams[video_stream_idx].time_base.den)

	var codec C.ismd_codec_type_t
	switch vc := streams[video_stream_idx].codec.codec_id; vc {
	case C.AV_CODEC_ID_H264:
		codec = C.ISMD_CODEC_TYPE_H264
	case C.AV_CODEC_ID_MPEG1VIDEO:
		fallthrough
	case C.AV_CODEC_ID_MPEG2VIDEO:
		codec = C.ISMD_CODEC_TYPE_MPEG2
	case C.AV_CODEC_ID_MPEG4:
		codec = C.ISMD_CODEC_TYPE_MPEG4
	default:
		log.Fatalf("Unhandled video codec: %d", vc)
	}

	Init(codec, C.GDL_PLANE_ID_UPP_C)
	defer Destroy()

	C.av_init_packet(&pkt)
	pkt.data = nil
	pkt.size = 0

	running := true
	go func() {
		os.Stdin.Read(make([]byte, 1))
		running = false
	}()
	frame := 0
	for running && C.av_read_frame(fmt_ctx, &pkt) >= 0 {
		orig_pkt := pkt
		wrote := false
		for pkt.stream_index == video_stream_idx && (pkt.size > 0) {
			pts := num * float64(pkt.pts) / den
			WriteToInputPort(uintptr(unsafe.Pointer(pkt.data)), C.size_t(pkt.size), pts, 32*1024)
			wrote = true
			break
		}
		if wrote {
			frame++
			if frame%100 == 0 {
				var stat C.ismd_vidrend_stats_t
				C.ismd_vidrend_get_stats(m_video_render, &stat)
				log.Printf("%+v", stat)
			}
		}

		C.av_free_packet(&orig_pkt)
	}
}
예제 #5
0
파일: avformat.go 프로젝트: ovr/goav
//Initialize libavformat and register all the muxers, demuxers and protocols.
func AvRegisterAll() {
	C.av_register_all()
}
예제 #6
0
파일: format.go 프로젝트: 0x46616c6b/gmf
func init() {
	C.av_register_all()
}
예제 #7
0
파일: avformat.go 프로젝트: hyhy01/goav
//void av_register_all (void)
//Initialize libavformat and register all the muxers, demuxers and protocols.
func Av_register_all() {
	C.av_register_all()
}
예제 #8
0
func init() {
	C.av_register_all()
	C.avcodec_register_all()
}
예제 #9
0
func init() {
	C.avcodec_register_all()
	C.av_register_all()
	C.av_log_set_level(C.AV_LOG_VERBOSE)
}
예제 #10
0
func init() {
	C.av_log_set_level(C.AV_LOG_QUIET)
	C.av_register_all()
}