diff --git a/common/config/config.json.template b/common/config/config.json.template index 458c4665..9eae992f 100644 --- a/common/config/config.json.template +++ b/common/config/config.json.template @@ -55,6 +55,7 @@ "humanReadable" : false, "keyFrameSearchOffsetMs" : 1, "discontinuityMode" : true, - "segmentDuration" : 10000 + "segmentDuration" : 10000, + "enablePlaylistHistory": false } } \ No newline at end of file diff --git a/packager/bin/monitor_packager.sh b/packager/bin/monitor_packager.sh index e85744bf..b4398b1b 100644 --- a/packager/bin/monitor_packager.sh +++ b/packager/bin/monitor_packager.sh @@ -119,12 +119,16 @@ function lookupTSFile { # result: seg-1466803160985-12000-146680317-f1-v1.ts -> seg 1466803160985 12000 146680317 f1 v1.ts # take 3 last tokens local n=${#items[@]} + [[ "$1" =~ "-a1" ]] && audio=1 || audio=0 + [[ "$audio" -eq "1" ]] && pattern="(.*)-${items[$n-4]}-${items[$n-3]}-${items[$n-2]}-${items[$n-1]}" || pattern="(.*)-${items[$n-3]}-${items[$n-2]}-${items[$n-1]}" + found=`grep -iEo "$pattern" $outfile` - found=`grep -iEo "(.*)${items[$n-3]}-${items[$n-2]}-${items[$n-1]}" $outfile` # if debug info on chunk name is present then validate local retval=${#found} - if (( $retval > 0 && $n > 4 )) + [[ "$audio" -eq "1" ]] && fieldsCnt=5 || fieldsCnt=4 + if (( $retval > 0 && $n > $fieldsCnt )) then + #echo "n=$n found=$found" dbgInfoCmp "$1" "$found" fi #echo "found=$found" @@ -141,10 +145,13 @@ function analyzeChunk { #grep "$chunk" $outfile &> /dev/null && return +lookupTSFile $chunk warning=`lookupTSFile $chunk` retval=$? + #echo "analyzeChunk chunk=$chunk retval=$retval" + [ -n "$warning" ] && echo $warning >> $outfile [ "$retval" -eq "0" ] || return @@ -171,17 +178,21 @@ function analyzeChunk { [ "$media" = "v" ] && index=0 || index=1 - #echo -e "\ncount:\tdts:\n$partitionLine" >> $outfile - - line=`ffprobe "$urlPrefix/$chunk" -show_packets -select_streams $media | \ - awk 'BEGIN{ offset=length("dts_time=")+1; dur_offset=length("duration_time=")+1} \ - /duration_time=/ { duration_time=substr($0,dur_offset);} \ - /dts_time=/ { last=substr($0,offset); if(!first){first=last}} \ - END{ last+=duration_time; print first" "last" "(last-first)}'` - medias[index]="$media $line" + dts_pat="dts="; dts_duration_pat="duration_time=" + #dts_pat="dts_time="; dts_duration_pat="duration=" + #NB: 9090 is packager initial offset for dts + line=`ffprobe "$urlPrefix/$chunk" -show_packets -select_streams $media | \ + awk -v dtspat=$dts_pat -v dts_durationpat=$dts_duration_pat \ + 'BEGIN{ offset=length(dtspat)+1; dur_offset=length(dts_durationpat)+1} \ + $0 ~ dts_durationpat { duration_time=substr($0,dur_offset);} \ + $0 ~ dtspat { last=substr($0,offset); if(!first){first=last} } \ + END{ last=((last+8589934592)-9090)%8589934592; first=((first+8589934592)-9090)%8589934592; last+=duration_time; print first" "last" "(last-first)}'` + + medias[index]="$media $line" #>> $outfile # echo -e "$endLine" >> $outfile done; + if [ -n "${medias[0]}" ] then video=(${medias[0]}) @@ -204,8 +215,7 @@ function analyzeChunk { #there's no double processing in bash... [ `echo "$chunkStartEndTSDiff >= $threshold" | bc` = "1" ] || [ `echo "$chunkStartEndTSDiff >= $threshold" | bc` = "1" ] && warning="$warning bad alignment WARNING: $chunkStartEndTSDiff" - - echo "$chunkStartDTSDiff $chunkStartEndTSDiff `echo "${video[3]} - ${audio[3]}" | bc` errors: $warning" >> $outfile; + echo "diffs: $chunkStartDTSDiff $chunkStartEndTSDiff `echo "${video[3]} - ${audio[3]}" | bc` errors: $warning" >> $outfile; else echo "${video[1]} ${video[2]} ${video[3]} errors: $warning" >> $outfile; fi