bare-ffmpeg 1.0.0-3 → 1.0.0-6
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/binding.c +72 -91
- package/lib/constants.js +1 -1
- package/lib/dictionary.js +0 -10
- package/lib/format-context.js +7 -6
- package/lib/frame.js +11 -19
- package/lib/image.js +8 -0
- package/lib/input-format.js +0 -3
- package/lib/packet.js +0 -6
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-ia32/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-x64/bare-ffmpeg.bare +0 -0
package/binding.c
CHANGED
|
@@ -167,10 +167,12 @@ bare_ffmpeg_output_format_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
167
167
|
if (format == NULL) {
|
|
168
168
|
err = js_throw_errorf(env, NULL, "No output format found for name '%s'", name);
|
|
169
169
|
assert(err == 0);
|
|
170
|
+
|
|
170
171
|
free(name);
|
|
171
172
|
|
|
172
173
|
return NULL;
|
|
173
174
|
}
|
|
175
|
+
|
|
174
176
|
free(name);
|
|
175
177
|
|
|
176
178
|
js_value_t *handle;
|
|
@@ -211,10 +213,12 @@ bare_ffmpeg_input_format_init(js_env_t *env, js_callback_info_t *info) {
|
|
|
211
213
|
if (format == NULL) {
|
|
212
214
|
err = js_throw_errorf(env, NULL, "No input format found for name '%s'", name);
|
|
213
215
|
assert(err == 0);
|
|
216
|
+
|
|
214
217
|
free(name);
|
|
215
218
|
|
|
216
219
|
return NULL;
|
|
217
220
|
}
|
|
221
|
+
|
|
218
222
|
free(name);
|
|
219
223
|
|
|
220
224
|
js_value_t *handle;
|
|
@@ -302,6 +306,7 @@ bare_ffmpeg_format_context_open_input_with_format(js_env_t *env, js_callback_inf
|
|
|
302
306
|
assert(err == 0);
|
|
303
307
|
|
|
304
308
|
context->handle = avformat_alloc_context();
|
|
309
|
+
|
|
305
310
|
context->handle->opaque = (void *) context;
|
|
306
311
|
|
|
307
312
|
bare_ffmpeg_dictionary_t *options;
|
|
@@ -319,6 +324,7 @@ bare_ffmpeg_format_context_open_input_with_format(js_env_t *env, js_callback_inf
|
|
|
319
324
|
assert(err == 0);
|
|
320
325
|
|
|
321
326
|
err = avformat_open_input(&context->handle, (char *) url, format->handle, &options->handle);
|
|
327
|
+
|
|
322
328
|
free(url);
|
|
323
329
|
|
|
324
330
|
if (err < 0) {
|
|
@@ -485,13 +491,12 @@ bare_ffmpeg_format_context_get_best_stream_index(js_env_t *env, js_callback_info
|
|
|
485
491
|
err = js_get_value_int32(env, argv[1], &type);
|
|
486
492
|
assert(err == 0);
|
|
487
493
|
|
|
488
|
-
int
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
494
|
+
int i = av_find_best_stream(context->handle, type, -1, -1, NULL, 0);
|
|
495
|
+
|
|
496
|
+
if (i < 0) i = -1;
|
|
492
497
|
|
|
493
498
|
js_value_t *result;
|
|
494
|
-
err = js_create_int32(env,
|
|
499
|
+
err = js_create_int32(env, i, &result);
|
|
495
500
|
assert(err == 0);
|
|
496
501
|
|
|
497
502
|
return result;
|
|
@@ -752,6 +757,7 @@ bare_ffmpeg_codec_context_open(js_env_t *env, js_callback_info_t *info) {
|
|
|
752
757
|
|
|
753
758
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
754
759
|
assert(err == 0);
|
|
760
|
+
|
|
755
761
|
assert(argc == 1);
|
|
756
762
|
|
|
757
763
|
bare_ffmpeg_codec_context_t *context;
|
|
@@ -777,6 +783,7 @@ bare_ffmpeg_codec_context_open_with_options(js_env_t *env, js_callback_info_t *i
|
|
|
777
783
|
|
|
778
784
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
779
785
|
assert(err == 0);
|
|
786
|
+
|
|
780
787
|
assert(argc == 2);
|
|
781
788
|
|
|
782
789
|
bare_ffmpeg_codec_context_t *context;
|
|
@@ -788,6 +795,7 @@ bare_ffmpeg_codec_context_open_with_options(js_env_t *env, js_callback_info_t *i
|
|
|
788
795
|
assert(err == 0);
|
|
789
796
|
|
|
790
797
|
err = avcodec_open2(context->handle, context->handle->codec, &options->handle);
|
|
798
|
+
|
|
791
799
|
if (err < 0) {
|
|
792
800
|
err = js_throw_error(env, NULL, av_err2str(err));
|
|
793
801
|
assert(err == 0);
|
|
@@ -1033,6 +1041,7 @@ bare_ffmpeg_codec_context_receive_packet(js_env_t *env, js_callback_info_t *info
|
|
|
1033
1041
|
|
|
1034
1042
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1035
1043
|
assert(err == 0);
|
|
1044
|
+
|
|
1036
1045
|
assert(argc == 2);
|
|
1037
1046
|
|
|
1038
1047
|
bare_ffmpeg_codec_context_t *context;
|
|
@@ -1068,6 +1077,7 @@ bare_ffmpeg_codec_context_send_frame(js_env_t *env, js_callback_info_t *info) {
|
|
|
1068
1077
|
|
|
1069
1078
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1070
1079
|
assert(err == 0);
|
|
1080
|
+
|
|
1071
1081
|
assert(argc == 2);
|
|
1072
1082
|
|
|
1073
1083
|
bare_ffmpeg_codec_context_t *context;
|
|
@@ -1084,6 +1094,7 @@ bare_ffmpeg_codec_context_send_frame(js_env_t *env, js_callback_info_t *info) {
|
|
|
1084
1094
|
js_value_t *result;
|
|
1085
1095
|
err = js_get_boolean(env, false, &result);
|
|
1086
1096
|
assert(err == 0);
|
|
1097
|
+
|
|
1087
1098
|
return result;
|
|
1088
1099
|
}
|
|
1089
1100
|
|
|
@@ -1162,8 +1173,6 @@ bare_ffmpeg_codec_parameters_from_context(js_env_t *env, js_callback_info_t *inf
|
|
|
1162
1173
|
if (err < 0) {
|
|
1163
1174
|
err = js_throw_error(env, NULL, av_err2str(err));
|
|
1164
1175
|
assert(err == 0);
|
|
1165
|
-
|
|
1166
|
-
return NULL;
|
|
1167
1176
|
}
|
|
1168
1177
|
|
|
1169
1178
|
return NULL;
|
|
@@ -1194,8 +1203,6 @@ bare_ffmpeg_codec_parameters_to_context(js_env_t *env, js_callback_info_t *info)
|
|
|
1194
1203
|
if (err < 0) {
|
|
1195
1204
|
err = js_throw_error(env, NULL, av_err2str(err));
|
|
1196
1205
|
assert(err == 0);
|
|
1197
|
-
|
|
1198
|
-
return NULL;
|
|
1199
1206
|
}
|
|
1200
1207
|
|
|
1201
1208
|
return NULL;
|
|
@@ -1332,7 +1339,7 @@ bare_ffmpeg_frame_destroy(js_env_t *env, js_callback_info_t *info) {
|
|
|
1332
1339
|
}
|
|
1333
1340
|
|
|
1334
1341
|
static js_value_t *
|
|
1335
|
-
|
|
1342
|
+
bare_ffmpeg_frame_get_audio_channel(js_env_t *env, js_callback_info_t *info) {
|
|
1336
1343
|
int err;
|
|
1337
1344
|
|
|
1338
1345
|
size_t argc = 2;
|
|
@@ -1375,6 +1382,7 @@ bare_ffmpeg_frame_get_width(js_env_t *env, js_callback_info_t *info) {
|
|
|
1375
1382
|
|
|
1376
1383
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1377
1384
|
assert(err == 0);
|
|
1385
|
+
|
|
1378
1386
|
assert(argc == 1);
|
|
1379
1387
|
|
|
1380
1388
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1397,6 +1405,7 @@ bare_ffmpeg_frame_set_width(js_env_t *env, js_callback_info_t *info) {
|
|
|
1397
1405
|
|
|
1398
1406
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1399
1407
|
assert(err == 0);
|
|
1408
|
+
|
|
1400
1409
|
assert(argc == 2);
|
|
1401
1410
|
|
|
1402
1411
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1421,6 +1430,7 @@ bare_ffmpeg_frame_get_height(js_env_t *env, js_callback_info_t *info) {
|
|
|
1421
1430
|
|
|
1422
1431
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1423
1432
|
assert(err == 0);
|
|
1433
|
+
|
|
1424
1434
|
assert(argc == 1);
|
|
1425
1435
|
|
|
1426
1436
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1443,6 +1453,7 @@ bare_ffmpeg_frame_set_height(js_env_t *env, js_callback_info_t *info) {
|
|
|
1443
1453
|
|
|
1444
1454
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1445
1455
|
assert(err == 0);
|
|
1456
|
+
|
|
1446
1457
|
assert(argc == 2);
|
|
1447
1458
|
|
|
1448
1459
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1467,6 +1478,7 @@ bare_ffmpeg_frame_get_pixel_format(js_env_t *env, js_callback_info_t *info) {
|
|
|
1467
1478
|
|
|
1468
1479
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1469
1480
|
assert(err == 0);
|
|
1481
|
+
|
|
1470
1482
|
assert(argc == 1);
|
|
1471
1483
|
|
|
1472
1484
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1489,6 +1501,7 @@ bare_ffmpeg_frame_set_pixel_format(js_env_t *env, js_callback_info_t *info) {
|
|
|
1489
1501
|
|
|
1490
1502
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1491
1503
|
assert(err == 0);
|
|
1504
|
+
|
|
1492
1505
|
assert(argc == 2);
|
|
1493
1506
|
|
|
1494
1507
|
bare_ffmpeg_frame_t *frame;
|
|
@@ -1504,35 +1517,6 @@ bare_ffmpeg_frame_set_pixel_format(js_env_t *env, js_callback_info_t *info) {
|
|
|
1504
1517
|
return NULL;
|
|
1505
1518
|
}
|
|
1506
1519
|
|
|
1507
|
-
static js_value_t *
|
|
1508
|
-
bare_ffmpeg_frame_get_linesize(js_env_t *env, js_callback_info_t *info) {
|
|
1509
|
-
int err;
|
|
1510
|
-
|
|
1511
|
-
size_t argc = 2;
|
|
1512
|
-
js_value_t *argv[2];
|
|
1513
|
-
|
|
1514
|
-
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1515
|
-
assert(err == 0);
|
|
1516
|
-
assert(argc == 2);
|
|
1517
|
-
|
|
1518
|
-
bare_ffmpeg_frame_t *frame;
|
|
1519
|
-
err = js_get_arraybuffer_info(env, argv[0], (void **) &frame, NULL);
|
|
1520
|
-
assert(err == 0);
|
|
1521
|
-
|
|
1522
|
-
uint32_t channel;
|
|
1523
|
-
err = js_get_value_uint32(env, argv[1], &channel);
|
|
1524
|
-
assert(err == 0);
|
|
1525
|
-
assert(channel < AV_NUM_DATA_POINTERS);
|
|
1526
|
-
|
|
1527
|
-
int32_t linesize = frame->handle->linesize[channel];
|
|
1528
|
-
|
|
1529
|
-
js_value_t *result;
|
|
1530
|
-
err = js_create_int32(env, linesize, &result);
|
|
1531
|
-
assert(err == 0);
|
|
1532
|
-
|
|
1533
|
-
return result;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
1520
|
static js_value_t *
|
|
1537
1521
|
bare_ffmpeg_frame_alloc(js_env_t *env, js_callback_info_t *info) {
|
|
1538
1522
|
int err;
|
|
@@ -1542,71 +1526,27 @@ bare_ffmpeg_frame_alloc(js_env_t *env, js_callback_info_t *info) {
|
|
|
1542
1526
|
|
|
1543
1527
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1544
1528
|
assert(err == 0);
|
|
1529
|
+
|
|
1545
1530
|
assert(argc == 2);
|
|
1546
1531
|
|
|
1547
1532
|
bare_ffmpeg_frame_t *frame;
|
|
1548
1533
|
err = js_get_arraybuffer_info(env, argv[0], (void **) &frame, NULL);
|
|
1549
1534
|
assert(err == 0);
|
|
1550
|
-
assert(frame->handle != NULL);
|
|
1551
1535
|
|
|
1552
1536
|
int align;
|
|
1553
1537
|
err = js_get_value_int32(env, argv[1], &align);
|
|
1554
1538
|
assert(err == 0);
|
|
1555
|
-
assert(frame->handle != NULL);
|
|
1556
1539
|
|
|
1557
1540
|
err = av_frame_get_buffer(frame->handle, align);
|
|
1541
|
+
|
|
1558
1542
|
if (err < 0) {
|
|
1559
1543
|
err = js_throw_error(env, NULL, av_err2str(err));
|
|
1560
1544
|
assert(err == 0);
|
|
1561
|
-
return NULL;
|
|
1562
1545
|
}
|
|
1563
1546
|
|
|
1564
1547
|
return NULL;
|
|
1565
1548
|
}
|
|
1566
1549
|
|
|
1567
|
-
static js_value_t *
|
|
1568
|
-
bare_ffmpeg_frame_get_data(js_env_t *env, js_callback_info_t *info) {
|
|
1569
|
-
int err;
|
|
1570
|
-
|
|
1571
|
-
size_t argc = 1;
|
|
1572
|
-
js_value_t *argv[1];
|
|
1573
|
-
|
|
1574
|
-
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1575
|
-
assert(err == 0);
|
|
1576
|
-
assert(argc == 1);
|
|
1577
|
-
|
|
1578
|
-
bare_ffmpeg_frame_t *frame;
|
|
1579
|
-
err = js_get_arraybuffer_info(env, argv[0], (void **) &frame, NULL);
|
|
1580
|
-
assert(err == 0);
|
|
1581
|
-
|
|
1582
|
-
int size = av_image_get_buffer_size(
|
|
1583
|
-
frame->handle->format,
|
|
1584
|
-
frame->handle->width,
|
|
1585
|
-
frame->handle->height,
|
|
1586
|
-
1
|
|
1587
|
-
);
|
|
1588
|
-
assert(size > 0);
|
|
1589
|
-
|
|
1590
|
-
js_value_t *result;
|
|
1591
|
-
uint8_t *buffer;
|
|
1592
|
-
err = js_create_arraybuffer(env, size, (void **) &buffer, &result);
|
|
1593
|
-
assert(err == 0);
|
|
1594
|
-
|
|
1595
|
-
err = av_image_copy_to_buffer(
|
|
1596
|
-
buffer,
|
|
1597
|
-
size,
|
|
1598
|
-
(const uint8_t *const *) frame->handle->data,
|
|
1599
|
-
frame->handle->linesize,
|
|
1600
|
-
frame->handle->format,
|
|
1601
|
-
frame->handle->width,
|
|
1602
|
-
frame->handle->height,
|
|
1603
|
-
1
|
|
1604
|
-
);
|
|
1605
|
-
assert(err >= 0);
|
|
1606
|
-
|
|
1607
|
-
return result;
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
1550
|
static js_value_t *
|
|
1611
1551
|
bare_ffmpeg_image_init(js_env_t *env, js_callback_info_t *info) {
|
|
1612
1552
|
int err;
|
|
@@ -1684,6 +1624,39 @@ bare_ffmpeg_image_fill(js_env_t *env, js_callback_info_t *info) {
|
|
|
1684
1624
|
return NULL;
|
|
1685
1625
|
}
|
|
1686
1626
|
|
|
1627
|
+
static js_value_t *
|
|
1628
|
+
bare_ffmpeg_image_get_line_size(js_env_t *env, js_callback_info_t *info) {
|
|
1629
|
+
int err;
|
|
1630
|
+
|
|
1631
|
+
size_t argc = 3;
|
|
1632
|
+
js_value_t *argv[3];
|
|
1633
|
+
|
|
1634
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1635
|
+
assert(err == 0);
|
|
1636
|
+
|
|
1637
|
+
assert(argc == 3);
|
|
1638
|
+
|
|
1639
|
+
int64_t pixel_format;
|
|
1640
|
+
err = js_get_value_int64(env, argv[0], &pixel_format);
|
|
1641
|
+
assert(err == 0);
|
|
1642
|
+
|
|
1643
|
+
int32_t width;
|
|
1644
|
+
err = js_get_value_int32(env, argv[1], &width);
|
|
1645
|
+
assert(err == 0);
|
|
1646
|
+
|
|
1647
|
+
int32_t plane;
|
|
1648
|
+
err = js_get_value_int32(env, argv[2], &plane);
|
|
1649
|
+
assert(err == 0);
|
|
1650
|
+
|
|
1651
|
+
int32_t linesize = av_image_get_linesize((enum AVPixelFormat) pixel_format, width, plane);
|
|
1652
|
+
|
|
1653
|
+
js_value_t *result;
|
|
1654
|
+
err = js_create_int32(env, linesize, &result);
|
|
1655
|
+
assert(err == 0);
|
|
1656
|
+
|
|
1657
|
+
return result;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1687
1660
|
static js_value_t *
|
|
1688
1661
|
bare_ffmpeg_packet_init(js_env_t *env, js_callback_info_t *info) {
|
|
1689
1662
|
int err;
|
|
@@ -1708,6 +1681,7 @@ bare_ffmpeg_packet_init_from_buffer(js_env_t *env, js_callback_info_t *info) {
|
|
|
1708
1681
|
|
|
1709
1682
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1710
1683
|
assert(err == 0);
|
|
1684
|
+
|
|
1711
1685
|
assert(argc == 3);
|
|
1712
1686
|
|
|
1713
1687
|
uint8_t *data;
|
|
@@ -1731,6 +1705,7 @@ bare_ffmpeg_packet_init_from_buffer(js_env_t *env, js_callback_info_t *info) {
|
|
|
1731
1705
|
memcpy(pkt->data, &data[offset], len);
|
|
1732
1706
|
|
|
1733
1707
|
js_value_t *handle;
|
|
1708
|
+
|
|
1734
1709
|
bare_ffmpeg_packet_t *packet;
|
|
1735
1710
|
err = js_create_arraybuffer(env, sizeof(bare_ffmpeg_packet_t), (void **) &packet, &handle);
|
|
1736
1711
|
assert(err == 0);
|
|
@@ -1821,14 +1796,15 @@ bare_ffmpeg_packet_get_data(js_env_t *env, js_callback_info_t *info) {
|
|
|
1821
1796
|
err = js_get_arraybuffer_info(env, argv[0], (void **) &packet, NULL);
|
|
1822
1797
|
assert(err == 0);
|
|
1823
1798
|
|
|
1824
|
-
js_value_t *
|
|
1799
|
+
js_value_t *handle;
|
|
1800
|
+
|
|
1825
1801
|
uint8_t *data;
|
|
1826
|
-
err = js_create_arraybuffer(env, packet->handle->size, (void **) &data, &
|
|
1802
|
+
err = js_create_arraybuffer(env, packet->handle->size, (void **) &data, &handle);
|
|
1827
1803
|
assert(err == 0);
|
|
1828
1804
|
|
|
1829
1805
|
memcpy(data, packet->handle->data, packet->handle->size);
|
|
1830
1806
|
|
|
1831
|
-
return
|
|
1807
|
+
return handle;
|
|
1832
1808
|
}
|
|
1833
1809
|
|
|
1834
1810
|
static js_value_t *
|
|
@@ -1982,6 +1958,7 @@ bare_ffmpeg_dictionary_destroy(js_env_t *env, js_callback_info_t *info) {
|
|
|
1982
1958
|
|
|
1983
1959
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1984
1960
|
assert(err == 0);
|
|
1961
|
+
|
|
1985
1962
|
assert(argc == 1);
|
|
1986
1963
|
|
|
1987
1964
|
bare_ffmpeg_dictionary_t *dict;
|
|
@@ -2002,6 +1979,7 @@ bare_ffmpeg_dictionary_set_entry(js_env_t *env, js_callback_info_t *info) {
|
|
|
2002
1979
|
|
|
2003
1980
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
2004
1981
|
assert(err == 0);
|
|
1982
|
+
|
|
2005
1983
|
assert(argc == 3);
|
|
2006
1984
|
|
|
2007
1985
|
bare_ffmpeg_dictionary_t *dict;
|
|
@@ -2029,6 +2007,7 @@ bare_ffmpeg_dictionary_set_entry(js_env_t *env, js_callback_info_t *info) {
|
|
|
2029
2007
|
|
|
2030
2008
|
err = av_dict_set(&dict->handle, (const char *) key, (const char *) value, 0);
|
|
2031
2009
|
assert(err == 0);
|
|
2010
|
+
|
|
2032
2011
|
free(key);
|
|
2033
2012
|
free(value);
|
|
2034
2013
|
|
|
@@ -2044,6 +2023,7 @@ bare_ffmpeg_dictionary_get_entry(js_env_t *env, js_callback_info_t *info) {
|
|
|
2044
2023
|
|
|
2045
2024
|
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
2046
2025
|
assert(err == 0);
|
|
2026
|
+
|
|
2047
2027
|
assert(argc == 2);
|
|
2048
2028
|
|
|
2049
2029
|
bare_ffmpeg_dictionary_t *dict;
|
|
@@ -2061,12 +2041,14 @@ bare_ffmpeg_dictionary_get_entry(js_env_t *env, js_callback_info_t *info) {
|
|
|
2061
2041
|
assert(err == 0);
|
|
2062
2042
|
|
|
2063
2043
|
AVDictionaryEntry *entry = av_dict_get(dict->handle, (const char *) key, NULL, 0);
|
|
2044
|
+
|
|
2064
2045
|
free(key);
|
|
2065
2046
|
|
|
2066
2047
|
if (entry == NULL) {
|
|
2067
2048
|
js_value_t *result;
|
|
2068
2049
|
err = js_get_null(env, &result);
|
|
2069
2050
|
assert(err == 0);
|
|
2051
|
+
|
|
2070
2052
|
return result;
|
|
2071
2053
|
}
|
|
2072
2054
|
|
|
@@ -2140,19 +2122,18 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
|
|
|
2140
2122
|
|
|
2141
2123
|
V("initFrame", bare_ffmpeg_frame_init)
|
|
2142
2124
|
V("destroyFrame", bare_ffmpeg_frame_destroy)
|
|
2143
|
-
V("
|
|
2125
|
+
V("getFrameAudioChannel", bare_ffmpeg_frame_get_audio_channel)
|
|
2144
2126
|
V("getFrameWidth", bare_ffmpeg_frame_get_width)
|
|
2145
2127
|
V("setFrameWidth", bare_ffmpeg_frame_set_width)
|
|
2146
2128
|
V("getFrameHeight", bare_ffmpeg_frame_get_height)
|
|
2147
2129
|
V("setFrameHeight", bare_ffmpeg_frame_set_height)
|
|
2148
2130
|
V("getFramePixelFormat", bare_ffmpeg_frame_get_pixel_format)
|
|
2149
2131
|
V("setFramePixelFormat", bare_ffmpeg_frame_set_pixel_format)
|
|
2150
|
-
V("getFrameLineSize", bare_ffmpeg_frame_get_linesize)
|
|
2151
2132
|
V("allocFrame", bare_ffmpeg_frame_alloc)
|
|
2152
|
-
V("getFrameData", bare_ffmpeg_frame_get_data)
|
|
2153
2133
|
|
|
2154
2134
|
V("initImage", bare_ffmpeg_image_init)
|
|
2155
2135
|
V("fillImage", bare_ffmpeg_image_fill)
|
|
2136
|
+
V("getImageLineSize", bare_ffmpeg_image_get_line_size)
|
|
2156
2137
|
|
|
2157
2138
|
V("initPacket", bare_ffmpeg_packet_init)
|
|
2158
2139
|
V("initPacketFromBuffer", bare_ffmpeg_packet_init_from_buffer)
|
package/lib/constants.js
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = exports = {
|
|
|
12
12
|
UYVY422: binding.AV_PIX_FMT_UYVY422,
|
|
13
13
|
YUV420P: binding.AV_PIX_FMT_YUV420P
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
mediaTypes: {
|
|
16
16
|
UNKNOWN: binding.AVMEDIA_TYPE_UNKNOWN,
|
|
17
17
|
VIDEO: binding.AVMEDIA_TYPE_VIDEO,
|
|
18
18
|
AUDIO: binding.AVMEDIA_TYPE_AUDIO,
|
package/lib/dictionary.js
CHANGED
|
@@ -14,20 +14,10 @@ module.exports = class FFmpegDictionary extends ReferenceCounted {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
get(key) {
|
|
17
|
-
if (typeof key !== 'string' || key.length < 1) {
|
|
18
|
-
throw new TypeError(`Key should be a non empty string`)
|
|
19
|
-
}
|
|
20
17
|
return binding.getDictionaryEntry(this._handle, key)
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
set(key, value) {
|
|
24
|
-
if (typeof key !== 'string' || key.length < 1) {
|
|
25
|
-
throw new TypeError(`Key should be a non empty string`)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (typeof value !== 'string' || value.length < 1) {
|
|
29
|
-
throw new TypeError(`Value should be a non empty string`)
|
|
30
|
-
}
|
|
31
21
|
binding.setDictionaryEntry(this._handle, key, value)
|
|
32
22
|
}
|
|
33
23
|
}
|
package/lib/format-context.js
CHANGED
|
@@ -4,6 +4,7 @@ const ReferenceCounted = require('./reference-counted')
|
|
|
4
4
|
const OutputFormat = require('./output-format')
|
|
5
5
|
const IOContext = require('./io-context')
|
|
6
6
|
const InputFormat = require('./input-format')
|
|
7
|
+
const Dictionary = require('./dictionary')
|
|
7
8
|
|
|
8
9
|
class FFmpegFormatContext extends ReferenceCounted {
|
|
9
10
|
constructor(io) {
|
|
@@ -42,12 +43,6 @@ class FFmpegFormatContext extends ReferenceCounted {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
getBestStream(type) {
|
|
45
|
-
if (typeof type !== 'number') {
|
|
46
|
-
throw new TypeError(
|
|
47
|
-
`Type parameter should be of type number but got: ${typeof type}`
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
46
|
if (this._streams.length == 0) {
|
|
52
47
|
return null
|
|
53
48
|
}
|
|
@@ -86,14 +81,20 @@ exports.InputFormatContext = class FFmpegInputFormatContext extends (
|
|
|
86
81
|
constructor(io, options, url = defaultURL) {
|
|
87
82
|
if (io instanceof IOContext) {
|
|
88
83
|
super(io)
|
|
84
|
+
|
|
89
85
|
this._handle = binding.openInputFormatContextWithIO(io._handle)
|
|
90
86
|
} else if (io instanceof InputFormat) {
|
|
91
87
|
super()
|
|
88
|
+
|
|
89
|
+
options = options || new Dictionary()
|
|
90
|
+
|
|
92
91
|
this._handle = binding.openInputFormatContextWithFormat(
|
|
93
92
|
io._handle,
|
|
94
93
|
options._handle,
|
|
95
94
|
url
|
|
96
95
|
)
|
|
96
|
+
|
|
97
|
+
options.destroy()
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
for (const handle of binding.getFormatContextStreams(this._handle)) {
|
package/lib/frame.js
CHANGED
|
@@ -13,47 +13,39 @@ module.exports = class FFmpegFrame extends ReferenceCounted {
|
|
|
13
13
|
this._handle = null
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throw new RangeError(`Channel index must be between 0 and 7`)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return Buffer.from(binding.getFrameChannel(this._handle, i))
|
|
16
|
+
get width() {
|
|
17
|
+
return binding.getFrameWidth(this._handle)
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
set width(value) {
|
|
25
21
|
binding.setFrameWidth(this._handle, value)
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
get
|
|
29
|
-
return binding.
|
|
24
|
+
get height() {
|
|
25
|
+
return binding.getFrameHeight(this._handle)
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
set height(value) {
|
|
33
29
|
binding.setFrameHeight(this._handle, value)
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
get
|
|
37
|
-
return binding.
|
|
32
|
+
get pixelFormat() {
|
|
33
|
+
return binding.getFramePixelFormat(this._handle)
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
set pixelFormat(value) {
|
|
41
37
|
binding.setFramePixelFormat(this._handle, value)
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
audioChannel(i) {
|
|
41
|
+
if (i < 0 || i > 7) {
|
|
42
|
+
throw new RangeError(`Channel index must be between 0 and 7`)
|
|
43
|
+
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
return binding.getFrameLineSize(this._handle, channel)
|
|
45
|
+
return Buffer.from(binding.getFrameAudioChannel(this._handle, i))
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
alloc() {
|
|
53
49
|
binding.allocFrame(this._handle, 32)
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
get data() {
|
|
57
|
-
return Buffer.from(binding.getFrameData(this._handle))
|
|
58
|
-
}
|
|
59
51
|
}
|
package/lib/image.js
CHANGED
|
@@ -44,4 +44,12 @@ module.exports = class FFmpegImage {
|
|
|
44
44
|
frame._handle
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
lineSize(plane = 0) {
|
|
49
|
+
return binding.getImageLineSize(this._pixelFormat, this._width, plane)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static lineSize(pixelFormat, width, plane = 0) {
|
|
53
|
+
return binding.getImageLineSize(pixelFormat, width, plane)
|
|
54
|
+
}
|
|
47
55
|
}
|
package/lib/input-format.js
CHANGED
|
@@ -16,9 +16,6 @@ switch (Bare.platform) {
|
|
|
16
16
|
|
|
17
17
|
module.exports = class FFmpegInputFormat {
|
|
18
18
|
constructor(name = defaultName) {
|
|
19
|
-
if (typeof name !== 'string' || name.length < 1) {
|
|
20
|
-
throw new TypeError('Input format name should be a non empty string')
|
|
21
|
-
}
|
|
22
19
|
this._handle = binding.initInputFormat(name)
|
|
23
20
|
}
|
|
24
21
|
}
|
package/lib/packet.js
CHANGED
|
@@ -6,12 +6,6 @@ module.exports = class FFmpegPacket extends ReferenceCounted {
|
|
|
6
6
|
super()
|
|
7
7
|
|
|
8
8
|
if (buffer) {
|
|
9
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
10
|
-
throw TypeError(
|
|
11
|
-
`Buffer parameter should be of type Buffer but got: ${typeof buffer}`
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
this._handle = binding.initPacketFromBuffer(
|
|
16
10
|
buffer.buffer,
|
|
17
11
|
buffer.byteOffset,
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|