View Issue Details

IDProjectCategoryView StatusLast Update
0000330Cinelerra-GG[All Projects] Bugpublic2020-01-01 00:25
ReporterAndrew-R Assigned Togoodguy  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2019-09 
Target VersionFixed in Version2019-11 
Summary0000330: AVI DV type 1 (ODML) fails to seek in CinGG
DescriptionIf you load AVI DV type 1 file bigger than 2Gb into CinGG and try to play from not default position - sound will become pulsed noise. Video still plays.

You can also try to fast play same file from any non-zero position, it will also fail.
Steps To ReproduceDownload big file from
 https://yadi.sk/i/ivzmAc2UGq-Wwg - this is 2,3G file as it was saved 10 years ago on my disk.

md5sum /home/guest/botva/Downloads/from_Vladimir/Leningrad\ dolphinarium\ 16\ 09\ 2009/LD_160909_2.avi
ec11ac9e644e7c949ca74db7b9c57111

Try to load this file in CinGG, even wait for audio indexing to finish (waveform will be drawn ok). Try to play from very start - it will work. Try to seek in file - sound will fail. Render will fail in audio department too :/
TagsDV

Activities

PhyllisSmith

PhyllisSmith

2020-01-01 00:25

manager   ~0002623

There are at least 3 possible workarounds available so I think Andrew is OK with closing this.
Latest workaround is to use the Transcode option under the Settings pulldown. This is the most obvious and easily done within Cinelerra. !st workaround suggestion was to simply do a fast ffmpeg copy to another file. 2nd workaround suggestion was a patch to handle this type of file.
Andrew-R

Andrew-R

2019-11-14 14:50

reporter   ~0002460

patch seems to work for me, with ffmpeg.git and CinelerraGG-git

