Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • About’s Pitt
Close Button

รวมความยาว videoรวมความยาว video

2010-08-082010-08-08| phunsanitphunsanit| 0 Comment | 07:00

ากต้องการรวมความยาวของวิดีโอทั้งหมดในโฟลเดอร์ เช่น /Users/Shared/meetings บน macOS คุณสามารถใช้คำสั่งบน Terminal ได้หลายวิธีครับ โดยวิธีที่แม่นยำที่สุดคือการใช้ ffprobe (ซึ่งมาพร้อมกับ ffmpeg) หรือจะใช้คำสั่ง mdls ที่มีอยู่แล้วในเครื่อง macOS ก็ได้ครับ


ใช้ mdls (สะดวกที่สุด ไม่ต้องติดตั้งโปรแกรมเพิ่ม)

macOS มีระบบ Spotlight คอยเก็บ Metadata ของไฟล์อยู่แล้ว สามารถรันคำสั่งนี้บน Terminal เพื่อหาความยาวรวม (วินาที) แล้วแปลงเป็น ชั่วโมง:นาที:วินาที ได้ทันที
find /Users/Shared/meetings -type f ( -name ".mp4" -o -name ".mov" -o -name "*.mkv" ) -print0 | xargs -0 mdls -name kMDItemDurationSeconds | awk '{sum += $3} END {printf "%02d:%02d:%02d\n", sum/3600, (sum%3600)/60, sum%60}'
หมายเหตุ: สามารถเพิ่มหรือลดนามสกุลไฟล์วิดีโอในเครื่องหมาย \( ... \) ได้ตามต้องการ เช่น -name "*.avi"


ใช้ ffprobe (แม่นยำที่สุด สำหรับสาย Dev)

หากในเครื่องมี ffmpeg ติดตั้งอยู่แล้ว (เช่น ติดตั้งผ่าน Homebrew) วิธีนี้จะเช็กจากตัวไฟล์วิดีโอโดยตรงและแม่นยำมากครับ
find /Users/Shared/meetings -type f ( -name ".mp4" -o -name ".mov" -o -name "*.mkv" ) -print0 | xargs -0 -I {} ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "{}" | awk '{sum += $1} END {printf "%02d:%02d:%02d\n", sum/3600, (sum%3600)/60, sum%60}'


ใช้สคริปต์ Python (อ่านง่ายและปรับแต่งต่อสะดวก)

หากต้องการผลลัพธ์ที่ละเอียดขึ้น สามารถสร้างไฟล์สคริปต์ Python สั้น ๆ (ใช้ตัวอ่าน metadata พื้นฐานของ macOS) รันคำสั่งนี้ใน Terminal ได้เลยครับ

python3 -c '
import os, subprocess
total_seconds = 0
path = "/Users/Shared/meetings"
extensions = (".mp4", ".mov", ".mkv", ".avi")

for root, dirs, files in os.walk(path):
    for file in files:
        if file.lower().endswith(extensions):
            filepath = os.path.join(root, file)
            try:
                # ดึงเวลาเป็นวินาทีผ่าน mdls
                output = subprocess.check_output(f"mdls -name kMDItemDurationSeconds \"{filepath}\"", shell=True).decode()
                if "kMDItemDurationSeconds =" in output:
                    sec = float(output.split("=")[1].strip())
                    total_seconds += sec
            except:
                pass

