{"id":29668101,"url":"https://github.com/junho100/aws-bedrock-ts-demo","last_synced_at":"2025-07-22T17:06:06.242Z","repository":{"id":290515138,"uuid":"973136007","full_name":"junho100/aws-bedrock-ts-demo","owner":"junho100","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-29T07:31:12.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T08:34:42.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junho100.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-26T10:39:19.000Z","updated_at":"2025-04-29T07:31:16.000Z","dependencies_parsed_at":"2025-04-29T08:47:34.767Z","dependency_job_id":null,"html_url":"https://github.com/junho100/aws-bedrock-ts-demo","commit_stats":null,"previous_names":["junho100/aws-bedrock-ts-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/junho100/aws-bedrock-ts-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junho100%2Faws-bedrock-ts-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junho100%2Faws-bedrock-ts-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junho100%2Faws-bedrock-ts-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junho100%2Faws-bedrock-ts-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junho100","download_url":"https://codeload.github.com/junho100/aws-bedrock-ts-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junho100%2Faws-bedrock-ts-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266535695,"owners_count":23944275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T17:06:05.621Z","updated_at":"2025-07-22T17:06:06.233Z","avatar_url":"https://github.com/junho100.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Bedrock을 활용한 비디오 분석 샘플 코드\n\n## 기능\n\n- 인터넷 URL에서 비디오 파일 다운로드\n- 비디오의 프레임을 일정 간격으로 샘플링\n- 샘플링된 프레임을 AWS Bedrock Claude AI를 통해 분석\n- 프레임 분석 결과를 종합하여 비디오 내용 요약 생성\n- 주요 이벤트, 관련 객체, 패턴, 이상 징후 및 위험 평가 제공\n\n## 설치 방법\n\n### 요구사항\n\n- Node.js 16.x 이상\n- AWS 계정 및 Bedrock 서비스 접근 권한\n- AWS CLI 구성 및 자격 증명 설정\n\n### 설치\n\n```bash\n# 저장소 클론\ngit clone https://github.com/junho100/aws-bedrock-ts-demo.git\ncd aws-nova-ts-demo\n\n# 의존성 설치\nnpm install\n```\n\n### config.ts 파일 생성\n\n루트 디렉토리에 아래와 같은 내용으로 `config.ts` 파일을 생성하세요:\n\n```typescript\n/**\n * 비디오 분석기 환경 설정\n */\nexport const config = {\n  // 비디오 URL (분석할 비디오 URL로 변경)\n  videoUrl: \"https://비디오URL을입력하세요.mp4\",\n\n  // 비디오 처리 설정\n  videoProcessing: {\n    // 프레임 샘플링 간격 (밀리초)\n    sampleMsec: 1000,\n\n    // 프레임 크기 조정 비율 (0.0 ~ 1.0)\n    resizeRatio: 0.7,\n\n    // 한 번에 처리할 프레임 수\n    frameBatchSize: 7,\n\n    // 슬라이딩 윈도우 크기 (몇 프레임씩 이동할지)\n    slidingWindowSize: 7,\n\n    // 출력 디렉토리\n    outputDir: \"./workspace\",\n  },\n\n  // AWS Bedrock 설정\n  aws: {\n    // AWS 리전\n    region: \"ap-northeast-2\",\n\n    // AWS 프로필 (credentials 파일에 설정된 프로필)\n    profile: \"your-aws-profile\",\n\n    // Bedrock 모델 ID\n    modelId: \"apac.anthropic.claude-3-5-sonnet-20240620-v1:0\",\n  },\n};\n```\n\n## 사용 방법\n\n1. 위에서 설명한 대로 `config.ts` 파일을 생성하고 필요한 정보를 입력합니다.\n\n2. 애플리케이션 실행:\n\n```bash\nnpm start\n```\n\n## 실행 예시\n\n애플리케이션을 실행하면 다음과 같은 순서로 비디오 분석이 진행됩니다:\n\n1. 지정된 URL에서 비디오 다운로드\n2. 비디오에서 주기적으로 프레임 샘플링\n3. 샘플링된 프레임을 AWS Bedrock Claude AI로 분석\n4. 비디오 전체에 대한 종합 분석 결과 출력\n\n```\n=== 비디오 분석 시작 ===\n비디오 URL: https://example.com/your-video.mp4\nURL에서 비디오 다운로드 중: https://example.com/your-video.mp4\n비디오가 다음 경로에 다운로드 되었습니다: /path/to/tmp_xxx/video_sample.mp4\n프레임 샘플링 중...\n62개 프레임이 샘플링 되었습니다.\n프레임 분석 중...\n비디오 종합 분석 중...\n\n================ 비디오 분석 결과 ================\n요약:\n[비디오 내용에 대한 종합적인 요약 내용]\n\n주요 이벤트:\n1. [이벤트 설명] (중요도: HIGH)\n2. [이벤트 설명] (중요도: MEDIUM)\n\n관련 객체:\n사람: [관련된 사람들 설명]\n물체: [관련된 물체 설명]\n\n분석:\n패턴: [비디오에서 발견된 패턴 설명]\n이상 징후: [발견된 이상 징후 설명]\n위험 평가: [전체적인 위험 수준 평가]\n==================================================\n```\n\n### 샘플 프레임\n\n실행 과정에서 비디오는 여러 프레임으로 분할되어 `workspace/frames/` 디렉토리에 저장됩니다. 이러한 프레임들이 Claude AI에 의해 분석되어 비디오의 내용을 해석하는 데 사용됩니다.\n\n예를 들어, 다음과 같은 형식으로 프레임이 저장됩니다:\n\n- `frame_000001.jpg`\n- `frame_000002.jpg`\n- ...\n- `frame_000039.jpg`\n\n각 프레임은 지정된 시간 간격(기본값: 1초)으로 추출되며, 이 프레임들의 연속적인 분석을 통해 비디오의 전체적인 내용과 주요 이벤트를 파악합니다.\n\n## 주요 구성 요소\n\n- **VideoAnalyzer**: 비디오 처리 및 분석을 담당하는 메인 클래스\n- **BedrockClient**: AWS Bedrock 서비스와의 통신을 처리하는 클래스\n- **config.ts**: 애플리케이션 설정 관리\n\n## 동영상 분석 방식\n\n이 프로젝트는 다음과 같은 방식으로 동영상을 분석합니다:\n\n### 1. 비디오 다운로드 및 전처리\n\n- HTTP/HTTPS 프로토콜을 사용하여 지정된 URL에서 비디오 파일을 다운로드합니다.\n- ffmpeg를 사용하여 비디오 메타데이터(FPS, 프레임 수, 해상도 등)를 추출합니다.\n\n### 2. 프레임 샘플링\n\n- 구성된 시간 간격(`sampleMsec`, 기본값: 1000ms)에 따라 비디오에서 정기적으로 프레임을 추출합니다.\n- 추출된 각 프레임은 지정된 비율(`resizeRatio`, 기본값: 0.7)로 크기가 조정되어 저장됩니다.\n- 모든 프레임은 `workspace/frames/` 디렉토리에 저장됩니다.\n\n### 3. 슬라이딩 윈도우 기법\n\n- 연속적인 비디오 컨텍스트를 유지하기 위해 슬라이딩 윈도우 접근 방식을 사용합니다.\n- 프레임들이 배치(`frameBatchSize`, 기본값: 7개)로 그룹화되어 처리됩니다.\n- 각 새 배치는 이전 배치에서 일정 수의 프레임(`slidingWindowSize`, 기본값: 7)만큼 이동하여 시간적 연속성을 유지합니다.\n\n### 4. AI 분석 단계\n\n- **프레임 시퀀스 분석**: AWS Bedrock의 Claude AI 모델이 각 프레임 배치를 분석하여 시간 순서대로 상황을 설명합니다.\n\n  - 모델은 CCTV 영상 분석 전문가 역할을 수행하도록 프롬프트가 설계되어 있습니다.\n  - 각 프레임 배치에 대해 시퀀스 요약과 주요 이벤트를 식별합니다.\n  - 이전 프레임 배치의 분석 결과를 참조하여 연속성을 유지합니다.\n\n- **종합 분석**: 모든 프레임 배치 분석이 완료되면, 전체 비디오에 대한 종합 분석을 수행합니다.\n  - 주요 이벤트와 그 중요도(높음/중간/낮음)를 식별합니다.\n  - 관련 객체(사람, 물체)를 분류합니다.\n  - 행동 패턴, 이상 징후, 위험 평가 등 종합적인 분석 결과를 제공합니다.\n\n### 5. 결과 처리\n\n- 모든 분석 결과는 구조화된 JSON 형식으로 반환되며, 콘솔에 요약되어 출력됩니다.\n- 토큰 사용량 통계가 기록되어 AWS Bedrock 서비스 사용량을 모니터링할 수 있습니다.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunho100%2Faws-bedrock-ts-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunho100%2Faws-bedrock-ts-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunho100%2Faws-bedrock-ts-demo/lists"}