On 29/09/14 12:08, Uwe L. Korn wrote:
In (non-live) streams with no metadata, the duration of a stream can
be retrieved by calling the RTMP function getStreamLength with the
playpath. The server will return a positive duration upon the request if
the duration is known, otherwise either no response or a duration of 0
will be returned.
---
  libavformat/rtmpproto.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 81 insertions(+)


+    } else if (!strcmp(tracked_method, "getStreamLength")) {
+        // If the server does not know the duration of the stream, it will 
report 0 here.
+        rt->duration = av_int2double(AV_RB64(pkt->data + 21));
      }

Do not we have a read function for this kind of stuff?

  fail:
@@ -2617,6 +2649,7 @@ reconnect:
      rt->received_metadata = 0;
      rt->last_bytes_read = 0;
      rt->server_bw = 2500000;
+    rt->duration = 0;

      av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n",
             proto, path, rt->app, rt->playpath);
@@ -2675,6 +2708,54 @@ reconnect:
          if (rt->has_video) {
              rt->flv_data[4] |= FLV_HEADER_FLAG_HASVIDEO;
          }
+
+        // If we received the first packet of an A/V stream and no metadata but
+        // the server returned a valid duration, create a fake metadata packet
+        // to inform the FLV decoder about the duration.
+        if (!rt->received_metadata && rt->duration > 0) {

Make it a stand-alone function please.


The concept sounds good to me.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to