You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
output example: set the stream timebase
This is required by the new API.
This commit is contained in:
@@ -96,6 +96,8 @@ static void add_audio_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
c->channels = 2;
|
c->channels = 2;
|
||||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
|
||||||
|
ost->st->time_base = (AVRational){ 1, c->sample_rate };
|
||||||
|
|
||||||
// some formats want stream headers to be separate
|
// some formats want stream headers to be separate
|
||||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||||
@@ -239,8 +241,9 @@ static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
* of which frame timestamps are represented. For fixed-fps content,
|
* of which frame timestamps are represented. For fixed-fps content,
|
||||||
* timebase should be 1/framerate and timestamp increments should be
|
* timebase should be 1/framerate and timestamp increments should be
|
||||||
* identical to 1. */
|
* identical to 1. */
|
||||||
c->time_base.den = STREAM_FRAME_RATE;
|
ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
|
||||||
c->time_base.num = 1;
|
c->time_base = ost->st->time_base;
|
||||||
|
|
||||||
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
|
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
|
||||||
c->pix_fmt = STREAM_PIX_FMT;
|
c->pix_fmt = STREAM_PIX_FMT;
|
||||||
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
|
Reference in New Issue
Block a user