aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-18 01:33:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-18 01:54:40 +0200
commitfae714a9fbff876c4cacfe7d437c940d557b44ce (patch)
treea902e7f012153f96582d2eecdfb78def1c0260a1 /libavformat/utils.c
parent9be937d38dac1ccf16fa8a7c0f9098bad5bb0431 (diff)
parent3ec344626c4ec2f515169f89bffe95dea92a5982 (diff)
downloadffmpeg-fae714a9fbff876c4cacfe7d437c940d557b44ce.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: avconv: add presets rtsp: Expose the flag options via private AVOptions for sdp and rtp, too rtsp: Make the rtsp flags avoptions set via a define rtpenc: Set a default video codec avoptions: Fix av_opt_flag_is_set rtp: Fix ff_rtp_get_payload_type doc: Update the documentation on setting options for RTSP rtsp: Remove the separate filter_source variable rtsp: Accept options via private avoptions instead of URL options rtsp: Simplify AVOption definitions rtsp: Merge the AVOption lists lavfi: port libmpcodecs delogo filter lavfi: port boxblur filter from libmpcodecs lavfi: add negate filter lavfi: add LUT (LookUp Table) generic filters AVOptions: don't segfault on NULL parameter in av_set_options_string() avio: Check for invalid buffer length. mpegenc/mpegtsenc: add muxrate private options. lavf: deprecate AVFormatContext.file_size mov: add support for TV metadata atoms tves, tvsn and stik Conflicts: Changelog doc/filters.texi doc/protocols.texi libavfilter/Makefile libavfilter/allfilters.c libavfilter/avfilter.h libavfilter/formats.c libavfilter/internal.h libavfilter/vf_boxblur.c libavfilter/vf_delogo.c libavfilter/vf_lut.c libavformat/mpegtsenc.c libavformat/utils.c libavformat/version.h libavutil/opt.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c7eb93f3b0..333baa0290 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1902,7 +1902,7 @@ static int has_duration(AVFormatContext *ic)
static void update_stream_timings(AVFormatContext *ic)
{
int64_t start_time, start_time1, start_time_text, end_time, end_time1;
- int64_t duration, duration1;
+ int64_t duration, duration1, filesize;
int i;
AVStream *st;
@@ -1945,9 +1945,9 @@ static void update_stream_timings(AVFormatContext *ic)
if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) {
ic->duration = duration;
}
- if (ic->file_size > 0 && ic->duration != AV_NOPTS_VALUE) {
+ if (ic->pb && (filesize = avio_size(ic->pb)) > 0 && ic->duration != AV_NOPTS_VALUE) {
/* compute the bitrate */
- ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE /
+ ic->bit_rate = (double)filesize * 8.0 * AV_TIME_BASE /
(double)ic->duration;
}
}
@@ -1988,9 +1988,8 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
/* if duration is already set, we believe it */
if (ic->duration == AV_NOPTS_VALUE &&
- ic->bit_rate != 0 &&
- ic->file_size != 0) {
- filesize = ic->file_size;
+ ic->bit_rate != 0) {
+ filesize = ic->pb ? avio_size(ic->pb) : 0;
if (filesize > 0) {
for(i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
@@ -2034,7 +2033,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
/* estimate the end time (duration) */
/* XXX: may need to support wrapping */
- filesize = ic->file_size;
+ filesize = ic->pb ? avio_size(ic->pb) : 0;
end_time = AV_NOPTS_VALUE;
do{
offset = filesize - (DURATION_MAX_READ_SIZE<<retry);
@@ -2098,7 +2097,6 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
if (file_size < 0)
file_size = 0;
}
- ic->file_size = file_size;
if ((!strcmp(ic->iformat->name, "mpeg") ||
!strcmp(ic->iformat->name, "mpegts")) &&