bare-ffmpeg 1.0.0-27 → 1.0.0-28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -698,6 +698,28 @@ Parameters:
698
698
 
699
699
  **Returns**: A new `InputFormat` instance
700
700
 
701
+ #### Properties
702
+
703
+ ##### `InputFormat.extensions`
704
+
705
+ Gets the file extensions associated with this input format.
706
+
707
+ **Returns**: `string` - Comma-separated list of file extensions (e.g., `'mkv,mk3d,mka,mks,webm'`)
708
+
709
+ ##### `InputFormat.mimeType`
710
+
711
+ Gets the MIME type for this input format.
712
+
713
+ **Returns**: `string` - The MIME type (e.g., `'audio/webm,audio/x-matroska,video/webm,video/x-matroska'`)
714
+
715
+ #### Example
716
+
717
+ ```js
718
+ const format = new ffmpeg.InputFormat('webm')
719
+ console.log(format.extensions) // 'mkv,mk3d,mka,mks,webm'
720
+ console.log(format.mimeType) // 'audio/webm,audio/x-matroska,video/webm,video/x-matroska'
721
+ ```
722
+
701
723
  #### Methods
702
724
 
703
725
  ##### `InputFormat.destroy()`
@@ -720,6 +742,28 @@ Parameters:
720
742
 
721
743
  **Returns**: A new `OutputFormat` instance
722
744
 
745
+ #### Properties
746
+
747
+ ##### `OutputFormat.extensions`
748
+
749
+ Gets the file extensions associated with this output format.
750
+
751
+ **Returns**: `string` - Comma-separated list of file extensions (e.g., `'webm'`, `'mp4,m4a,m4v'`)
752
+
753
+ ##### `OutputFormat.mimeType`
754
+
755
+ Gets the MIME type for this output format.
756
+
757
+ **Returns**: `string` - The MIME type (e.g., `'video/webm'`, `'video/mp4'`)
758
+
759
+ #### Example
760
+
761
+ ```js
762
+ const format = new ffmpeg.OutputFormat('webm')
763
+ console.log(format.extensions) // 'webm'
764
+ console.log(format.mimeType) // 'video/webm'
765
+ ```
766
+
723
767
  #### Methods
724
768
 
725
769
  ##### `OutputFormat.destroy()`
@@ -784,6 +828,25 @@ Destroys the `Frame` and frees all associated resources. Automatically called wh
784
828
 
785
829
  **Returns**: `void`
786
830
 
831
+ ##### `Frame.copyProperties(otherFrame)`
832
+
833
+ Copies all metadata properties such as timestamps, timebase and width/height for videoframes and
834
+ sampleRate channelLayout for audioFrames.
835
+
836
+ see `av_frame_copy_props()` for details.
837
+
838
+ ```js
839
+ const src = new ffmpeg.Frame()
840
+ const dst = new ffmpeg.Frame()
841
+
842
+ decoder.receiveFrame(src)
843
+ rescaler.convert(src, dst)
844
+
845
+ dst.copyProperties(src) // transfer all meta-data
846
+ ```
847
+
848
+ **Returns**: `void`
849
+
787
850
  ### `Packet`
788
851
 
789
852
  This structure stores compressed data. It is typically exported by demuxers and then passed as input to decoders, or received as output from encoders and then passed to muxers.
package/binding.cc CHANGED
@@ -376,6 +376,24 @@ bare_ffmpeg_input_format_get_flags(
376
376
  return format->handle->flags;
377
377
  }
378
378
 
379
+ static std::string
380
+ bare_ffmpeg_input_format_get_extensions(
381
+ js_env_t *env,
382
+ js_receiver_t,
383
+ js_arraybuffer_span_of_t<bare_ffmpeg_input_format_t, 1> context
384
+ ) {
385
+ return context->handle->extensions;
386
+ }
387
+
388
+ static std::string
389
+ bare_ffmpeg_input_format_get_mime_type(
390
+ js_env_t *env,
391
+ js_receiver_t,
392
+ js_arraybuffer_span_of_t<bare_ffmpeg_input_format_t, 1> context
393
+ ) {
394
+ return context->handle->mime_type;
395
+ }
396
+
379
397
  static js_arraybuffer_t
