Skip to content

Commit 1b513e3

Browse files
committed
Updated
1 parent 358ffdf commit 1b513e3

File tree

10 files changed

+52
-41
lines changed

10 files changed

+52
-41
lines changed

cmd/cli/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
type DecodeCmd struct {
12-
Path string `arg required help:"Media file" type:"path"`
12+
Path string `arg:"" required:"" help:"Media file" type:"path"`
1313
}
1414

1515
func (cmd *DecodeCmd) Run(globals *Globals) error {

cmd/ffmpeg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using the low-level golang bindings.
1515
Generate a synthetic audio signal and encode it to an output MP2 file.
1616
* [encode_video](encode_video) - libavcodec encoding video API usage example.
1717
Generate synthetic video data and encode it to an output file.
18-
* [mux](mux) - Muxing - libavformat/libavcodec muxing API usage example.
18+
* [mux](mux) - Muxing - libavformat/libavcodec muxing API usage example - NOT COMPLETED
1919
Generate a synthetic audio signal and mux it into a container format.
2020
* [remux](remux) - Remuxing - libavformat/libavcodec demuxing and muxing API usage example.
2121
Remux streams from one container format to another. Data is copied from the input to the output

cmd/ffmpeg/encode_audio/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func main() {
8383
}
8484

8585
// Allocate the data buffers
86-
if err := ff.AVUtil_frame_get_buffer(frame, 0); err != nil {
86+
if err := ff.AVUtil_frame_get_buffer(frame, false); err != nil {
8787
log.Fatal(err)
8888
}
8989

cmd/ffmpeg/encode_video/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func main() {
9292
frame.SetHeight(ctx.Height())
9393

9494
// Allocate the data buffers
95-
if err := ff.AVUtil_frame_get_buffer(frame, 0); err != nil {
95+
if err := ff.AVUtil_frame_get_buffer(frame, false); err != nil {
9696
log.Fatal(err)
9797
}
9898

cmd/ffmpeg/mux/generate.go renamed to cmd/ffmpeg/mux/generate.go_old

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func write_video_frame(ctx *ff.AVFormatContext, stream *Stream) bool {
6767

6868

6969

70-
70+
/*
7171
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
7272
{
7373
AVCodecContext *c;
@@ -80,8 +80,8 @@ func write_video_frame(ctx *ff.AVFormatContext, stream *Stream) bool {
8080
frame = get_audio_frame(ost);
8181

8282
if (frame) {
83-
/* convert samples from native format to destination codec format, using the resampler */
84-
/* compute destination number of samples */
83+
/* convert samples from native format to destination codec format, using the resampler
84+
/* compute destination number of samples
8585
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
8686
c->sample_rate, c->sample_rate, AV_ROUND_UP);
8787
av_assert0(dst_nb_samples == frame->nb_samples);
@@ -94,7 +94,7 @@ func write_video_frame(ctx *ff.AVFormatContext, stream *Stream) bool {
9494
if (ret < 0)
9595
exit(1);
9696

97-
/* convert to destination format */
97+
/* convert to destination format
9898
ret = swr_convert(ost->swr_ctx,
9999
ost->frame->data, dst_nb_samples,
100100
(const uint8_t **)frame->data, frame->nb_samples);
@@ -109,4 +109,5 @@ func write_video_frame(ctx *ff.AVFormatContext, stream *Stream) bool {
109109
}
110110

111111
return write_frame(oc, c, ost->st, frame, ost->tmp_pkt);
112-
}
112+
}
113+
*/

cmd/ffmpeg/mux/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ func main() {
9090
for encode_audio || encode_video {
9191
// Choose video if both are available, and video is earlier than audio
9292
if (encode_video && !encode_audio) || (encode_video && ff.AVUtil_compare_ts(video.next_pts, video.Encoder.TimeBase(), audio.next_pts, audio.Encoder.TimeBase()) <= 0) {
93-
encode_video = !write_video_frame(ctx, video)
93+
fmt.Println("TODO: Write video frame")
94+
encode_video = false
95+
// encode_video = !write_video_frame(ctx, video)
9496
} else {
95-
encode_audio = !write_audio_frame(ctx, audio)
97+
fmt.Println("TODO: Write audio frame")
98+
encode_audio = false
99+
// encode_audio = !write_audio_frame(ctx, audio)
96100
}
97101
}
98102

cmd/ffmpeg/mux/stream.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func alloc_video_frame(pix_fmt ff.AVPixelFormat, width, height int) (*ff.AVFrame
223223
frame.SetPixFmt(pix_fmt)
224224

225225
// allocate the buffers for the frame data
226-
if err := ff.AVUtil_frame_get_buffer(frame, 0); err != nil {
226+
if err := ff.AVUtil_frame_get_buffer(frame, false); err != nil {
227227
ff.AVUtil_frame_free(frame)
228228
return nil, err
229229
}
@@ -246,7 +246,7 @@ func alloc_audio_frame(sample_fmt ff.AVSampleFormat, channel_layout ff.AVChannel
246246
}
247247

248248
// allocate the buffers for the frame data
249-
if err := ff.AVUtil_frame_get_buffer(frame, 0); err != nil {
249+
if err := ff.AVUtil_frame_get_buffer(frame, false); err != nil {
250250
ff.AVUtil_frame_free(frame)
251251
return nil, err
252252
}

manager.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ import (
1515
type manager struct {
1616
}
1717

18-
type inputformat struct {
19-
ctx *ff.AVInputFormat
20-
Name string `json:"name"`
18+
type formatmeta struct {
19+
Name string `json:"name" writer:",width:25"`
2120
Description string `json:"description" writer:",wrap,width:40"`
2221
Extensions string `json:"extensions,omitempty"`
2322
MimeTypes string `json:"mimetypes,omitempty"`
2423
}
2524

25+
type inputformat struct {
26+
formatmeta
27+
ctx *ff.AVInputFormat
28+
}
29+
2630
type outputformat struct {
27-
ctx *ff.AVOutputFormat
28-
Name string `json:"name"`
29-
Description string `json:"description" writer:",wrap,width:40"`
30-
Extensions string `json:"extensions,omitempty"`
31-
MimeTypes string `json:"mimetypes,omitempty"`
31+
formatmeta
32+
ctx *ff.AVOutputFormat
3233
}
3334

3435
////////////////////////////////////////////////////////////////////////////
@@ -40,21 +41,25 @@ func NewManager() *manager {
4041

4142
func newInputFormat(ctx *ff.AVInputFormat) *inputformat {
4243
return &inputformat{
43-
ctx: ctx,
44-
Name: ctx.Name(),
45-
Description: ctx.LongName(),
46-
Extensions: ctx.Extensions(),
47-
MimeTypes: ctx.MimeTypes(),
44+
ctx: ctx,
45+
formatmeta: formatmeta{
46+
Name: ctx.Name(),
47+
Description: ctx.LongName(),
48+
Extensions: ctx.Extensions(),
49+
MimeTypes: ctx.MimeTypes(),
50+
},
4851
}
4952
}
5053

5154
func newOutputFormat(ctx *ff.AVOutputFormat) *outputformat {
5255
return &outputformat{
53-
ctx: ctx,
54-
Name: ctx.Name(),
55-
Description: ctx.LongName(),
56-
Extensions: ctx.Extensions(),
57-
MimeTypes: ctx.MimeTypes(),
56+
ctx: ctx,
57+
formatmeta: formatmeta{
58+
Name: ctx.Name(),
59+
Description: ctx.LongName(),
60+
Extensions: ctx.Extensions(),
61+
MimeTypes: ctx.MimeTypes(),
62+
},
5863
}
5964
}
6065

sys/ffmpeg61/avutil_frame.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,14 @@ func (ctx *AVFrame) Int16(plane int) []int16 {
239239
return cInt16Slice(unsafe.Pointer(buf.data), C.int(buf.size)>>1)
240240
}
241241
}
242+
243+
// Returns the data as a set of planes and strides
244+
func (ctx *AVFrame) Data() ([][]byte, []int) {
245+
planes := make([][]byte, int(C.AV_NUM_DATA_POINTERS))
246+
strides := make([]int, int(C.AV_NUM_DATA_POINTERS))
247+
for i := 0; i < int(C.AV_NUM_DATA_POINTERS); i++ {
248+
planes[i] = ctx.Uint8(i)
249+
strides[i] = ctx.Linesize(i)
250+
}
251+
return planes, strides
252+
}

sys/ffmpeg61/swresample.go_old

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)