summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-05-18 12:12:59 +0200
committerAnton Khirnov <anton@khirnov.net>2014-06-18 15:12:34 +0200
commit194be1f43ea391eb986732707435176e579265aa (patch)
tree2045d50660f7e045fde6cda7a2ed8213c24f5aab /libavformat/mux.c
parentd754ed41727b1fcbab335b510248a9758a73320c (diff)
lavf: switch to AVStream.time_base as the hint for the muxer timebase
Previously, AVStream.codec.time_base was used for that purpose, which was quite confusing for the callers. This change also opens the path for removing AVStream.codec. The change in the lavf-mkv test is due to the native timebase (1/1000) being used instead of the default one (1/90000), so the packets are now sent to the crc muxer in the same order in which they are demuxed (previously some of them got reordered because of inexact timestamp conversion).
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index e024a7eaea..9c2144acc1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -115,6 +115,25 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
st = s->streams[i];
codec = st->codec;
+#if FF_API_LAVF_CODEC_TB
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (!st->time_base.num && codec->time_base.num) {
+ av_log(s, AV_LOG_WARNING, "Using AVStream.codec.time_base as a "
+ "timebase hint to the muxer is deprecated. Set "
+ "AVStream.time_base instead.\n");
+ avpriv_set_pts_info(st, 64, codec->time_base.num, codec->time_base.den);
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (!st->time_base.num) {
+ /* fall back on the default timebase values */
+ if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->sample_rate)
+ avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ else
+ avpriv_set_pts_info(st, 33, 1, 90000);
+ }
+
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (codec->sample_rate <= 0) {
@@ -127,13 +146,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
av_get_bits_per_sample(codec->codec_id) >> 3;
break;
case AVMEDIA_TYPE_VIDEO:
- if (codec->time_base.num <= 0 ||
- codec->time_base.den <= 0) { //FIXME audio too?
- av_log(s, AV_LOG_ERROR, "time base not set\n");
- ret = AVERROR(EINVAL);
- goto fail;
- }
-
if ((codec->width <= 0 || codec->height <= 0) &&
!(of->flags & AVFMT_NODIMENSIONS)) {
av_log(s, AV_LOG_ERROR, "dimensions not set\n");