]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/flvdec.c
set width and height even for mpeg4, pix_fmt to NONE will force decoding anwyay
[ffmpeg] / libavformat / flvdec.c
index 1be80e32e4c348062ec0eb4488d40f8ef4db272a..953be09c5080af6269d19a3e050a206fa04fb9aa 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
 
@@ -34,7 +34,7 @@ static int flv_probe(AVProbeData *p)
 static int flv_read_header(AVFormatContext *s,
                            AVFormatParameters *ap)
 {
-    int offset, flags;
+    int offset, flags, size;
 
     s->ctx_flags |= AVFMTCTX_NOHEADER; //ok we have a header but theres no fps, codec type, sample_rate, ...
 
@@ -42,6 +42,17 @@ static int flv_read_header(AVFormatContext *s,
     flags = get_byte(&s->pb);
 
     offset = get_be32(&s->pb);
+
+    if(!url_is_streamed(&s->pb)){
+        const int fsize= url_fsize(&s->pb);
+        url_fseek(&s->pb, fsize-4, SEEK_SET);
+        size= get_be32(&s->pb);
+        url_fseek(&s->pb, fsize-3-size, SEEK_SET);
+        if(size == get_be24(&s->pb) + 11){
+            s->duration= get_be24(&s->pb) * (int64_t)AV_TIME_BASE / 1000;
+        }
+    }
+
     url_fseek(&s->pb, offset, SEEK_SET);
 
     return 0;