Bug #2374
closed2nd pass: error reading index
Description
This is the error I'm getting when using markad: crashes at the beginning of the second pass.
To help in debugging, I've uploaded the movie to http://www.kdvelectronics.eu/vdr-record.tar.bz2
Script started on Fri 08 Apr 2016 09:56:04 AM CEST
$ ~/src/vdr-2.2.0/PLUGINS/src/markad/command/markad K- ./EL_PELICULĂ“N#3A_UN_GOLPE_BRILLANTE/2016-03-19.22.08
markad: Fri Apr 8 09:56:42 [3938] starting v0.1.5pre (74e2a8c) (64bit)
markad: Fri Apr 8 09:56:42 [3938] on /home/koen/Downloads/EL_PELICULĂ“N#3A_UN_GOLPE_BRILLANTE/2016-03-19.22.08.3-0.rec
markad: Fri Apr 8 09:56:42 [3938] broadcast aspectratio 16:9 (from info)
markad: Fri Apr 8 09:56:42 [3938] getting broadcast start from info mtime
markad: Fri Apr 8 09:56:42 [3938] no logo found, logo detection disabled
markad: Fri Apr 8 09:56:42 [3938] marks can/will be weak!
markad: Fri Apr 8 09:56:42 [3938] pre-timer 1m
markad: Fri Apr 8 09:56:42 [3938] broadcast length 95m
markad: Fri Apr 8 09:56:42 [3938] found H262-video (0x00c9)
markad: Fri Apr 8 09:56:42 [3938] using libavcodec.so.53.35.0 with 1 threads
markad: Fri Apr 8 09:56:42 [3938] using codec MPEG-2 video
markad: Fri Apr 8 09:56:42 [3938] channel antena3
markad: Fri Apr 8 09:56:42 [3938] SDTV 704x576i25
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
markad: Fri Apr 8 09:56:42 [3938] error decoding video
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video 0x199fe40] mpeg_decode_postinit() failure
0x199fe40] mpeg_decode_postinit() failure
[mpeg2video
[mpeg2video @ 0x199fe40] mpeg_decode_postinit() failure
markad: Fri Apr 8 09:56:43 [3938] aspectratio of 16:9 detected
markad: Fri Apr 8 09:56:43 [3938] assuming start (2151)
markad: Fri Apr 8 09:56:43 [3938] detected start of horiz. borders (0)*
markad: Fri Apr 8 09:56:46 [3938] detected stop of horiz. borders (21759)
markad: Fri Apr 8 09:56:50 [3938] detected start of horiz. borders (39036)*
markad: Fri Apr 8 09:56:53 [3938] detected stop of horiz. borders (57633)
markad: Fri Apr 8 09:56:54 [3938] detected start of horiz. borders (57771)*
markad: Fri Apr 8 09:57:03 [3938] detected stop of horiz. borders (117477)
markad: Fri Apr 8 09:57:08 [3938] detected start of horiz. borders (138117)*
markad: Fri Apr 8 09:57:09 [3938] assuming stop (147171)
markad: Fri Apr 8 09:57:09 [3938] 2nd pass
markad: Fri Apr 8 09:57:09 [3938] error reading index
markad: Fri Apr 8 09:57:09 [3938] processed time 27.54s, 153691/0 frames, 5579.8 fps, 223.2 pps
$ exit
Script done on Fri 08 Apr 2016 09:57:14 AM CEST
Thanks for writing markad (and previously, noad).
Updated by Markus over 8 years ago
koen wrote:
This is the error I'm getting when using markad: crashes at the beginning of the second pass.
Since I got hit by the same issue recently, I started digging and ended up here: source:command/markad-standalone.cpp@74e2a8c5#L967
It seems that the second pass tries to read the index of frame (start mark - 120s). Now, if the first mark determined by the first pass is before minute 2 of the input, the frame number passed to ReadIndex
is negative, which leads to a negative file position for seeking in the index file inside this function. And this obviously fails. So I guess there should be something like max(0,p1->position-frange)
here?
Updated by koen over 8 years ago
Markus wrote:
Now, if the first mark determined by the first pass is before minute 2 of the input, the frame number passed to
ReadIndex
is negative, which leads to a negative file position for seeking in the index file inside this function. And this obviously fails. So I guess there should be something likemax(0,p1->position-frange)
here?
Thanks. I've tried the following patch, and can say this solves the problem (for me). Maybe add this to the repository?
*** markad-standalone.cpp.ORIG 2016-06-03 08:53:36.336058106 +0200 --- markad-standalone.cpp 2016-06-03 09:47:11.775755903 +0200 *************** *** 965,972 **** off_t offset; int number,frame,iframes; int frange=macontext.Video.Info.FramesPerSecond*120; // 40s + 80s ! if (marks.ReadIndex(directory,isTS,p1->position-frange,frange,&number,&offset,&frame,&iframes)) { if (!ProcessFile2ndPass(&p1,NULL,number,offset,frame,iframes)) break; --- 965,974 ---- off_t offset; int number,frame,iframes; int frange=macontext.Video.Info.FramesPerSecond*120; // 40s + 80s + int frange_begin=p1->position-frange; // 120 seconds before first mark + if (frange_begin<0) frange_begin=0; // but not before beginning of broadcast ! if (marks.ReadIndex(directory,isTS,frange_begin,frange,&number,&offset,&frame,&iframes)) { if (!ProcessFile2ndPass(&p1,NULL,number,offset,frame,iframes)) break;
Updated by Markus over 8 years ago
koen wrote:
Thanks. I've tried the following patch, and can say this solves the problem (for me). Maybe add this to the repository?
[...]
Would make sense, yes. But we have to rely on Joe_D to take a look and commit the change. He can probably also shed some light on what the two comments in lines 967 and 973 are supposed to tell us. If the intention is to start 40s/160s before the mark and end 80s/160s after the mark, the numbers currently passed to ReadIndex
are wrong -- at least according to my current understanding of the code. But I may have overlooked something...
Updated by Joe_D about 8 years ago
- Status changed from New to Closed
- Assignee set to Joe_D
- % Done changed from 0 to 100
In FramesPerSeconds there is the number of frame per second (e.g. 25 or 50 with SDTV)
With macontext.Video.Info.FramesPerSecond*120 i calculate the frames to get 2 minutes back (3000 or 6000 frames).
Thanks for the patch, i added it to the git!