Advertisement
Guest User

libavformat-segment-c_segment-list-EXTM3U.patch

a guest
Aug 16th, 2012
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. --- libavformat/segment.c.org 2012-08-16 18:23:53.000000000 +0000
  2. +++ libavformat/segment.c 2012-08-16 18:41:43.000000000 +0000
  3. @@ -34,6 +34,7 @@
  4. typedef enum {
  5. LIST_TYPE_FLAT = 0,
  6. LIST_TYPE_EXT,
  7. + LIST_TYPE_EXTM3U,
  8. LIST_TYPE_NB,
  9. } ListType;
  10.  
  11. @@ -129,7 +130,11 @@
  12. avio_printf(seg->list_pb, "%s\n", oc->filename);
  13. } else if (seg->list_type == LIST_TYPE_EXT) {
  14. avio_printf(seg->list_pb, "%s,%f,%f\n", oc->filename, seg->start_time, seg->end_time);
  15. + } else if (seg->list_type == LIST_TYPE_EXTM3U) {
  16. + avio_printf(seg->list_pb, "#EXTINF:%s,\n",seg->time_str);
  17. + avio_printf(seg->list_pb, "%s\n", oc->filename);
  18. }
  19. +
  20. avio_flush(seg->list_pb);
  21. }
  22.  
  23. @@ -238,11 +243,19 @@
  24. if (!oc)
  25. return AVERROR(ENOMEM);
  26.  
  27. - if (seg->list)
  28. + if (seg->list) {
  29. if ((ret = avio_open2(&seg->list_pb, seg->list, AVIO_FLAG_WRITE,
  30. &s->interrupt_callback, NULL)) < 0)
  31. goto fail;
  32.  
  33. + if (seg->list_type == LIST_TYPE_EXTM3U) {
  34. + avio_printf(seg->list_pb, "#EXTM3U\n");
  35. + avio_printf(seg->list_pb, "#EXT-X-TARGETDURATION:%s\n",seg->time_str);
  36. + avio_printf(seg->list_pb, "#EXT-X-ALLOW-CACHE:1s\n");
  37. + avio_printf(seg->list_pb, "\n");
  38. + }
  39. + }
  40. +
  41. for (i = 0; i< s->nb_streams; i++)
  42. seg->has_video +=
  43. (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO);
  44. @@ -369,6 +382,7 @@
  45. { "segment_list_type", "set the segment list type", OFFSET(list_type), AV_OPT_TYPE_INT, {.dbl = LIST_TYPE_FLAT}, 0, LIST_TYPE_NB-1, E, "list_type" },
  46. { "flat", "flat format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_FLAT }, INT_MIN, INT_MAX, 0, "list_type" },
  47. { "ext", "extended format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_EXT }, INT_MIN, INT_MAX, 0, "list_type" },
  48. + { "extm3u", "extended M3U format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_EXTM3U }, INT_MIN, INT_MAX, 0, "list_type" },
  49. { "segment_time", "set segment duration", OFFSET(time_str),AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
  50. { "segment_time_delta","set approximation value used for the segment times", OFFSET(time_delta_str), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, E },
  51. { "segment_times", "set segment split time points", OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL}, 0, 0, E },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement