summaryrefslogtreecommitdiff
path: root/libavformat/flvenc.c
diff options
context:
space:
mode:
authorBjörn Axelsson <bjorn.axelsson@intinor.se>2012-12-13 14:48:25 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-13 21:54:35 +0100
commit2947e7b7a7378e4899c57a86f029fb20dc0f010c (patch)
tree426c5a9fba597c99a6b254b96b722c690092089e /libavformat/flvenc.c
parent0aa0bab40db3fefb1713436d1e70219a1164cd6f (diff)
flvenc: don't write random data if seek fails
The FLV muxer tries to update the header in write_trailer, which is impossible if writing to a pipe or network stream. Don't write header data if seek to header fails. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r--libavformat/flvenc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index c528bf5bef..6ee0dd3077 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -426,10 +426,14 @@ static int flv_write_trailer(AVFormatContext *s)
file_size = avio_tell(pb);
/* update information */
- avio_seek(pb, flv->duration_offset, SEEK_SET);
- put_amf_double(pb, flv->duration / (double)1000);
- avio_seek(pb, flv->filesize_offset, SEEK_SET);
- put_amf_double(pb, file_size);
+ if(avio_seek(pb, flv->duration_offset, SEEK_SET) < 0)
+ av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n");
+ else
+ put_amf_double(pb, flv->duration / (double)1000);
+ if(avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0)
+ av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n");
+ else
+ put_amf_double(pb, file_size);
avio_seek(pb, file_size, SEEK_SET);
return 0;