EpText.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package VideoHandle;
  2. /**
  3. * Created by Administrator on 2017/11/8.
  4. */
  5. public class EpText {
  6. private String textFitler;
  7. /**
  8. * @param x 文字起始位置X
  9. * @param y 文字起始位置Y
  10. * @param size 文字的大小
  11. * @param color 文字的颜色
  12. * @param ttf 文字的字体文件路径
  13. * @param text 添加文字的内容
  14. * @param time 起始结束时间(传null的时候为一直显示)
  15. */
  16. public EpText(int x, int y, float size, Color color, String ttf, String text, Time time) {
  17. this.textFitler = "drawtext=fontfile=" + ttf + ":fontsize=" + size + ":fontcolor=" + color.getColor() + ":x=" + x + ":y=" + y + ":text='" + text + "'" + (time == null ? "" : time.getTime());
  18. }
  19. public String getTextFitler() {
  20. return textFitler;
  21. }
  22. /**
  23. * 起始结束时间的类
  24. */
  25. public static class Time {
  26. private String time;
  27. public Time(int start, int end) {
  28. this.time = ":enable=between(t\\," + start + "\\," + end + ")";
  29. }
  30. public String getTime() {
  31. return time;
  32. }
  33. }
  34. /**
  35. * 颜色
  36. */
  37. public enum Color {
  38. Red("Red"), Blue("Blue"), Yellow("Yellow"), Black("Black"), DarkBlue("DarkBlue"),
  39. Green("Green"), SkyBlue("SkyBlue"), Orange("Orange"), White("White"), Cyan("Cyan");
  40. private String color;
  41. Color(String color) {
  42. this.color = color;
  43. }
  44. public String getColor() {
  45. return color;
  46. }
  47. }
  48. }