hours = int(total_seconds // 3600)
minutes = int((total_seconds % 3600) // 60)
seconds = int(total_seconds % 60)
print(f"เวลาทั้งหมด: {hours} ชั่วโมง {minutes} นาที {seconds} วินาที (รวม {total_seconds:.2f} วินาที)")
'

อ่านเพิ่มเติม

  • VLC Media Player: ดู video ได้ทุกเรื่อง ทุกไฟล์
  • ดูดโหลด video, MP3 โดย yt-dlp
  • yt-dlp: Options
Read MoreRead More

Posts pagination

ก่อนหน้า 1 … 4,261 4,262 4,263 … 11,501 ถัดไป

Projects

  • Statement Columns Mapping Helper
  • PlusMagi Blocks
  • PlusMagi Site Search
  • PlusMagi Tags Reindex
  • jQuery Plus Repeater

Recent Posts

  • Playwright Thesaurus 1788954211843
  • เทคนิคแทรก Post ID ที่หายไปใน WordPress ด้วย CTE Recursive ในเสี้ยววินาที
  • SPA: Single Page Applications
  • foundation สถาบัน สถาปนา
  • PHP: การทำ Database Migration แทนการรันคำสั่ง SQL สดบน Server

Archives

Categories

  • .net core (41)
  • Academia (23)
  • Accounting (7)
  • agile methodologies (25)
  • Agriculture (1)
  • AI (326)
  • anthropology (6)
  • Archaeology (1)
  • architecture (490)
  • Artificial Intelligence (24)
  • Astronomy (2)
  • Authentication (52)
  • automation (166)
  • Behavioral Science (71)
  • Biology (4)
  • Biotechnology (1)
  • Building Codes (1)
  • Building Engineering (2)
  • Building Safety (2)
  • Building Science (1)
  • business (407)
  • Business Analysis (215)
  • Business Ethics (4)
  • Businesses (43)
  • career development (23)
  • cd (122)
  • ci (117)
  • civil engineering (9)
  • Client-Side Scripting (1)
  • Cloud Computing (267)
  • Cognitive Science (62)
  • Communication (103)
  • community management (1)
  • Compliance (1)
  • Computational Science (1)
  • Computer (146)
  • Computer Hardware (33)
  • computer science (855)
  • Construction (3)
  • construction law (1)
  • Containerization (35)
  • Content Management System (1)
  • Content Management Systems (1)
  • Corporate Governance (4)
  • criminology (21)
  • Criminology (เสนอใหม่) (1)
  • Cryptography (33)
  • culture (84)
  • Cybersecurity (129)
  • data (210)
  • Data Analysis (2)
  • Data Engineering (4)
  • Data Governance (1)
  • Data Integration (16)
  • Data Management (5)
  • data modeling (1)
  • Data Privacy (2)
  • data science (16)
  • Data Visualization (35)
  • Database Design (1)
  • Database Management (13)
  • Database Systems (7)
  • Design (214)
    • UX/UI (7)
  • Development (221)
  • devops (229)
  • devsecops (40)
  • Digital Art (1)
  • Digital Communication (1)
  • Digital Design (1)
  • Digital Economy (1)
  • digital marketing (1)
  • Distributed Systems (2)
  • Document Processing (1)
  • Documentation (14)
  • dotnet (39)
  • economics (1)
  • Edge Computing (2)
  • education (2)
  • Education Technology (2)
  • Electrical Engineering (2)
  • embedded systems (2)
  • energy (2)
  • engineering (5)
  • Enterprise IT Governance (1)
  • Entertainment (4)
  • Entrepreneurship (1)
  • Environment (1)
  • envoy (1)
  • Ethics (1)
  • facility management (1)
  • Film (2)
  • Finance (12)
  • Forensic Science (เสนอใหม่) (1)
  • Front-End Development (2)
  • frontend development (4)
  • Geography (1)
  • Geology (1)
  • Governance (6)
  • government services (1)
  • Graphic Design (2)
  • Hardware (1)
  • Health (2)
  • Histories (26)
  • history (7)
  • html (1)
  • Human Resources (1)
  • Human-Computer Interaction (6)
  • Humanities (1)
  • industrial standards (1)
  • Information Governance (1)
  • Information Science (6)
  • information security (5)
  • Information Technology (1)
  • insurance (1)
  • Internet of Things (1)
  • it service management (1)
  • IT Support (1)
  • knowledge management (3)
  • labor law (1)
  • Law (45)
  • Law and Regulation (1)
  • leadership (1)
  • Learning Management System (1)
  • Legal (5)
  • Legal Affairs (2)
  • Legal Compliance (1)
  • Legal Studies (4)
  • Library Science (1)
  • Life (681)
    • Books (71)
    • Cartoon (24)
    • D.I.Y (32)
    • Game (1)
    • Mindset (41)
    • Movies (31)
    • Philosophy (18)
    • Psychology (8)
    • Sci-Fi (38)
    • Tips and Tricks (32)
    • ปรัชญา (153)
    • พัฒนาตนเอง (251)
    • พุทธ (7)
    • สิ่งแวดล้อม (20)
  • lifestyle (1)
  • Linguistics (1)
  • Literature (6)
  • Logic (1)
  • machine learning (1)
  • management (1)
  • Mathematics (14)
  • Mechanical Engineering (1)
  • media (1)
  • Media Studies (1)
  • Mental Health (1)
  • Metadata (1)
  • mobile (1)
  • Mobile Computing (1)
  • mobile development (2)
  • Modular Design (1)
  • Music (1)
  • mystery (8)
  • Mythology (1)
  • net core (1)
  • Network (317)
    • Apache HTTP Server (31)
    • IOT (23)
    • Nginx (26)
    • Stalwart (7)
  • Network Security (1)
  • networking (152)
  • Operating System (5)
  • Operating Systems (424)
    • Unix-like (308)
      • Android (28)
        • F-Droid (6)
      • Homebrew (24)
      • iPhone (9)
      • Linux (197)
      • macOS (117)
        • OrbStack (12)
      • Oh My ZSH (5)
      • Shell Script (35)
      • SSH (5)
    • Windows (96)
      • PowerShell (26)
      • WSL (14)
  • operations (1)
  • Operations Management (2)
  • Personal Experience (1)
  • Personal Finance (1)
  • php programming (1)
  • Physics (1)
  • Policy (2)
  • Pop Culture (3)
  • Product Design (2)
  • product management (1)
  • productivity (3)
  • Programming (1,820)
    • .NET (96)
      • .NET Core EF (9)
      • C# (73)
    • API (361)
      • REST (8)
      • Swagger (4)
    • Database (452)
      • DBeaver (7)
      • MariaDB (35)
      • MySql (67)
      • Oracle Database (24)
        • 10g (8)
      • PostgreSQL (14)
      • RDBMS (42)
      • SQL Server (76)
        • SSMS (5)
        • T-SQL (26)
    • PowerBuilder (17)
    • Python (13)
    • Rust (31)
    • System Analyst (SA) (33)
    • Testing (114)
      • Automated Testing (98)
        • Playwright (7)
    • UML (2)
    • Web (1,294)
      • Backend (1,033)
        • Golang (1)
        • Java (104)
          • Spring Boot (15)
        • Node.js (2)
        • PHP (238)
          • Laravel (54)
          • Yii (1)
      • Frontend (286)
        • CSS (46)
          • Tailwind CSS (4)
        • JavaScript (206)
          • Angular (7)
          • jQuery (56)
          • Tabulator (24)
          • Vue.js (6)
      • WordPress (30)
  • Programming Languages (13)
  • Programs (69)
    • Excel (17)
  • Project Management (9)
  • Property Law (3)
  • Property Management (2)
  • public administration (1)
  • Public Safety (1)
  • r (1)
  • Real Estate (15)
  • Real Estate Law (1)
  • Religion (6)
  • Requirements Engineering (1)
  • Risk Management (4)
  • safety (2)
  • Safety Engineering (8)
  • Safety Science (1)
  • safety standards (2)
  • Safety Systems (1)
  • science (10)
  • Science Fiction (4)
  • script (1)
  • SecDevOps (144)
    • CI/CD (12)
    • Docker (64)
    • GIT (54)
    • SVN (6)
  • Security (211)
  • Self-Improvement (1)
  • SEO (2)
  • sistema (1)
  • social (1)
  • social policy (2)
  • social science (2)
  • social welfare (1)
  • Sociology (1)
  • Software (2)
  • Software Architecture (2)
  • Software Development (17)
  • Software Engineering (35)
  • Software Licensing (3)
  • Software Quality Assurance (1)
  • Software Security (1)
  • Software Testing (5)
  • Software Tools (1)
  • Space Exploration (2)
  • Spirituality (4)
  • SQL (1)
  • Standards (1)
  • statistics (2)
  • strategy (1)
  • system (111)
  • System Administration (8)
  • System Analysis (2)
  • system analyst (19)
  • System Architecture (2)
  • System Integration (1)
  • System Tools (1)
  • Systems Programming (2)
  • technology (173)
  • Technology Strategy (1)
  • technologyระบบ (13)
  • technologyและระบบ (1)
  • Tools (1)
  • Transportation (2)
  • ui (11)
  • Uncategorized (3,100)
  • urban planning (10)
  • User Experience (4)
  • User Experience (UX) (1)
  • User Experience Design (1)
  • User Interface (3)
  • User Interface Design (1)
  • ux (12)
  • ux design (1)
  • Version Control (1)
  • Web Development (63)
  • Web Security (1)
  • web server (1)
  • กฎหมาย (288)
  • กฎหมายทรัพย์สิน (1)
  • การจัดการ (586)
  • การจัดการข้อมูล (165)
  • การจัดการข้อมูลและองค์ความรู้ (1)
  • การจัดการอาคาร (1)
  • การบริหารจัดการ (1)
  • การบริหารจัดการธุรกิจ (1)
  • การพัฒนาตนเอง (12)
  • การออกแบบ (60)
  • การเขียน (1)
  • คณิตศาสตร์ (29)
  • ความคิด (108)
  • ความปลอดภัย (118)
  • จริยธรรม (57)
  • จักรวาลวิทยา (1)
  • จิตวิทยา (845)
  • ชีวิต (87)
  • ฐานข้อมูล (12)
  • ทั่วไป (61)
  • ธุรกิจ (319)
  • นิยายวิทยาศาสตร์ (1)
  • บุคคล (8)
  • บุคลากร (1)
  • บุคลิก (60)
  • ประวัติศาสตร์ (30)
  • ปัญญาประดิษฐ์ (11)
  • พฤติกรรม (68)
  • ภาษา (1)
  • ภาษาศาสตร์คอมพิวเตอร์ (12)
  • ระบบ (79)
  • ระบบปฏิบัติการ (30)
  • วัฒนธรรม (10)
  • วิชาการ (36)
  • วิชาการข้อมูล (37)
  • วิทยาการข้อมูล (28)
  • วิทยาการข้อมูลและภาษาศาสตร์คอมพิวเตอร์ (1)
  • วิทยาศาสตร์ (79)
  • วิทยาศาสตร์ข้อมูล (3)
  • สถาปัตยกรรม (1)
  • สังคม (17)
  • สุขภาพ (28)
  • องค์ความรู้ (19)
  • อสังหาริมทรัพย์ (5)
  • ออกแบบ (1)
  • เทคโนโลยี (4,315)
  • เทคโนโลยีระบบ (5)
  • ไวยากรณ์ (1)
  • 기술 (1)
  • 사회 (1)

Sirat WordPress Theme By VWThemes

Scroll Up
Exit mobile version