Closed notedit closed 3 weeks ago
go-astiav
is only compatible up until 5.1.2
I'll rename your issue and keep it opened but I'm not planning to make this library compatible with ffmpeg 6.0 in the coming months.
Thanks for this lib 🙇 !
Just to document AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
was also dropped by https://github.com/FFmpeg/FFmpeg/commit/f843460eb790d37e444e5946628f228421916537
Error log:
../../go/pkg/mod/github.com/asticode/go-astiav@v0.12.0/codec_context_flag.go:38:50: could not determine kind of name for C.AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
../../go/pkg/mod/github.com/asticode/go-astiav@v0.12.0/codec_context_flag.go:21:51: could not determine kind of name for C.AV_CODEC_FLAG_TRUNCATED
FYI I've created a branch called bump/n6.1.1
where go-astiav
is now compatible with ffmpeg n6.1.1
. Feel free to let me know if you face any issue. I won't merge it in master
right away, but at least everybody will still be able to use ffmpeg n6.1.1
👍
For those wanting to test this version, you can grab the latest commit and:
go get github.com/asticode/go-astiav@b205dafea2429a246090a9f9eb28feae70828443
For now, I'm facing the following issue while using b205dafea2429a246090a9f9eb28feae70828443
working to fix my usage though
7.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:26:73: error: 'AV_CHANNEL_LAYOUT_3POINT1POINT2' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_3POINT1'?
67.15 26 | AVChannelLayout *c2goChannelLayout3Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_3POINT1POINT2;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_3POINT1
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:35:73: error: 'AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK'?
67.15 35 | AVChannelLayout *c2goChannelLayout5Point1Point2Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:37:73: error: 'AV_CHANNEL_LAYOUT_CUBE' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_QUAD'?
67.15 37 | AVChannelLayout *c2goChannelLayoutCube = &(AVChannelLayout)AV_CHANNEL_LAYOUT_CUBE;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_QUAD
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:38:73: error: 'AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK'?
67.15 38 | AVChannelLayout *c2goChannelLayout5Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:39:73: error: 'AV_CHANNEL_LAYOUT_7POINT1POINT2' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_7POINT1_WIDE'?
67.15 39 | AVChannelLayout *c2goChannelLayout7Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT2;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_7POINT1_WIDE
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:40:73: error: 'AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK'?
67.15 40 | AVChannelLayout *c2goChannelLayout7Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK
67.15 /go/pkg/mod/github.com/asticode/go-astiav@v0.13.2-0.20240505170917-b205dafea242/channel_layout.go:44:73: error: 'AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK' undeclared here (not in a function); did you mean 'AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK'?
67.15 44 | AVChannelLayout *c2goChannelLayout7Point1TopBack = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK;
67.15 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67.15 | AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK
------
Which ffmpeg
version are you using? 🤔
Which
ffmpeg
version are you using? 🤔
I was using the wrong version, thanks, I've made some adjustment here and there n I was able to make my trasncoding code to "work".
Btw, do you know any working example of a opus transcoding?
I took your transcoding example and adapted (both the old version and now 6.0.1) trying to transcode aac <-> opus but in the end the audio is choppy, and I'm unsure why, I'm still digging it though.
Here's the yours transcoding adapted (with comments) to output opus.
How I generated the source sample named sample_h264_aac.mp4
:
ffmpeg -hide_banner -loglevel verbose -re -f lavfi -i testsrc2=size=1280x720:rate=30,format=yuv420p -f lavfi -i sine=frequency=1000:sample_rate=44100 -c:v libx264 -preset veryfast -tune zerolatency -profile:v baseline -b:v 1000k -bufsize 2000k -x264opts keyint=30:min-keyint=30:scenecut=-1 -c:a aac -b:a 128k \\n sample_h264_aac.mp4
How I generated the target media (to compared with the one generated by my transcoding.go) named sample_converted_opus.mp4
:
ffmpeg -i sample.mp4 -c:v copy -c:a libopus sample_converted_opus.mp4
I only took a quick glance at your code but I'd try to check different time bases first since they seem weird to me 🤔 I wouldn't force it to 1/48000
or 1/30
and would ffmpeg dictate its value. As far as I'm concerned, when updating s.encCodecContext
, values should be the same as what's coming out of the filter. You could use the tb
filter to force the timebase. But forcing to 1/48000
for audio seems wrong to me, since that may not describe what's coming in the encoder properly 🤔 this line also seems weird to me and shouldn't be there 🤔
But again, that's only after taking a quick glance at your code, so I may be wrong
As far as I'm concerned, when updating s.encCodecContext, values should be the same as what's coming out of the filter.
I guess the gotcha here is the need to upscale the audio frame rate, that's why I believe is necessary to set a new tb.
I wouldn't force it to 1/48000 or 1/30 and would ffmpeg dictate its value.
I had to because if I didn't do it, it would fail saying The encoder timebase is not set.
, looking at the official example it seems that they also set it manually https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcode.c#L183 for filtering though they use pkt tb thouhg https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcode.c#L275 .
I did a lot of attempts, and noticed that dismissing set a TB makes it fail, that's why I started to fill the TBs.
app-1 | 2024/05/06 16:43:24 ffmpeg log: Invalid time base 0/1 (level: 16)
app-1 | 2024/05/06 16:43:24 main: initializing filters failed: main: creating buffersrc context failed (args=astiav.FilterArgs{"pix_fmt":"0", "pixel_aspect":"1/1", "time_base":"0", "video_size":"1280x720"}) : Invalid argument
I'll keep trying to see where it goes, now with the version 6.x.x
The way I understand it, you need to set your timebases to:
tb
filter before however in order to make sure frames coming out of the filter do have timestamps in this timebase)But the problem may be elsewhere 🤔
By the way, could we continue this discussion in the video-dev slack instead? I don't want to use this issue dedicated to supporting ffmpeg 6.0 with a discussion that is not related to that subject anymore 👍
FYI: homebrew on mac now defaults to ffmpeg 7.0.1, which removed a few things that are easily commented out, but also has these problems:
./codec_context.go:87:18: cc.c.channels undefined (type *_Ctype_struct_AVCodecContext has no field or method channels)
./codec_context.go:91:7: cc.c.channels undefined (type *_Ctype_struct_AVCodecContext has no field or method channels)
./codec_parameters.go:41:18: cp.c.channels undefined (type *_Ctype_struct_AVCodecParameters has no field or method channels)
./codec_parameters.go:45:7: cp.c.channels undefined (type *_Ctype_struct_AVCodecParameters has no field or method channels)
@rcoreilly FYI I've created a bump/n7.0
branch which is compatible with the n7.0
ffmpeg version 👍
FYI I've merged bump/n7.0
into master
, and go-astiav
is now compatible with n7.0
👍
AV_CODEC_CAP_TRUNCATED has been removed in ffmpeg 6.
https://github.com/obsproject/obs-studio/issues/8375