sample video; readme update; and example methods fix

This commit is contained in:
H.G. Giorgis
2015-08-27 22:37:34 -04:00
parent b6cd753eb5
commit beb1349151
8 changed files with 63 additions and 58 deletions
+9 -5
View File
@@ -38,20 +38,24 @@ func main() {
## Installation
``` sh
go get github.com/giorgisio/goav
```
[FFMPEG libraries] (https://github.com/FFmpeg/FFmpeg/blob/master/INSTALL.md)
``` sh
sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev
sudo apt-get install yasm
export FFMPEG_ROOT=$HOME/ffmpeg
export CGO_LDFLAGS="-L$FFMPEG_ROOT/lib/ -lavcodec -lavformat -lavutil -lswscale -lswresample -lavdevice -lavfilter"
export CGO_CFLAGS="-I$FFMPEG_ROOT/include"
export LD_LIBRARY_PATH=$HOME/ffmpeg/lib
```
```
go get github.com/giorgisio/goav
```
## Contribute
- Fork this repo and create your own feature branch.
- Follow standard Go conventions
+4 -4
View File
@@ -292,10 +292,10 @@ func Av_packet_split_side_data(p *AVPacket) int {
return int(C.av_packet_split_side_data((*C.struct_AVPacket)(p)))
}
//const char *av_packet_side_data_name (enum AVPacketSideDataType type)
func Av_packet_side_data_name(t AVPacketSideDataType) string {
return C.GoString(C.av_packet_side_data_name((C.enum_AVPacketSideDataType)(t)))
}
// //const char *av_packet_side_data_name (enum AVPacketSideDataType type)
// func Av_packet_side_data_name(t AVPacketSideDataType) string {
// return C.GoString(C.av_packet_side_data_name((C.enum_AVPacketSideDataType)(t)))
// }
//Pack a dictionary for use in side_data.
//uint8_t *av_packet_pack_dictionary (AVDictionary *dict, int *size)
+4 -4
View File
@@ -4,19 +4,19 @@
*/
package avcodec
func Codec_id(c *AVCodecContext) AVCodecID {
func (c *AVCodecContext) Codec_id() AVCodecID {
return (AVCodecID)(c.codec_id)
}
func Width(c *AVCodecContext) int {
func (c *AVCodecContext) Width() int {
return int(c.width)
}
func Height(c *AVCodecContext) int {
func (c *AVCodecContext) Height() int {
return int(c.width)
}
func Pix_fmt(c *AVCodecContext) AVPixelFormat {
func (c *AVCodecContext) Pix_fmt() AVPixelFormat {
return (AVPixelFormat)(c.pix_fmt)
}
+9 -9
View File
@@ -118,13 +118,13 @@ func Avdevice_free_list_devices(d **AVDeviceInfoList) {
C.avdevice_free_list_devices((**C.struct_AVDeviceInfoList)(unsafe.Pointer(d)))
}
//int avdevice_list_input_sources (struct AVInputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
//List devices.
func Avdevice_list_input_sources(d *AVInputFormat, dv string, do *AVDictionary, dl **AVDeviceInfoList) int {
return int(C.avdevice_list_input_sources((*C.struct_AVInputFormat)(d), C.CString(dv), (*C.struct_AVDictionary)(do), (**C.struct_AVDeviceInfoList)(unsafe.Pointer(dl))))
}
// //int avdevice_list_input_sources (struct AVInputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
// //List devices.
// func Avdevice_list_input_sources(d *AVInputFormat, dv string, do *AVDictionary, dl **AVDeviceInfoList) int {
// return int(C.avdevice_list_input_sources((*C.struct_AVInputFormat)(d), C.CString(dv), (*C.struct_AVDictionary)(do), (**C.struct_AVDeviceInfoList)(unsafe.Pointer(dl))))
// }
//int avdevice_list_output_sinks (struct AVOutputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
func Avdevice_list_output_sinks(d *AVOutputFormat, dn string, di *AVDictionary, dl **AVDeviceInfoList) int {
return int(C.avdevice_list_output_sinks((*C.struct_AVOutputFormat)(d), C.CString(dn), (*C.struct_AVDictionary)(di), (**C.struct_AVDeviceInfoList)(unsafe.Pointer(dl))))
}
// //int avdevice_list_output_sinks (struct AVOutputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
// func Avdevice_list_output_sinks(d *AVOutputFormat, dn string, di *AVDictionary, dl **AVDeviceInfoList) int {
// return int(C.avdevice_list_output_sinks((*C.struct_AVOutputFormat)(d), C.CString(dn), (*C.struct_AVDictionary)(di), (**C.struct_AVDeviceInfoList)(unsafe.Pointer(dl))))
// }
+21 -21
View File
@@ -84,15 +84,15 @@ func Av_stream_get_parser(s *AVStream) *AVCodecParserContext {
return (*AVCodecParserContext)(C.av_stream_get_parser((*C.struct_AVStream)(s)))
}
//char * av_stream_get_recommended_encoder_configuration (const AVStream *s)
func Av_stream_get_recommended_encoder_configuration(s *AVStream) string {
return C.GoString(C.av_stream_get_recommended_encoder_configuration((*C.struct_AVStream)(s)))
}
// //char * av_stream_get_recommended_encoder_configuration (const AVStream *s)
// func Av_stream_get_recommended_encoder_configuration(s *AVStream) string {
// return C.GoString(C.av_stream_get_recommended_encoder_configuration((*C.struct_AVStream)(s)))
// }
//void av_stream_set_recommended_encoder_configuration (AVStream *s, char *configuration)
func Av_stream_set_recommended_encoder_configuration(s *AVStream, c string) {
C.av_stream_set_recommended_encoder_configuration((*C.struct_AVStream)(s), C.CString(c))
}
// //void av_stream_set_recommended_encoder_configuration (AVStream *s, char *configuration)
// func Av_stream_set_recommended_encoder_configuration(s *AVStream, c string) {
// C.av_stream_set_recommended_encoder_configuration((*C.struct_AVStream)(s), C.CString(c))
// }
//int64_t av_stream_get_end_pts (const AVStream *st)
//Returns the pts of the last muxed packet + its duration.
@@ -135,15 +135,15 @@ func Av_format_set_subtitle_codec(s *AVFormatContext, c *AVCodec) {
C.av_format_set_subtitle_codec((*C.struct_AVFormatContext)(s), (*C.struct_AVCodec)(c))
}
//AVCodec * av_format_get_data_codec (const AVFormatContext *s)
func Av_format_get_data_codec(s *AVFormatContext) *AVCodec {
return (*AVCodec)(C.av_format_get_data_codec((*C.struct_AVFormatContext)(s)))
}
// //AVCodec * av_format_get_data_codec (const AVFormatContext *s)
// func Av_format_get_data_codec(s *AVFormatContext) *AVCodec {
// return (*AVCodec)(C.av_format_get_data_codec((*C.struct_AVFormatContext)(s)))
// }
//void av_format_set_data_codec (AVFormatContext *s, AVCodec *c)
func Av_format_set_data_codec(s *AVFormatContext, c *AVCodec) {
C.av_format_set_data_codec((*C.struct_AVFormatContext)(s), (*C.struct_AVCodec)(c))
}
// //void av_format_set_data_codec (AVFormatContext *s, AVCodec *c)
// func Av_format_set_data_codec(s *AVFormatContext, c *AVCodec) {
// C.av_format_set_data_codec((*C.struct_AVFormatContext)(s), (*C.struct_AVCodec)(c))
// }
//int av_format_get_metadata_header_padding (const AVFormatContext *s)
func Av_format_get_metadata_header_padding(s *AVFormatContext) int {
@@ -364,11 +364,11 @@ func Avformat_seek_file(s *AVFormatContext, si int, mit, ts, mat int64, f int) i
return int(C.avformat_seek_file((*C.struct_AVFormatContext)(s), C.int(si), C.int64_t(mit), C.int64_t(ts), C.int64_t(mat), C.int(f)))
}
//int avformat_flush (AVFormatContext *s)
//Discard all internally buffered data.
func Avformat_flush(s *AVFormatContext) int {
return int(C.avformat_flush((*C.struct_AVFormatContext)(s)))
}
// //int avformat_flush (AVFormatContext *s)
// //Discard all internally buffered data.
// func Avformat_flush(s *AVFormatContext) int {
// return int(C.avformat_flush((*C.struct_AVFormatContext)(s)))
// }
//int av_read_play (AVFormatContext *s)
//Start playing a network-based stream (e.g.
Binary file not shown.
+6 -6
View File
@@ -12,8 +12,7 @@ import (
)
func main() {
filename := "/home/giorgis/media/sample2.mp4"
filename := "sample.mp4"
var (
pFormatCtx *avformat.AVFormatContext
@@ -36,6 +35,7 @@ func main() {
// Open video file
if avformat.Avformat_open_input(&pFormatCtx, filename, nil, nil) != 0 {
log.Println("Error: Couldn't open file.")
return
}
@@ -83,7 +83,7 @@ func main() {
log.Println("Codec Context:", pCodecCtxOrig)
//C.enum_AVCodecID
codec_id := avcodec.Codec_id(pCodecCtxOrig)
codec_id := pCodecCtxOrig.Codec_id()
log.Println("Codec ID:", codec_id)
// Find the decoder for the video stream
@@ -121,9 +121,9 @@ func main() {
//avcodec.PIX_FMT_RGB24
//avcodec.SWS_BILINEAR
w := avcodec.Width(pCodecCtx)
h := avcodec.Height(pCodecCtx)
pix_fmt := avcodec.Pix_fmt(pCodecCtx)
w := pCodecCtx.Width()
h := pCodecCtx.Height()
pix_fmt := pCodecCtx.Pix_fmt()
// Determine required buffer size and allocate buffer
numBytes = avcodec.Avpicture_get_size((avcodec.AVPixelFormat)(a), w, h)
+10 -9
View File
@@ -1,22 +1,23 @@
package main
import (
"fmt"
//"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avdevice" //Just for test
"github.com/giorgisio/goav/avfilter" //Just for test
"github.com/giorgisio/goav/avdevice"
"github.com/giorgisio/goav/avfilter"
"github.com/giorgisio/goav/avformat"
"github.com/giorgisio/goav/swresample"
"log"
//"github.com/giorgisio/goav/avcodec"
//"github.com/giorgisio/goav/avutil"
"github.com/giorgisio/goav/swresample" //Just for test
//"github.com/giorgisio/goav/swscale"
)
func main() {
fmt.Println("Testing:")
// Register all formats and codecs
avformat.Av_register_all()
avfilter.Avfilter_version()
avdevice.Avdevice_version()
swresample.Swresample_license()
log.Println(avfilter.Avfilter_version())
log.Println(avdevice.Avdevice_version())
log.Println(swresample.Swresample_license())
}