avi_fix.patch (512 bytes)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 5cf67a4771..5bd2372c27 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1942,6 +1942,7 @@ AVInputFormat ff_avi_demuxer = {
     .long_name      = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
     .priv_data_size = sizeof(AVIContext),
     .extensions     = "avi",
+    .flags          = AVFMT_SEEK_NOSTREAMS,
     .read_probe     = avi_probe,
     .read_header    = avi_read_header,
     .read_packet    = avi_read_packet,
avi_fix.patch (512 bytes)
Andrew-R

Andrew-R

2019-11-08 15:04

reporter   ~0002444

so, brief testing (3 avi files, one is small - BBC.Natural.World.2010.A.Killer.Whale.Called.Luna.avi and two others are big DV files) showed this flag helped, no more broken sound after seek in LD_160909_2.avi, buger files still work.

Can anyone test this more, on different avi files?

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 5cf67a4771..5bd2372c27 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1942,6 +1942,7 @@ AVInputFormat ff_avi_demuxer = {
     .long_name = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
     .priv_data_size = sizeof(AVIContext),
     .extensions = "avi",
+ .flags = AVFMT_SEEK_NOSTREAMS,
     .read_probe = avi_probe,
     .read_header = avi_read_header,
     .read_packet = avi_read_packet,

diff relative to ffmpeg's git, after applying CinGG patch adding this flag.
Andrew-R

Andrew-R

2019-11-08 04:45

reporter   ~0002440

ah, looking at patches:
https://git.cinelerra-gg.org/git/?p=goodguy/cinelerra.git;a=blob;f=cinelerra-5.1/thirdparty/src/ffmpeg-4.2.patch3;h=cd2843884679a287aab2f8e83db7a8d6ed7a24f0;hb=HEAD

may be AVI demuxer also should be marked as (locally introduced) AVFMT_SEEK_NOSTREAMS ? Will try this ....
Andrew-R

Andrew-R

2019-10-31 00:41

reporter   ~0002366

@PhyllisSmith

yes, this workaround with opts file works .....
Andrew-R

Andrew-R

2019-10-30 23:47

reporter   ~0002364

Ok, about to try ..

i think this time_base thing has AVRational type not just because..

1001/30000 (numerator/denumerator) was supposed to represent 29.97 fps .....
so 1/25 can be expanded to 1000/25000, say ..... probably opts file should use this notation?

https://www.ffmpeg.org/doxygen/3.0/structAVRational.html
PhyllisSmith

PhyllisSmith

2019-10-30 23:26

manager   ~0002363

@Andrew
Commentary from GG on some statements ending in a ? (question mark) and a patch that you can try if you want.

Note 2347: "but there is no way to detect this mismatch programmatically?" ---- there is always a way!
"May be old (commented out) code can be used in such cases, or user asked what kind of timestamp stream s/he want?" --- the attached patch allows for designating which time_base to use.
Note 2354: "So, this workaround must be restricted to dv type 1 files with odml ? .. Searching if ffmpeg has any way to detect this .... If not - yeah, may be use pref will do?" --- the patch provides a way to designate a preference.
Note: 2358: "so, sometimes timestamps can be 0 or negative?" --- Yes, that is true. There are Device (dts) and Presentation time stamps (pts) but no one uses device time stamps any more.
Note: 2359: "Cool, eh?" --- Yes! impressive coding. Would not use frame rate on audio streams normally.
Note: 2360: "Because time_base from both codec and stream seems to be valid" --- they are not the same AND if they are supposed to the the same, then ffmpeg should set them that way and it would always be the right answer. 30000 is not useful for anything...

Add the patch, rebuild, create an opts file that matches the name of the avi file; for example for your LD_160909_2.avi file in the exact same directory, create a file called LD_160909_2.opts. Its only contents is the line: force_timebase=0
and "bam" now the audio works.

andrew.patch (1,612 bytes)
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 70098ca..9fab08f 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -681,7 +681,10 @@ 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;
 	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;
@@ -1576,6 +1579,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 +2275,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);
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h
index 9e17d8b..dc6c95d 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.h
+++ b/cinelerra-5.1/cinelerra/ffmpeg.h
@@ -378,6 +378,7 @@ public:
 
 	int decoding, encoding;
 	int has_audio, has_video;
+	int force_timebase;
 
 	FFMPEG(FileBase *file_base=0);
 	~FFMPEG();
andrew.patch (1,612 bytes)
PhyllisSmith

PhyllisSmith

2019-10-30 19:34

manager   ~0002361

@Andrew:
Yes, I will leave open. I have gathered all of the Notes from above and gg is going to review them this afternoon. We are trying to keep up with you and can not do so!!
Andrew-R

Andrew-R

2019-10-30 03:13

reporter   ~0002360

IDEA!

Because time_base from both codec and stream seems to be valid at least when probing from very start - just use this for avi (it has just one stream header anyway, and while codec params may vary midstream [1] - not sure how software is supposed to deal with THIS) and not reprobe on seek ....

Thing is, from behind libavformat i have no idea how to check specifics of avi container .....

I understand this issue is NOT about to be resolved in just one day before monthly builds starts - but can you not close it for another month, Phyllis? I wish to investigate a bit more and will leave notes here ....

[1] https://forum.videohelp.com/threads/392187-Different-audio-sampling-rate-in-single-capture-file
Andrew-R

Andrew-R

2019-10-29 16:56

reporter   ~0002359

so, more debug!

after such mod:
int FFStream::seek(int64_t no, double rate)
{
// default ffmpeg native seek
 int npkts = 1;
 int64_t pos = no, pkt_pos = -1;
 IndexMarks *index_markers = get_markers();
 if( index_markers && index_markers->size() > 1 ) {
  IndexMarks &marks = *index_markers;
  int i = marks.find(pos);
  int64_t n = i < 0 ? (i=0) : marks[i].no;
// if indexed seek point not too far away (<30 secs), use index
  if( no-n < 30*rate ) {
   if( n < 0 ) n = 0;
   pos = n;
   if( i < marks.size() ) pkt_pos = marks[i].pos;
   npkts = MAX_RETRY;
  }
 }
 if( pos == curr_pos ) return 0;
 double secs = pos < 0 ? 0. : pos / rate;
 AVRational time_base = st->time_base;
 AVRational time_base2 = av_inv_q(avctx->framerate);
 fprintf(stderr, "Timebase from stream: %i,%i \n", time_base.num, time_base.den);
 fprintf(stderr, "Timebase from codec: %i,%i \n", time_base2.num, time_base2.den);
 int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
 int64_t tstmp2 = av_rescale_q(tstmp, time_base, AV_TIME_BASE_Q);
 if (time_base.den != time_base2.den) {
 //fprintf (stderr, "timebases for stream and code differ!\n");
 //fprintf (stderr, "Timestamps tstmp, tstmp2: %jd,%jd \n", tstmp, tstmp2);
 //fprintf (stderr, "using default 25 fps ones!\n");
 //tstmp = secs * 25;
 }

I see this output:

LANG=ru_RU.utf8 /dev/shm/tmp/cinelerra-goodguy-20191029/cinelerra-5.1/bin/cin
Cinelerra Infinity - built: Oct 29 2019 11:57:50
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 codec: 1,0
Timebase from stream: 1,25
Timebase from codec: 1,0
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 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 codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
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 codec: 1,25
Timebase from stream: 1,25
Timebase from codec: 1,25
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,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Timebase from stream: 1,30000
Timebase from codec: 1,0
Session time: 0:00:47
Cpu time: user: 0:00:05.002 sys: 0:00:01.634

Cool, eh?
Andrew-R

Andrew-R

2019-10-29 16:11

reporter   ~0002358

so ..there is stream time_base and codec time_base .....

after i modified ffmpeg.C like this ....

int FFStream::seek(int64_t no, double rate)
{
// default ffmpeg native seek
 int npkts = 1;
 int64_t pos = no, pkt_pos = -1;
 IndexMarks *index_markers = get_markers();
 if( index_markers && index_markers->size() > 1 ) {
  IndexMarks &marks = *index_markers;
  int i = marks.find(pos);
  int64_t n = i < 0 ? (i=0) : marks[i].no;
// if indexed seek point not too far away (<30 secs), use index
  if( no-n < 30*rate ) {
   if( n < 0 ) n = 0;
   pos = n;
   if( i < marks.size() ) pkt_pos = marks[i].pos;
   npkts = MAX_RETRY;
  }
 }
 if( pos == curr_pos ) return 0;
 double secs = pos < 0 ? 0. : pos / rate;
 // AVRational time_base = st->time_base;
 AVRational time_base = av_inv_q(avctx->framerate);
 fprintf(stderr, "Timebase: %i,%i \n", time_base.num, time_base.den);
 int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
 int64_t tstmp2 = av_rescale_q(tstmp, time_base, AV_TIME_BASE_Q);
 // if (tstmp != tstmp2) {
 //fprintf (stderr, "native seek timestamps and default timebase timestamps differ!\n");
 fprintf (stderr, "Timestamps tstmp, tstmp2: %jd,%jd \n", tstmp, tstmp2);
 //fprintf (stderr, "using default 25 fps ones!\n");
 //tstmp = secs * 25;
 //}
 if( !tstmp ) {
  if( st->nb_index_entries > 0 ) tstmp = st->index_entries[0].timestamp;
  else if( st->start_time != AV_NOPTS_VALUE ) tstmp = st->start_time;
  else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts;
  else tstmp = INT64_MIN+1;
 }
 else if( nudge != AV_NOPTS_VALUE ) tstmp += nudge;
 int idx = st->index;
[...]

It printed such info:


 LANG=ru_RU.utf8 /dev/shm/tmp/cinelerra-goodguy-20191029/cinelerra-5.1/bin/cin
Cinelerra Infinity - built: Oct 29 2019 11:57:50
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: 1,25
Timestamps tstmp, tstmp2: 1361,54440000
Timebase: 1,25
Timestamps tstmp, tstmp2: 1360,54400000
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: 1,25
Timestamps tstmp, tstmp2: 2726,109040000
Timebase: 1,25
Timestamps tstmp, tstmp2: 2726,109040000
Timebase: 1,25
Timestamps tstmp, tstmp2: 4092,163680000
Timebase: 1,25
Timestamps tstmp, tstmp2: 4092,163680000
Timebase: 1,25
Timestamps tstmp, tstmp2: 5457,218280000
Timebase: 1,25
Timestamps tstmp, tstmp2: 5457,218280000
Timebase: 1,25
Timestamps tstmp, tstmp2: 6823,272920000
Timebase: 1,25
Timestamps tstmp, tstmp2: 6821,272840000
Timebase: 1,25
Timestamps tstmp, tstmp2: 8189,327560000
Timebase: 1,25
Timestamps tstmp, tstmp2: 8187,327480000
Timebase: 1,25
Timestamps tstmp, tstmp2: 9554,382160000
Timebase: 1,25
Timestamps tstmp, tstmp2: 9553,382120000
Timebase: 1,25
Timestamps tstmp, tstmp2: 10918,436720000
Timebase: 1,25
Timestamps tstmp, tstmp2: 10918,436720000
Timebase: 1,25
Timestamps tstmp, tstmp2: 12284,491360000
Timebase: 1,25
Timestamps tstmp, tstmp2: 12284,491360000
Timebase: 1,25
Timestamps tstmp, tstmp2: 13650,546000000
Timebase: 1,25
Timestamps tstmp, tstmp2: 13649,545960000
Timebase: 1,25
Timestamps tstmp, tstmp2: 15015,600600000
Timebase: 1,25
Timestamps tstmp, tstmp2: 15013,600520000
Timebase: 1,25
Timestamps tstmp, tstmp2: 16381,655240000
Timebase: 1,25
Timestamps tstmp, tstmp2: 16380,655200000
Timebase: 1,25
Timestamps tstmp, tstmp2: 0,0
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Timebase: 1,25
Timestamps tstmp, tstmp2: 4553,182120000
Timebase: 1,25
Timestamps tstmp, tstmp2: 4553,182120000
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 16 09 2009/LD_160909_2.avi
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 9673,386920000
Timebase: 1,25
Timestamps tstmp, tstmp2: 9673,386920000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 11857,474280000
Timebase: 1,25
Timestamps tstmp, tstmp2: 11856,474240000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 3717,148680000
Timebase: 1,25
Timestamps tstmp, tstmp2: 3717,148680000
Timebase: 1,25
Timestamps tstmp, tstmp2: 3564,142560000
Timebase: 1,25
Timestamps tstmp, tstmp2: 3563,142520000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 2010,80400000
Timebase: 1,25
Timestamps tstmp, tstmp2: 2010,80400000
Timebase: 1,25
Timestamps tstmp, tstmp2: 3678,147120000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 3678,147120000
Timebase: 1,25
Timestamps tstmp, tstmp2: 15784,631360000
Timebase: 1,25
Timestamps tstmp, tstmp2: 15783,631320000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 3764,150560000
Timebase: 1,25
Timestamps tstmp, tstmp2: 3764,150560000
Timebase: 1,25
Timestamps tstmp, tstmp2: 14537,581480000
Timebase: 1,25
Timestamps tstmp, tstmp2: 14537,581480000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
AudioALSA::write_buffer err -32(Обрыв канала) at sample 180224
AudioALSA::write_buffer err -32(Обрыв канала) at sample 196608
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
Timebase: 1,25
Timestamps tstmp, tstmp2: 10918,436720000
Timebase: 1,25
Timestamps tstmp, tstmp2: 10918,436720000
Timebase: 1,25
Timestamps tstmp, tstmp2: 21841,873640000
Timebase: 1,25
Timestamps tstmp, tstmp2: 21840,873600000
Timebase: 1,25
Timestamps tstmp, tstmp2: 32764,1310560000
Timebase: 1,25
Timestamps tstmp, tstmp2: 32763,1310520000
Timebase: 1,25
Timestamps tstmp, tstmp2: 43687,1747480000
Timebase: 1,25
Timestamps tstmp, tstmp2: 43686,1747440000
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
Timebase: 1,25
Timestamps tstmp, tstmp2: 54610,2184400000
Timebase: 1,25
Timestamps tstmp, tstmp2: 54609,2184360000
Timebase: 1,25
Timestamps tstmp, tstmp2: 65533,2621320000
Timebase: 1,25
Timestamps tstmp, tstmp2: 65532,2621280000
Timebase: 1,25
Timestamps tstmp, tstmp2: 76454,3058160000
Timebase: 1,25
Timestamps tstmp, tstmp2: 76453,3058120000
Timebase: 1,25
Timestamps tstmp, tstmp2: 87377,3495080000
Timebase: 1,25
Timestamps tstmp, tstmp2: 87376,3495040000
Timebase: 1,25
Timestamps tstmp, tstmp2: 0,0
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
Timebase: 1,25
Timestamps tstmp, tstmp2: 0,0
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
Device type none is not supported.
Available device types: vdpau cuda vaapi opencl
Timebase: 1,25
Timestamps tstmp, tstmp2: 84921,3396840000
Timebase: 1,25
Timestamps tstmp, tstmp2: 84920,3396800000
FFMPEG::open_decoder: some stream times estimated: /home/guest/botva/Downloads/from_Vladimir/Leningrad dolphinarium 04 10 2010/UD_04102010_16_00.avi
Timebase: 1,0
Timestamps tstmp, tstmp2: 0,-9223372036854775808
AudioALSA::write_buffer err -32(Обрыв канала) at sample 114688
AudioALSA::write_buffer err -32(Обрыв канала) at sample 131072
AudioALSA::write_buffer err -32(Обрыв канала) at sample 147456
AudioALSA::write_buffer err -32(Обрыв канала) at sample 163840
AudioALSA::write_buffer err -32(Обрыв канала) at sample 180224
AudioALSA::write_buffer err -32(Обрыв канала) at sample 196608
AudioALSA::write_buffer err -32(Обрыв канала) at sample 212992
AudioALSA::write_buffer err -32(Обрыв канала) at sample 229376
AudioALSA::write_buffer err -32(Обрыв канала) at sample 245760
AudioALSA::write_buffer err -32(Обрыв канала) at sample 262144
AudioALSA::write_buffer err -32(Обрыв канала) at sample 278528
AudioALSA::write_buffer err -32(Обрыв канала) at sample 294912
AudioALSA::write_buffer err -32(Обрыв канала) at sample 311296
AudioALSA::write_buffer err -32(Обрыв канала) at sample 327680
AudioALSA::write_buffer err -32(Обрыв канала) at sample 344064
AudioALSA::write_buffer err -32(Обрыв канала) at sample 360448
AudioALSA::write_buffer err -32(Обрыв канала) at sample 376832
AudioALSA::write_buffer err -32(Обрыв канала) at sample 393216
AudioALSA::write_buffer err -32(Обрыв канала) at sample 409600
AudioALSA::write_buffer err -32(Обрыв канала) at sample 425984
AudioALSA::write_buffer err -32(Обрыв канала) at sample 442368
AudioALSA::write_buffer err -32(Обрыв канала) at sample 458752
AudioALSA::write_buffer err -32(Обрыв канала) at sample 475136
AudioALSA::write_buffer err -32(Обрыв канала) at sample 491520
AudioALSA::write_buffer err -32(Обрыв канала) at sample 507904
AudioALSA::write_buffer err -32(Обрыв канала) at sample 524288
AudioALSA::write_buffer err -32(Обрыв канала) at sample 540672
AudioALSA::write_buffer err -32(Обрыв канала) at sample 557056
AudioALSA::write_buffer err -32(Обрыв канала) at sample 573440
AudioALSA::write_buffer err -32(Обрыв канала) at sample 589824
AudioALSA::write_buffer err -32(Обрыв канала) at sample 606208
AudioALSA::write_buffer err -32(Обрыв канала) at sample 622592
AudioALSA::write_buffer err -32(Обрыв канала) at sample 638976
AudioALSA::write_buffer err -32(Обрыв канала) at sample 655360
AudioALSA::write_buffer err -32(Обрыв канала) at sample 671744
AudioALSA::write_buffer err -32(Обрыв канала) at sample 688128
AudioALSA::write_buffer err -32(Обрыв канала) at sample 704512
AudioALSA::write_buffer err -32(Обрыв канала) at sample 720896
AudioALSA::write_buffer err -32(Обрыв канала) at sample 737280
AudioALSA::write_buffer err -32(Обрыв канала) at sample 753664
AudioALSA::write_buffer err -32(Обрыв канала) at sample 770048
AudioALSA::write_buffer err -32(Обрыв канала) at sample 786432
AudioALSA::write_buffer err -32(Обрыв канала) at sample 802816
AudioALSA::write_buffer err -32(Обрыв канала) at sample 819200
AudioALSA::write_buffer err -32(Обрыв канала) at sample 835584
AudioALSA::write_buffer err -32(Обрыв канала) at sample 851968
AudioALSA::write_buffer err -32(Обрыв канала) at sample 868352
AudioALSA::write_buffer err -32(Обрыв канала) at sample 884736
AudioALSA::write_buffer err -32(Обрыв канала) at sample 901120
AudioALSA::write_buffer err -32(Обрыв канала) at sample 917504
AudioALSA::write_buffer err -32(Обрыв канала) at sample 933888
AudioALSA::write_buffer err -32(Обрыв канала) at sample 950272
AudioALSA::write_buffer err -32(Обрыв канала) at sample 966656
AudioALSA::write_buffer err -32(Обрыв канала) at sample 983040
AudioALSA::write_buffer err -32(Обрыв канала) at sample 999424
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1015808
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1032192
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1048576
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1064960
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1081344
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1097728
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1114112
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1130496
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1146880
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1163264
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1179648
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1196032
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1212416
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1228800
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1245184
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1261568
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1277952
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1294336
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1310720
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1327104
AudioALSA::write_buffer err -32(Обрыв канала) at sample 1343488

still trying to seek in 13 Gb file on hdd :}
                                                                                                                
so, sometimes timestamps can be 0 or negative?
Andrew-R

Andrew-R

2019-10-29 15:35

reporter   ~0002357

https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2014-October/082198.html

[FFmpeg-cvslog] lavc: deprecate the use of AVCodecContext.time_base for decoding

lavc: deprecate the use of AVCodecContext.time_base for decoding

When decoding, this field holds the inverse of the framerate that can be
written in the headers for some codecs. Using a field called 'time_base'
for this is very misleading, as there are no timestamps associated with
it. Furthermore, this field is used for a very different purpose during
encoding.

Add a new field, called 'framerate', to replace the use of time_base for
decoding.

something to try too .....
Andrew-R

Andrew-R

2019-10-29 13:07

reporter   ~0002355

Hm, looking at kino-1.3.4/src/avi.cc

void AVI2File::Init( int format, int sampleFrequency, int indexType )

case AVI_PAL:
                mainHdr.dwStreams = 2;
                mainHdr.dwWidth = 720;
                mainHdr.dwHeight = 576;

                /* Initialize the 'strh' chunk */

                streamHdr[ 0 ].fccType = make_fourcc( "vids" );
                streamHdr[ 0 ].fccHandler = make_fourcc( "dvsd" );
                streamHdr[ 0 ].dwFlags = 0;
                streamHdr[ 0 ].wPriority = 0;
                streamHdr[ 0 ].wLanguage = 0;
                streamHdr[ 0 ].dwInitialFrames = 0;
                streamHdr[ 0 ].dwScale = 1;
                streamHdr[ 0 ].dwRate = 25;
                streamHdr[ 0 ].dwStart = 0;
                streamHdr[ 0 ].dwLength = 0;
                streamHdr[ 0 ].dwSuggestedBufferSize = 144008;
                streamHdr[ 0 ].dwQuality = -1;
                streamHdr[ 0 ].dwSampleSize = 0;
                streamHdr[ 0 ].rcFrame.top = 0;
                streamHdr[ 0 ].rcFrame.bottom = 0;
                streamHdr[ 0 ].rcFrame.left = 0;
                streamHdr[ 0 ].rcFrame.right = 0;

and slightly below ....

case AVI_NTSC:
                mainHdr.dwTotalFrames = 0;
                mainHdr.dwStreams = 2;
                mainHdr.dwWidth = 720;
                mainHdr.dwHeight = 480;

                /* Initialize the 'strh' chunk */

                streamHdr[ 0 ].fccType = make_fourcc( "vids" );
                streamHdr[ 0 ].fccHandler = make_fourcc( "dvsd" );
                streamHdr[ 0 ].dwFlags = 0;
                streamHdr[ 0 ].wPriority = 0;
                streamHdr[ 0 ].wLanguage = 0;
                streamHdr[ 0 ].dwInitialFrames = 0;
                streamHdr[ 0 ].dwScale = 1001;
                streamHdr[ 0 ].dwRate = 30000;
                streamHdr[ 0 ].dwStart = 0;
                streamHdr[ 0 ].dwLength = 0;
                streamHdr[ 0 ].dwSuggestedBufferSize = 120008;
                streamHdr[ 0 ].dwQuality = -1;
                streamHdr[ 0 ].dwSampleSize = 0;
                streamHdr[ 0 ].rcFrame.top = 0;
                streamHdr[ 0 ].rcFrame.bottom = 0;
                streamHdr[ 0 ].rcFrame.left = 0;
                streamHdr[ 0 ].rcFrame.right = 0;

so, it was ntsc vs pal problem? Will look at time when dv type 1 decoding was added to libavformat .......
Andrew-R

Andrew-R

2019-10-29 12:11

reporter   ~0002354

No, this is not very good workaround, because it breaks another (type 2) avi dv file :} (or more accurately seek times become very big - it read whole 10+ Gb of data from relative slow (34 Mb/s for this file, according to gkrellm) hdd, until required timestamp (?) for audio finally found (video slowly inches forward frame by frame during this process) ....

So, this workaround must be restricted to dv type 1 files with odml ? .. Searching if ffmpeg has any way to detect this .... If not - yeah, may be use pref will do?
Andrew-R

Andrew-R

2019-10-29 11:29

reporter   ~0002353

so, this patch 'fixed' sample seeking for me:

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 70098ca..380d986 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -683,6 +683,13 @@ int FFStream::seek(int64_t no, double rate)
        double secs = pos < 0 ? 0. : pos / rate;
        AVRational time_base = st->time_base;
        int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
+ int64_t tstmp2 = av_rescale_q(tstmp, time_base, AV_TIME_BASE_Q);
+ if (tstmp != tstmp2) {
+ fprintf (stderr, "native seek timestamps and default timebase timestamps differ!\n");
+ fprintf (stderr, "Timestamps tstmp, tstmp2: %jd,%jd \n", tstmp, tstmp2);
+ fprintf (stderr, "using default 25 fps ones!\n");
+ tstmp = secs * 25;
+ }
        if( !tstmp ) {
                if( st->nb_index_entries > 0 ) tstmp = st->index_entries[0].timestamp;
                else if( st->start_time != AV_NOPTS_VALUE ) tstmp = st->start_time;


need to recheck other DV files ...
Andrew-R

Andrew-R

2019-10-29 10:26

reporter   ~0002352

sigh ... (and my main comment, as opposed to testing comment below, was lost)

"avi: DV in AVI must be considered single stream" - commit msg from 2013 in ffmpeg/libavformat

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/756547ce7f4d67a18663503e2157aebed3531703

from cinelerra-5.1/thirdparty/ffmpeg-4.2/libavformat/avidec.c


static const AVOption options[] = {
    { "use_odml", "use odml index", offsetof(AVIContext, use_odml), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
    { NULL },
};

may be this demuxer can be recalled with this option set/iunset, if we have seek failures?
Andrew-R

Andrew-R

2019-10-29 10:20

reporter   ~0002351

Hm I was looking at avi demux code in ffmpeg ...
PhyllisSmith

PhyllisSmith

2019-10-29 01:31

manager   ~0002350

The way that GG tracked down the problem and got it working in CinGG without making a copy first for only this type of file is quoted here as he wrote it down for me and I was able to make it work.

"I was actually using cin5 via gdb using this method, but it is really just to demonstrate the problem and is not a very good idea.
1. start a debuggable cinelerra under gdb and load your file
2. add a breakpoint at ffmpeg.C:686
3. add a command to the breakpoint via:
command 1
p tstmp = secs * 25.
c
end
4. turn off gdb pagination via:
set pa off
5. continue program via:
c
6. this will trip the breakpoint for any seek, and use the 25fps time_base of the video stream for the audio, which seems to work for this media. apparently the specified time_base is 1/30000 (?) and the sample rate is 1/48000. The actual pts data in the framesmust actually match the video time_base, so always using 1/25 seems to work.

This is very kludgy, but effective for a once in a while fix."

I will see if I can convince GG to create a temporary patch.
Andrew-R

Andrew-R

2019-10-28 22:06

reporter   ~0002347

But there is no way to detect this mismatch programmatically?

From man ffmpeg:

   -copytb mode
           Specify how to set the encoder timebase when stream copying. mode is an integer numeric value, and can assume one of the following values:
           1 Use the demuxer timebase.
               The time base is copied to the output encoder from the corresponding input demuxer. This is sometimes required to avoid non monotonically increasing timestamps when
               copying video streams with variable frame rate.
           0 Use the decoder timebase.
               The time base is copied to the output encoder from the corresponding input decoder.
           -1 Try to make the choice automatically, in order to generate a sane output.

           Default value is -1.
......

May be old (commented out) code can be used in such cases, or user asked what kind of timestamp stream s/he want?

I can try to hack something, if you/GG leave a bit more hints/comments as where this info saved in ffmpeg structs and where Cin uses/extracts it ....
PhyllisSmith

PhyllisSmith

2019-10-28 21:41

manager   ~0002346

There is no fix that will fix this media in Cinelerra without breaking something else. In debugging, gg found that the audio sample rate is supposedly 48000. But the "stream seek" that CinGG uses, shows as 30000 for a seek. The reason it probably works in ffplay is because its seeks but it is not a stream seek so found some other good value. The media actually has the wrong timestamp data.

A really fast workaround to get media that is correct for CinGG, just make a copy using the following (substituting your directory for /tmp):

    ffmpeg -i /tmp/LD_160909_2.avi -acodec copy -vcodec copy -copytb -1 /tmp/x.avi

This will be closed in a day or 2 since there is no fix.
PhyllisSmith

PhyllisSmith

2019-10-28 00:17

manager   ~0002345

As confirmed by Pierre, I too confirmed problem. I will have GG look at this if he ever gets off of the ladder set up by the speakers hooked to an oscilloscope looking for a solution to BT326.
Andrew-R

Andrew-R

2019-10-25 16:17

reporter   ~0002324

Pierre found workaround:
from email to CinGG list
---------
Here I solved the problem....

I thought it might be corruption at the beginning or end of the clip. So
I used the "VidCutter" software (https://github.com/ozmartian/vidcutter)
which allows me to cut sections of media files without re-encoding.

I cut first and last frames using the function that identifies the
precise points between frames. I saved the resulting DV sequence
(shortened by 2 frames) and loaded it into CinGG which now uses it
without any more problems...
-------------

I tried to load this file into Avidemux 2.5.6 and it failed to load it too ..... mplayer -demuxer avi fails to find video (but with -demuxer lavf it plays and seeks). Probably index part of file broken or non-standard?
Andrew-R

Andrew-R

2019-10-25 16:13

reporter   ~0002323

xz compressed output of ffprobe -loglevel trace

ffprobe_trace-avi-dv-type-1.log.xz (55,176 bytes)

Issue History

Date Modified Username Field Change
2019-10-25 15:33 Andrew-R New Issue
2019-10-25 15:33 Andrew-R Tag Attached: DV
2019-10-25 16:13 Andrew-R File Added: ffprobe_trace-avi-dv-type-1.log.xz
2019-10-25 16:13 Andrew-R Note Added: 0002323
2019-10-25 16:17 Andrew-R Note Added: 0002324
2019-10-28 00:17 PhyllisSmith Assigned To => PhyllisSmith
2019-10-28 00:17 PhyllisSmith Status new => confirmed
2019-10-28 00:17 PhyllisSmith Note Added: 0002345
2019-10-28 21:09 PhyllisSmith Assigned To PhyllisSmith => goodguy
2019-10-28 21:41 PhyllisSmith Note Added: 0002346
2019-10-28 22:06 Andrew-R Note Added: 0002347
2019-10-29 01:31 PhyllisSmith Note Added: 0002350
2019-10-29 10:20 Andrew-R Note Added: 0002351
2019-10-29 10:26 Andrew-R Note Added: 0002352
2019-10-29 11:29 Andrew-R Note Added: 0002353
2019-10-29 12:11 Andrew-R Note Added: 0002354
2019-10-29 13:07 Andrew-R Note Added: 0002355
2019-10-29 15:35 Andrew-R Note Added: 0002357
2019-10-29 16:11 Andrew-R Note Added: 0002358
2019-10-29 16:56 Andrew-R Note Added: 0002359
2019-10-30 03:13 Andrew-R Note Added: 0002360
2019-10-30 19:34 PhyllisSmith Note Added: 0002361
2019-10-30 23:26 PhyllisSmith File Added: andrew.patch
2019-10-30 23:26 PhyllisSmith Note Added: 0002363
2019-10-30 23:47 Andrew-R Note Added: 0002364
2019-10-31 00:41 Andrew-R Note Added: 0002366
2019-11-08 04:45 Andrew-R Note Added: 0002440
2019-11-08 15:04 Andrew-R Note Added: 0002444
2019-11-14 14:50 Andrew-R File Added: avi_fix.patch
2019-11-14 14:50 Andrew-R Note Added: 0002460
2020-01-01 00:25 PhyllisSmith Status confirmed => closed
2020-01-01 00:25 PhyllisSmith Resolution open => fixed
2020-01-01 00:25 PhyllisSmith Fixed in Version => 2019-11
2020-01-01 00:25 PhyllisSmith Note Added: 0002623