@@ -1876,7 +1876,7 @@ export class FFprobeKit {
1876
1876
* @return media information session created for this execution
1877
1877
*/
1878
1878
static async getMediaInformationAsync ( path , executeCallback , logCallback , waitTimeout ) {
1879
- const commandArguments = [ "-v" , "error" , "-hide_banner" , "-print_format" , "json" , "-show_format" , "-show_streams" , "-i" , path ] ;
1879
+ const commandArguments = [ "-v" , "error" , "-hide_banner" , "-print_format" , "json" , "-show_format" , "-show_streams" , "-show_chapters" , "- i", path ] ;
1880
1880
return FFprobeKit . getMediaInformationFromCommandArgumentsAsync ( commandArguments , executeCallback , logCallback , waitTimeout ) ;
1881
1881
}
1882
1882
@@ -2221,6 +2221,28 @@ export class MediaInformation {
2221
2221
return list ;
2222
2222
}
2223
2223
2224
+ /**
2225
+ * Returns the chapters found as array.
2226
+ *
2227
+ * @returns Chapter array
2228
+ */
2229
+ getChapters ( ) {
2230
+ let list = [ ] ;
2231
+ let chapterList ;
2232
+
2233
+ if ( this . #allProperties !== undefined ) {
2234
+ chapterList = this . #allProperties. chapters ;
2235
+ }
2236
+
2237
+ if ( chapterList !== undefined ) {
2238
+ chapterList . forEach ( ( chapter ) => {
2239
+ list . push ( new Chapter ( chapter ) ) ;
2240
+ } ) ;
2241
+ }
2242
+
2243
+ return list ;
2244
+ }
2245
+
2224
2246
/**
2225
2247
* Returns the media property associated with the key.
2226
2248
*
@@ -2788,3 +2810,137 @@ export class StreamInformation {
2788
2810
return this . #allProperties;
2789
2811
}
2790
2812
}
2813
+
2814
+ /**
2815
+ * Chapter class.
2816
+ */
2817
+ export class Chapter {
2818
+
2819
+ static KEY_ID = "id" ;
2820
+ static KEY_TIME_BASE = "time_base" ;
2821
+ static KEY_START = "start" ;
2822
+ static KEY_START_TIME = "start_time" ;
2823
+ static KEY_END = "end" ;
2824
+ static KEY_END_TIME = "end_time" ;
2825
+ static KEY_TAGS = "tags" ;
2826
+
2827
+ #allProperties;
2828
+
2829
+ constructor ( properties ) {
2830
+ this . #allProperties = properties ;
2831
+ }
2832
+
2833
+ /**
2834
+ * Returns id.
2835
+ *
2836
+ * @return id
2837
+ */
2838
+ getId ( ) {
2839
+ return this . getNumberProperty ( Chapter . KEY_ID ) ;
2840
+ }
2841
+
2842
+ /**
2843
+ * Returns time base.
2844
+ *
2845
+ * @return time base
2846
+ */
2847
+ getTimeBase ( ) {
2848
+ return this . getStringProperty ( Chapter . KEY_TIME_BASE ) ;
2849
+ }
2850
+
2851
+ /**
2852
+ * Returns start.
2853
+ *
2854
+ * @return start
2855
+ */
2856
+ getStart ( ) {
2857
+ return this . getNumberProperty ( Chapter . KEY_START ) ;
2858
+ }
2859
+
2860
+ /**
2861
+ * Returns start time.
2862
+ *
2863
+ * @return start time
2864
+ */
2865
+ getStartTime ( ) {
2866
+ return this . getStringProperty ( Chapter . KEY_START_TIME ) ;
2867
+ }
2868
+
2869
+ /**
2870
+ * Returns end.
2871
+ *
2872
+ * @return end
2873
+ */
2874
+ getEnd ( ) {
2875
+ return this . getNumberProperty ( Chapter . KEY_END ) ;
2876
+ }
2877
+
2878
+ /**
2879
+ * Returns end time.
2880
+ *
2881
+ * @return end time
2882
+ */
2883
+ getEndTime ( ) {
2884
+ return this . getStringProperty ( Chapter . KEY_END_TIME ) ;
2885
+ }
2886
+
2887
+ /**
2888
+ * Returns all tags.
2889
+ *
2890
+ * @return tags object
2891
+ */
2892
+ getTags ( ) {
2893
+ return this . getProperties ( StreamInformation . KEY_TAGS ) ;
2894
+ }
2895
+
2896
+ /**
2897
+ * Returns the chapter property associated with the key.
2898
+ *
2899
+ * @param key property key
2900
+ * @return chapter property as string or undefined if the key is not found
2901
+ */
2902
+ getStringProperty ( key ) {
2903
+ if ( this . #allProperties !== undefined ) {
2904
+ return this . #allProperties[ key ] ;
2905
+ } else {
2906
+ return undefined ;
2907
+ }
2908
+ }
2909
+
2910
+ /**
2911
+ * Returns the chapter property associated with the key.
2912
+ *
2913
+ * @param key property key
2914
+ * @return chapter property as number or undefined if the key is not found
2915
+ */
2916
+ getNumberProperty ( key ) {
2917
+ if ( this . #allProperties !== undefined ) {
2918
+ return this . #allProperties[ key ] ;
2919
+ } else {
2920
+ return undefined ;
2921
+ }
2922
+ }
2923
+
2924
+ /**
2925
+ * Returns the chapter properties associated with the key.
2926
+ *
2927
+ * @param key properties key
2928
+ * @return chapter properties as an object or undefined if the key is not found
2929
+ */
2930
+ getProperties ( key ) {
2931
+ if ( this . #allProperties !== undefined ) {
2932
+ return this . #allProperties[ key ] ;
2933
+ } else {
2934
+ return undefined ;
2935
+ }
2936
+ }
2937
+
2938
+ /**
2939
+ * Returns all properties found.
2940
+ *
2941
+ * @returns an object in which properties can be accessed by property names
2942
+ */
2943
+ getAllProperties ( ) {
2944
+ return this . #allProperties;
2945
+ }
2946
+ }
0 commit comments