[Cin] Reverse playback hack
Andrew Randrianasulu
randrianasulu at gmail.com
Sun Jun 21 21:33:36 CEST 2020
Hi all!
While testing .prores files I noticed I missed this codec in my hack for faster reverse playback of
I-only video tracks ...
Now I added it there, and on my 4 core AMD reverse playback (2x, 1x) indeed
faster now.
I wonder how much I break shuttle controller higher speeds or complex plugin chains?
Hack attached.
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 70098ca..32867de 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -1192,10 +1192,19 @@ int FFVideoStream::video_seek(int64_t pos)
if( pos == curr_pos-1 && !seeked ) return 0;
// if close enough, just read up to current
int gop = avctx->gop_size;
- if( gop < 4 ) gop = 4;
+ if( gop < 4 && gop != 0) gop = 4;
if( gop > 64 ) gop = 64;
+ if( gop == 0 ) gop = 1;
+ //fprintf(stderr, "GOP: %i \n", gop);
int read_limit = curr_pos + 3*gop;
if( pos >= curr_pos && pos <= read_limit ) return 0;
+ // fixup for I-only codecs, not sure why it needed with ffmpeg 4.2
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO || st->codecpar->codec_id == AV_CODEC_ID_MJPEG ||
+ st->codecpar->codec_id == AV_CODEC_ID_FFVHUFF || st->codecpar->codec_id == AV_CODEC_ID_DNXHD ||
+ st->codecpar->codec_id ==AV_CODEC_ID_HUFFYUV || st->codecpar->codec_id == AV_CODEC_ID_PRORES) {
+ gop = 1;
+ if( seek(pos - 2*gop, frame_rate) < 0 ) return -1;
+ }
// guarentee preload more than 2*gop frames
if( seek(pos - 3*gop, frame_rate) < 0 ) return -1;
return 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: I-only_files_reverse_play_speedup.diff
Type: text/x-diff
Size: 1169 bytes
Desc: not available
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20200621/6d411009/attachment.bin>
More information about the Cin
mailing list