]> git.sesse.net Git - ffmpeg/commitdiff
flvenc: Check whether seeking back to the header succeeded
authorBjörn Axelsson <bjorn.axelsson@intinor.se>
Thu, 13 Dec 2012 13:48:25 +0000 (14:48 +0100)
committerMartin Storsjö <martin@martin.st>
Thu, 20 Dec 2012 10:37:42 +0000 (12:37 +0200)
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 seeking to the header fails.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/flvenc.c

index 8aeea968b4c0e525ada88658db2b17aa3c944886..ff6d14a24841426cf8a9b5fb02e1f54a9f121df8 100644 (file)
@@ -403,10 +403,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;