@scrypted/libav 1.0.14 → 1.0.16
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/.vscode/settings.json +6 -0
- package/package.json +1 -1
- package/src/decode.cpp +13 -17
package/package.json
CHANGED
package/src/decode.cpp
CHANGED
|
@@ -83,24 +83,20 @@ public:
|
|
|
83
83
|
// Decode video frames
|
|
84
84
|
while (av_read_frame(fmt_ctx_, packet) >= 0)
|
|
85
85
|
{
|
|
86
|
-
|
|
87
|
-
if (packet->stream_index != videoStreamIndex)
|
|
86
|
+
if (packet->stream_index == videoStreamIndex)
|
|
88
87
|
{
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (avcodec_send_packet(codecContext, packet) == 0)
|
|
93
|
-
{
|
|
94
|
-
if (avcodec_receive_frame(codecContext, frame) == 0)
|
|
88
|
+
if (avcodec_send_packet(codecContext, packet) == 0)
|
|
95
89
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
if (avcodec_receive_frame(codecContext, frame) == 0)
|
|
91
|
+
{
|
|
92
|
+
av_packet_free(&packet);
|
|
93
|
+
result = frame;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
99
96
|
}
|
|
97
|
+
av_packet_unref(packet); // Reset the packet for the next frame
|
|
100
98
|
}
|
|
101
|
-
av_packet_unref(packet); // Reset the packet for the next frame
|
|
102
99
|
}
|
|
103
|
-
fprintf(stdout, "finished reading a frame\n");
|
|
104
100
|
|
|
105
101
|
av_frame_free(&frame);
|
|
106
102
|
av_packet_free(&packet);
|
|
@@ -440,12 +436,12 @@ Napi::Value AVFormatContextObject::Open(const Napi::CallbackInfo &info)
|
|
|
440
436
|
return env.Null();
|
|
441
437
|
}
|
|
442
438
|
|
|
443
|
-
|
|
444
|
-
|
|
439
|
+
// Find the first video stream
|
|
440
|
+
#ifdef __APPLE__
|
|
445
441
|
const struct AVCodec *codec = nullptr;
|
|
446
|
-
|
|
442
|
+
#else
|
|
447
443
|
struct AVCodec *codec = nullptr;
|
|
448
|
-
|
|
444
|
+
#endif
|
|
449
445
|
|
|
450
446
|
/* find the video stream information */
|
|
451
447
|
ret = av_find_best_stream(fmt_ctx_, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
|