Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
ffmpeg2theora
Commits
d864bae9
Commit
d864bae9
authored
Jul 04, 2011
by
Jan Gerber
Browse files
some audio decoders set sample_rate to 0 in avcodec_open now
parent
77148c63
Changes
1
Show whitespace changes
Inline
Side-by-side
src/ffmpeg2theora.c
View file @
d864bae9
...
@@ -934,6 +934,7 @@ void ff2theora_output(ff2theora this) {
...
@@ -934,6 +934,7 @@ void ff2theora_output(ff2theora this) {
astream
=
this
->
context
->
streams
[
this
->
audio_index
];
astream
=
this
->
context
->
streams
[
this
->
audio_index
];
aenc
=
this
->
context
->
streams
[
this
->
audio_index
]
->
codec
;
aenc
=
this
->
context
->
streams
[
this
->
audio_index
]
->
codec
;
acodec
=
avcodec_find_decoder
(
aenc
->
codec_id
);
acodec
=
avcodec_find_decoder
(
aenc
->
codec_id
);
int
sample_rate
=
aenc
->
sample_rate
;
if
(
this
->
channels
<
1
)
{
if
(
this
->
channels
<
1
)
{
this
->
channels
=
aenc
->
channels
;
this
->
channels
=
aenc
->
channels
;
}
}
...
@@ -949,19 +950,19 @@ void ff2theora_output(ff2theora this) {
...
@@ -949,19 +950,19 @@ void ff2theora_output(ff2theora this) {
}
}
if
(
acodec
!=
NULL
&&
avcodec_open
(
aenc
,
acodec
)
>=
0
)
{
if
(
acodec
!=
NULL
&&
avcodec_open
(
aenc
,
acodec
)
>=
0
)
{
if
(
this
->
sample_rate
!=
aenc
->
sample_rate
if
(
this
->
sample_rate
!=
sample_rate
||
this
->
channels
!=
aenc
->
channels
||
this
->
channels
!=
aenc
->
channels
||
aenc
->
sample_fmt
!=
SAMPLE_FMT_S16
)
{
||
aenc
->
sample_fmt
!=
SAMPLE_FMT_S16
)
{
// values take from libavcodec/resample.c
// values take from libavcodec/resample.c
this
->
audio_resample_ctx
=
av_audio_resample_init
(
this
->
channels
,
aenc
->
channels
,
this
->
audio_resample_ctx
=
av_audio_resample_init
(
this
->
channels
,
aenc
->
channels
,
this
->
sample_rate
,
aenc
->
sample_rate
,
this
->
sample_rate
,
sample_rate
,
SAMPLE_FMT_S16
,
aenc
->
sample_fmt
,
SAMPLE_FMT_S16
,
aenc
->
sample_fmt
,
16
,
10
,
0
,
0
.
8
);
16
,
10
,
0
,
0
.
8
);
if
(
!
this
->
audio_resample_ctx
)
{
if
(
!
this
->
audio_resample_ctx
)
{
this
->
channels
=
aenc
->
channels
;
this
->
channels
=
aenc
->
channels
;
}
}
if
(
!
info
.
frontend
&&
this
->
sample_rate
!=
aenc
->
sample_rate
)
if
(
!
info
.
frontend
&&
this
->
sample_rate
!=
sample_rate
)
fprintf
(
stderr
,
" Resample: %dHz => %dHz
\n
"
,
aenc
->
sample_rate
,
this
->
sample_rate
);
fprintf
(
stderr
,
" Resample: %dHz => %dHz
\n
"
,
sample_rate
,
this
->
sample_rate
);
if
(
!
info
.
frontend
&&
this
->
channels
!=
aenc
->
channels
)
if
(
!
info
.
frontend
&&
this
->
channels
!=
aenc
->
channels
)
fprintf
(
stderr
,
" Channels: %d => %d
\n
"
,
aenc
->
channels
,
this
->
channels
);
fprintf
(
stderr
,
" Channels: %d => %d
\n
"
,
aenc
->
channels
,
this
->
channels
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment