Browse Source

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>
tags/n1.1
Björn Axelsson Michael Niedermayer 12 years ago
parent
commit
2947e7b7a7
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      libavformat/flvenc.c

+ 8
- 4
libavformat/flvenc.c View File

@@ -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;


Loading…
Cancel
Save