[Cin] [Libav-user] libavcodec usage inside Cinelerra-GG [LONG]

Andrew Randrianasulu randrianasulu at gmail.com
Mon Nov 4 16:18:44 CET 2019


В сообщении от Sunday 03 November 2019 13:56:09 Carl Eugen Hoyos написал(а):
> Am So., 3. Nov. 2019 um 11:53 Uhr schrieb Andrew Randrianasulu
> <randrianasulu at gmail.com>:
> 
> > For what exactly I should look?
> 
> You claim that AVStream->time_base is changing (which sounds strange to me
> but who know) on seeking, you could look (with printf's) how ffmpeg.c
> deals with this.
> I cannot know...

Update, just compiled CinelerraGG with ffmpeg.git

LANG=ru_RU.utf8 /dev/shm/tmp/cinelerra-goodguy-20191104/cinelerra-5.1/bin/cin
Cinelerra Infinity - built: Nov  4 2019 16:35:57
git://git.cinelerra-gg.org/goodguy/cinelerra.git
(c) 2006-2019 Heroine Virtual Ltd. by Adam Williams
(c) 2007-2019 cin5 derivative by W.P. Morrow aka goodguy
Cinelerra is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions. There is absolutely no warranty for Cinelerra.

FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,25
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Timebase from stream: 1,25
Timebase from stream: 1,25
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Timebase from stream: 1,30000
Session time: 0:00:19
Cpu time: user: 0:00:04.433 sys: 0:00:01.064

1,25 print was before I tried to seek in stream, but it jumped to 1,30000 after I tried to set playback cursor
to some 3 min into video.

Cinelerra git:
commit 83cdf330ba14342487a08d72e25ef29736d41100 (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Good Guy <good1.2guy at gmail.com>
Date:   Sat Nov 2 19:32:42 2019 -0600

    correct last chkin dvd opts files

ffmpeg.git:
commit ec3d3fc65d06a9f7bc4d32b12b14a7c75e00484d (HEAD -> master, origin/master, origin/HEAD)
Author: Jun Zhao <barryjzhao at tencent.com>
Date:   Sat Jun 15 16:21:56 2019 +0800

    lavf/asfdec: Simplify the check conditions

    Simplify the check conditions

    Signed-off-by: Jun Zhao <barryjzhao at tencent.com>


my diff for ffmpeg.c:

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 70098ca..3cf85a9 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -681,7 +681,11 @@ int FFStream::seek(int64_t no, double rate)
        }
        if( pos == curr_pos ) return 0;
        double secs = pos < 0 ? 0. : pos / rate;
-       AVRational time_base = st->time_base;
+// if user forced timebase to a specified stream
+       AVRational time_base = ffmpeg->force_timebase >= 0 ?
+               ffmpeg->fmt_ctx->streams[ffmpeg->force_timebase]->time_base :
+               st->time_base;
+               fprintf(stderr, "Timebase from stream: %i,%i \n", time_base.num, time_base.den);
        int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
        if( !tstmp ) {
                if( st->nb_index_entries > 0 ) tstmp = st->index_entries[0].timestamp;
@@ -1192,10 +1196,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 ) {
+       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;
@@ -1576,6 +1589,7 @@ FFMPEG::FFMPEG(FileBase *file_base)
        flow = 1;
        decoding = encoding = 0;
        has_audio = has_video = 0;
+       force_timebase = -1;
        opts = 0;
        opt_duration = -1;
        opt_video_filter = 0;
@@ -2271,6 +2285,8 @@ int FFMPEG::init_decoder(const char *filename)
                if( (tag=av_dict_get(opts, "format", NULL, 0)) != 0 ) {
                        ifmt = av_find_input_format(tag->value);
                }
+               if( (tag=av_dict_get(opts, "force_timebase", NULL, 0)) != 0 )
+                       force_timebase = atoi(tag->value);
        }
        else
                load_options("decode.opts", opts);

actually patch was mostly developed by CinelerraGG developer, I only added

 fprintf(stderr, "Timebase from stream: %i,%i \n", time_base.num, time_base.den);

(for testing I moved opts file I used to fix this stream away:

mv /home/guest/botva/Downloads/from_Vladimir/Leningrad\ dolphinarium\ 16\ 09\ 2009/LD_160909_2.opts \
/home/guest/botva/Downloads/from_Vladimir/Leningrad\ dolphinarium\ 16\ 09\ 2009/LD_160909_2___.opts )

Is this enough for demonstrating problem ?

> 
> Carl Eugen
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
> 
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".




More information about the Cin mailing list