mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
fftools/ffmpeg_enc: do not set AVStream timebase directly
Instead, pass the encoder context to of_stream_init() and have the muxer take the timebase from there. Note that the muxer can currently access the codec context directly, but that will change in future commits. This is a step towards decoupling encoders from muxers.
This commit is contained in:
parent
1ebd521a4e
commit
238f439992
@ -871,7 +871,8 @@ int enc_loopback(Encoder *enc);
|
||||
*
|
||||
* Open the muxer once all the streams have been initialized.
|
||||
*/
|
||||
int of_stream_init(OutputFile *of, OutputStream *ost);
|
||||
int of_stream_init(OutputFile *of, OutputStream *ost,
|
||||
const AVCodecContext *enc_ctx);
|
||||
int of_write_trailer(OutputFile *of);
|
||||
int of_open(const OptionsContext *o, const char *filename, Scheduler *sch);
|
||||
void of_free(OutputFile **pof);
|
||||
|
@ -367,11 +367,7 @@ int enc_open(void *opaque, const AVFrame *frame)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// copy timebase while removing common factors
|
||||
if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0)
|
||||
ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1});
|
||||
|
||||
ret = of_stream_init(of, ost);
|
||||
ret = of_stream_init(of, ost, enc_ctx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -608,12 +608,19 @@ static int bsf_init(MuxStream *ms)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_stream_init(OutputFile *of, OutputStream *ost)
|
||||
int of_stream_init(OutputFile *of, OutputStream *ost,
|
||||
const AVCodecContext *enc_ctx)
|
||||
{
|
||||
Muxer *mux = mux_from_of(of);
|
||||
MuxStream *ms = ms_from_ost(ost);
|
||||
int ret;
|
||||
|
||||
if (enc_ctx) {
|
||||
// use upstream time base unless it has been overridden previously
|
||||
if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0)
|
||||
ost->st->time_base = av_add_q(enc_ctx->time_base, (AVRational){0, 1});
|
||||
}
|
||||
|
||||
/* initialize bitstream filters for the output stream
|
||||
* needs to be done here, because the codec id for streamcopy is not
|
||||
* known until now */
|
||||
|
@ -3385,7 +3385,7 @@ int of_open(const OptionsContext *o, const char *filename, Scheduler *sch)
|
||||
OutputStream *ost = of->streams[i];
|
||||
|
||||
if (!ost->enc) {
|
||||
err = of_stream_init(of, ost);
|
||||
err = of_stream_init(of, ost, NULL);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user