mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-28 19:58:38 +00:00
fix:recording with old decoding/encoding API
The deprecated avcodec_decode_video2() should always the whole packet, so there is no need to loop (cf doc/examples/demuxing_decoding.c in FFmpeg). This hack changed the packet size and data pointer. This broke recording which used the same packet.
This commit is contained in:
parent
667b09259c
commit
2d6dfc09e1
1 changed files with 13 additions and 17 deletions
|
@ -367,23 +367,19 @@ void Decoder::run()
|
|||
av_packet_unref(&packet);
|
||||
goto runQuit;
|
||||
}
|
||||
#else
|
||||
while (packet.size > 0) {
|
||||
int gotPicture = 0;
|
||||
int len = -1;
|
||||
if (decodingFrame) {
|
||||
len = avcodec_decode_video2(codecCtx, decodingFrame, &gotPicture, &packet);
|
||||
}
|
||||
if (len < 0) {
|
||||
qCritical("Could not decode video packet: %d", len);
|
||||
av_packet_unref(&packet);
|
||||
goto runQuit;
|
||||
}
|
||||
if (gotPicture) {
|
||||
pushFrame();
|
||||
}
|
||||
packet.size -= len;
|
||||
packet.data += len;
|
||||
#else
|
||||
int gotPicture = 0;
|
||||
int len = -1;
|
||||
if (decodingFrame) {
|
||||
len = avcodec_decode_video2(codecCtx, decodingFrame, &gotPicture, &packet);
|
||||
}
|
||||
if (len < 0) {
|
||||
qCritical("Could not decode video packet: %d", len);
|
||||
av_packet_unref(&packet);
|
||||
goto runQuit;
|
||||
}
|
||||
if (gotPicture) {
|
||||
pushFrame();
|
||||
}
|
||||
#endif
|
||||
if (m_recorder) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue