Commit a98cadef authored by Michael Niedermayer's avatar Michael Niedermayer

doc/examples/muxing: Move samples_count to OutputStream

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 8b1d54ba
...@@ -55,6 +55,7 @@ typedef struct OutputStream { ...@@ -55,6 +55,7 @@ typedef struct OutputStream {
/* pts of the next frame that will be generated */ /* pts of the next frame that will be generated */
int64_t next_pts; int64_t next_pts;
int samples_count;
AVFrame *frame; AVFrame *frame;
AVFrame *tmp_frame; AVFrame *tmp_frame;
...@@ -177,8 +178,6 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc, ...@@ -177,8 +178,6 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
/**************************************************************/ /**************************************************************/
/* audio output */ /* audio output */
int samples_count;
static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
{ {
AVCodecContext *c; AVCodecContext *c;
...@@ -332,8 +331,8 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost) ...@@ -332,8 +331,8 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
dst_nb_samples = frame->nb_samples; dst_nb_samples = frame->nb_samples;
} }
frame->pts = av_rescale_q(samples_count, (AVRational){1, c->sample_rate}, c->time_base); frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
samples_count += dst_nb_samples; ost->samples_count += dst_nb_samples;
} }
ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet); ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment