유희평

initial commit

1 +Automatic video editing program
...\ No newline at end of file ...\ No newline at end of file
...@@ -445,8 +445,11 @@ class WindowClass(QMainWindow, Ui_MainWindow): # Ui_MainWindow를 받음 ...@@ -445,8 +445,11 @@ class WindowClass(QMainWindow, Ui_MainWindow): # Ui_MainWindow를 받음
445 self.horizontalSlider.setMaximum(self.endframe - self.stframe) 445 self.horizontalSlider.setMaximum(self.endframe - self.stframe)
446 self.horizontalSlider.setValue(self.stframe) 446 self.horizontalSlider.setValue(self.stframe)
447 self.isdata = False 447 self.isdata = False
448 +<<<<<<< HEAD
448 self.ax1.clear() 449 self.ax1.clear()
449 self.ax2.clear() 450 self.ax2.clear()
451 +=======
452 +>>>>>>> 34cff6b09a8d3e1117437cc9ed79eb6ae8313c1f
450 453
451 def updateFrame(self): 454 def updateFrame(self):
452 self.frameID += 1 455 self.frameID += 1
...@@ -495,6 +498,40 @@ class WindowClass(QMainWindow, Ui_MainWindow): # Ui_MainWindow를 받음 ...@@ -495,6 +498,40 @@ class WindowClass(QMainWindow, Ui_MainWindow): # Ui_MainWindow를 받음
495 self.statusbar.showMessage( 498 self.statusbar.showMessage(
496 "Time: " + str(tmin).zfill(2) + ":" + str(ttsec).zfill(2) + ":" + str(int(ksec * 100))) 499 "Time: " + str(tmin).zfill(2) + ":" + str(ttsec).zfill(2) + ":" + str(int(ksec * 100)))
497 self.sliderbusy2 = False 500 self.sliderbusy2 = False
501 +<<<<<<< HEAD
502 +=======
503 + """
504 + def lineSliderSet(self, cnt): #그래프상 수직선 위치 업데이트
505 + if cnt + 1 - self.stframe > self.horizontalSlider.maximum():
506 + return
507 +
508 + self.linebusy = True
509 + pdraw = self.drawmin
510 +
511 + self.drawmin -= 20
512 + if self.drawmin < 1:
513 + self.drawmin = 1
514 + while (cnt + 1) / self.fps > self.data.values[self.drawmin, 1]:
515 + self.drawmin += 1
516 + if not self.drawmin == pdraw or pdraw == 1:
517 + wr = ref(self.ax1.lines[5])
518 + self.ax1.lines.remove(wr())
519 + self.ui.bottomImage.canvas.draw()
520 + self.ax1.plot([self.data.values[self.drawmin, 1], self.data.values[self.drawmin, 1]], [0, 3.4], 'k',
521 + linewidth=2.0)
522 + self.ui.bottomImage.canvas.draw()
523 +
524 + tsec = cnt / self.fps
525 + tmin = int(tsec / 60)
526 + ttsec = int(tsec - 60 * tmin)
527 + ksec = tsec - 60 * tmin - ttsec
528 +
529 + self.ui.statusbar.showMessage(
530 + "Frame Time: " + str(tmin).zfill(2) + ":" + str(ttsec).zfill(2) + ":" + str(int(ksec * 100)))
531 +
532 + self.linebusy = False
533 + """
534 +>>>>>>> 34cff6b09a8d3e1117437cc9ed79eb6ae8313c1f
498 535
499 def horizontalSliderPressed(self): 536 def horizontalSliderPressed(self):
500 self.sliderbusy = True 537 self.sliderbusy = True
...@@ -752,7 +789,11 @@ class Clip: ...@@ -752,7 +789,11 @@ class Clip:
752 window_length = max_slice * sr #한 구간에 해당하는 샘플의 개수 789 window_length = max_slice * sr #한 구간에 해당하는 샘플의 개수
753 energy = np.array([sum(abs(x[i: i + window_length] ** 2)) #windwo_length구간 안에있는 모든 샘플들의 진폭의 제곱의 합->소리의 크기 790 energy = np.array([sum(abs(x[i: i + window_length] ** 2)) #windwo_length구간 안에있는 모든 샘플들의 진폭의 제곱의 합->소리의 크기
754 for i in range(0, len(x), window_length)]) #len(x)는 sr*영상길이인데 이것을 window_length만큼 끊음 i = 0, winlength, winlength*2, winlength*3, ... 791 for i in range(0, len(x), window_length)]) #len(x)는 sr*영상길이인데 이것을 window_length만큼 끊음 i = 0, winlength, winlength*2, winlength*3, ...
792 +<<<<<<< HEAD
755 793
794 +=======
795 + #print(energy)
796 +>>>>>>> 34cff6b09a8d3e1117437cc9ed79eb6ae8313c1f
756 #energy data를 dataframe으로 만듦 797 #energy data를 dataframe으로 만듦
757 df = pd.DataFrame(columns=['energy', 'start', 'end']) 798 df = pd.DataFrame(columns=['energy', 'start', 'end'])
758 row_index = 0 799 row_index = 0
...@@ -763,9 +804,42 @@ class Clip: ...@@ -763,9 +804,42 @@ class Clip:
763 df.loc[row_index, 'start'] = i[0] * max_slice 804 df.loc[row_index, 'start'] = i[0] * max_slice
764 df.loc[row_index, 'end'] = (i[0] + 1) * max_slice 805 df.loc[row_index, 'end'] = (i[0] + 1) * max_slice
765 row_index = row_index + 1 806 row_index = row_index + 1
807 +<<<<<<< HEAD
766 808
767 #연속구간으로 나타내기 809 #연속구간으로 나타내기
768 810
811 +=======
812 + #print(df)
813 + """
814 + if value >= threshold:
815 + i = np.where(energy == value)[0]
816 + df.loc[row_index, 'energy'] = value
817 + df.loc[row_index, 'start'] = i[0] * max_slice
818 + df.loc[row_index, 'end'] = (i[0] + 1) * max_slice
819 + row_index = row_index + 1
820 + print(df) #threshold를 넘은 구간이 저장됨
821 + """
822 + #연속구간으로 나타내기
823 + """
824 + temp = []
825 + i = 0
826 + j = 0
827 + n = len(df) - 2
828 + m = len(df) - 1
829 + while (i <= n):
830 + j = i + 1
831 + while (j <= m):
832 + if (df['end'][i] == df['start'][j]):
833 + df.loc[i, 'end'] = df.loc[j, 'end']
834 + temp.append(j)
835 + j = j + 1
836 + else:
837 + i = j
838 + break
839 + df.drop(temp, axis=0, inplace=True)
840 + print(df)
841 + """
842 +>>>>>>> 34cff6b09a8d3e1117437cc9ed79eb6ae8313c1f
769 return df 843 return df
770 844
771 845
...@@ -912,7 +986,26 @@ def get_video_duration(service, **kwargs): ...@@ -912,7 +986,26 @@ def get_video_duration(service, **kwargs):
912 def _js_parseInt(string): 986 def _js_parseInt(string):
913 return int(''.join([x for x in string if x.isdigit()])) 987 return int(''.join([x for x in string if x.isdigit()]))
914 988
989 +<<<<<<< HEAD
915 990
991 +=======
992 +"""
993 +if __name__ == '__main__':
994 + # When running locally, disable OAuthlib's HTTPs verification. When
995 + # running in production *do not* leave this option enabled.
996 + os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
997 + service = get_authenticated_service()
998 + video_id = input('Enter a video_id: ')
999 + comments = get_video_comments(
1000 + service, part='snippet', videoId=video_id, textFormat='plainText')
1001 + video_duration = get_video_duration(
1002 + service, part='contentDetails', id=video_id)
1003 + # print(video_duration)
1004 + # print(comments)
1005 + commentdata = make_video_timeline(comments, video_duration)
1006 + print(commentdata)
1007 +"""
1008 +>>>>>>> 34cff6b09a8d3e1117437cc9ed79eb6ae8313c1f
916 1009
917 if __name__ == "__main__": 1010 if __name__ == "__main__":
918 app = QApplication(sys.argv) 1011 app = QApplication(sys.argv)
......
File mode changed