380
398
  bare_ffmpeg_format_context_open_input_with_io(
381
399
  js_env_t *env,
@@ -503,6 +521,24 @@ bare_ffmpeg_format_context_open_output(
503
521
  return handle;
504
522
  }
505
523
 
524
+ static std::string
525
+ bare_ffmpeg_output_format_get_extensions(
526
+ js_env_t *env,
527
+ js_receiver_t,
528
+ js_arraybuffer_span_of_t<bare_ffmpeg_output_format_t, 1> context
529
+ ) {
530
+ return context->handle->extensions;
531
+ }
532
+
533
+ static std::string
534
+ bare_ffmpeg_output_format_get_mime_type(
535
+ js_env_t *env,
536
+ js_receiver_t,
537
+ js_arraybuffer_span_of_t<bare_ffmpeg_output_format_t, 1> context
538
+ ) {
539
+ return context->handle->mime_type;
540
+ }
541
+
506
542
  static void
507
543
  bare_ffmpeg_format_context_close_output(
508
544
  js_env_t *env,
@@ -1157,6 +1193,23 @@ bare_ffmpeg_frame_set_channel_layout(
1157
1193
  assert(err == 0);
1158
1194
  }
1159
1195
 
1196
+ static void
1197
+ bare_ffmpeg_frame_copy_properties(
1198
+ js_env_t *env,
1199
+ js_receiver_t,
1200
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> dst,
1201
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> src
1202
+ ) {
1203
+ int err = av_frame_copy_props(dst->handle, src->handle);
1204
+
1205
+ if (err < 0) {
1206
+ err = js_throw_error(env, NULL, av_err2str(err));
1207
+ assert(err == 0);
1208
+
1209
+ throw js_pending_exception;
1210
+ }
1211
+ }
1212
+
1160
1213
  static bool
1161
1214
  bare_ffmpeg_codec_context_open_with_options(
1162
1215
  js_env_t *env,
@@ -3596,16 +3649,23 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3596
3649
  V("initIOContext", bare_ffmpeg_io_context_init)
3597
3650
  V("destroyIOContext", bare_ffmpeg_io_context_destroy)
3598
3651
 
3599
- V("initOutputFormat", bare_ffmpeg_output_format_init)
3600
3652
  V("initInputFormat", bare_ffmpeg_input_format_init)
3601
- V("getOutputFormatFlags", bare_ffmpeg_output_format_get_flags)
3602
3653
  V("getInputFormatFlags", bare_ffmpeg_input_format_get_flags)
3654
+ V("getInputFormatExtensions", bare_ffmpeg_input_format_get_extensions)
3655
+ V("getInputFormatMimeType", bare_ffmpeg_input_format_get_mime_type)
3656
+
3657
+ V("initOutputFormat", bare_ffmpeg_output_format_init)
3658
+ V("getOutputFormatFlags", bare_ffmpeg_output_format_get_flags)
3659
+ V("getOutputFormatExtensions", bare_ffmpeg_output_format_get_extensions)
3660
+ V("getOutputFormatMimeType", bare_ffmpeg_output_format_get_mime_type)
3603
3661
 
3604
3662
  V("openInputFormatContextWithIO", bare_ffmpeg_format_context_open_input_with_io)
3605
3663
  V("openInputFormatContextWithFormat", bare_ffmpeg_format_context_open_input_with_format)
3606
3664
  V("closeInputFormatContext", bare_ffmpeg_format_context_close_input)
3665
+
3607
3666
  V("openOutputFormatContext", bare_ffmpeg_format_context_open_output)
3608
3667
  V("closeOutputFormatContext", bare_ffmpeg_format_context_close_output)
3668
+
3609
3669
  V("getFormatContextStreams", bare_ffmpeg_format_context_get_streams)
3610
3670
  V("getFormatContextBestStreamIndex", bare_ffmpeg_format_context_get_best_stream_index)
3611
3671
  V("createFormatContextStream", bare_ffmpeg_format_context_create_stream)
@@ -3737,6 +3797,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3737
3797
  V("setFramePacketDTS", bare_ffmpeg_frame_set_pkt_dts)
3738
3798
  V("getFrameTimeBase", bare_ffmpeg_frame_get_time_base)
3739
3799
  V("setFrameTimeBase", bare_ffmpeg_frame_set_time_base)
3800
+ V("copyFrameProperties", bare_ffmpeg_frame_copy_properties)
3740
3801
  V("allocFrame", bare_ffmpeg_frame_alloc)
3741
3802
 
3742
3803
  V("initImage", bare_ffmpeg_image_init)
package/lib/frame.js CHANGED
@@ -88,6 +88,10 @@ module.exports = class FFmpegFrame {
88
88
  binding.setFrameTimeBase(this._handle, value.numerator, value.denominator)
89
89
  }
90
90
 
91
+ copyProperties(source) {
92
+ binding.copyFrameProperties(this._handle, source._handle)
93
+ }
94
+
91
95
  alloc() {
92
96
  binding.allocFrame(this._handle, 32)
93
97
  }
@@ -26,4 +26,12 @@ module.exports = class FFmpegInputFormat {
26
26
  get flags() {
27
27
  return binding.getInputFormatFlags(this._handle)
28
28
  }
29
+
30
+ get extensions() {
31
+ return binding.getInputFormatExtensions(this._handle)
32
+ }
33
+
34
+ get mimeType() {
35
+ return binding.getInputFormatMimeType(this._handle)
36
+ }
29
37
  }
@@ -8,4 +8,12 @@ module.exports = class FFmpegOutputFormat {
8
8
  get flags() {
9
9
  return binding.getOutputFormatFlags(this._handle)
10
10
  }
11
+
12
+ get extensions() {
13
+ return binding.getOutputFormatExtensions(this._handle)
14
+ }
15
+
16
+ get mimeType() {
17
+ return binding.getOutputFormatMimeType(this._handle)
18
+ }
11
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-ffmpeg",
3
- "version": "1.0.0-27",
3
+ "version": "1.0.0-28",
4
4
  "description": "Low-level FFmpeg bindings for Bare",
5
5
  "exports": {
6
6
  ".": "./index.js",