Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • About’s Pitt
Close Button
PlusMagi's Blog By Pitt Phunsanit Backend,Business,Cloud Computing,Technology รวมความยาว video

รวมความยาว video

2014-05-102014-05-10| phunsanitphunsanit| 0 Comment | 07:00
Categories:
  • Backend
  • Business
  • Cloud Computing
  • Technology

ากต้องการรวมความยาวของวิดีโอทั้งหมดในโฟลเดอร์ เช่น /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 ได้เลยครับ

BASH / Shell

BASH / Shell

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
Tags: Bashrc, Command Line, Macos, Metadata, Modular Configuration, Progress Bars, Terminal, Video Processing, Zshrc, คลาย, บีบอัด, ปรากฏ, แบนด์วิดท์

แนะแนวเรื่อง

PREVIOUS Previous post: pipeline คืออะไร
NEXT Next post: MacOs: การใช้ /Users/Shared เพื่อแชร์ข้อมูลระหว่าง Local User อย่างปลอดภัย

Projects

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

Recent Posts

  • Language & Runtime (C#, .NET 10, CLR, GC, Memory Management)
  • windows, mac, linux ในการเขียนโปรแกรม
  • C#: upgrade to .net Core
  • Linux: .NET SDK / Runtime
  • ระฆังทิเบต หรือ ขันทิเบต (Tibetan Singing Bowl)

Archives

Categories

  • Ai (792)
    • AI Robotics (1)
    • AI Strategy (1)
    • AI/ML Infrastructure (1)
    • Data Cleaning (1)
    • DeFi (1)
    • GNSS (1)
    • GNSS Technology (1)
    • Historical Data Analysis (1)
    • IoT Data Management (1)
    • ระบบวิเคราะห์ (1)
    • เทคโนโลยี GNSS (1)
    • เทคโนโลยีภูมิสารสนเทศ (1)
  • Backend (3,155)
    • Accessibility Technology (1)
    • Advanced Architecture (1)
    • Advanced JavaScript (1)
    • Agile Methodology (1)
    • Angular (5)
    • Api Integration (5)
    • Automation Testing (1)
    • C# Programming (5)
    • CAD/CAM (1)
    • Clean Architecture (1)
    • CMS Development (1)
    • Codeigniter (1)
    • Coding Theory (1)
    • Concurrency (5)
    • CSS Frameworks (1)
    • Data Structures (5)
    • Debugging Tools (3)
    • Design Patterns (5)
    • Development (1)
    • Digital Design (1)
    • Front-End Architecture (2)
    • Front-End Development (1)
    • Frontend Testing (1)
    • Game Development (1)
    • HTML5 (6)
    • Joget Development (1)
    • Jquery (24)
    • Localization (l10n) (1)
    • Low-code Platform (1)
    • Microservices Architecture (1)
    • Object-oriented Programming (5)
    • Object-oriented Programming (oop) (1)
    • Oop (1)
    • PHP Performance (1)
    • Pure JavaScript (1)
    • Scripting (1)
    • Software Design (1)
    • Software Design Pattern (1)
    • Software Quality Assurance (1)
    • Systems Programming (1)
    • Technical Design (1)
    • Technical Specification (1)
    • UI/UX Backend (1)
    • UI/UX Design (6)
    • UML (1)
    • User Experience (UX) (1)
    • Version Control (1)
    • Version Control System (1)
    • Web Development Tools (1)
    • Web Services (1)
    • สถาปัตยกรรมซอฟต์แวร์ (2)
  • Business (1,168)
    • Business Process Automation (1)
    • Business Process Management (1)
    • Business Process Modeling (1)
    • Career Planning (1)
    • Career Strategy (1)
    • Email Marketing (1)
    • Finance Tech (1)
    • Finance Technology (1)
    • Financial Modeling (4)
    • Financial Systems (1)
    • Financial Technology (fintech) (1)
    • Global Strategy (1)
    • Global Studies (1)
    • Good Governance (1)
    • HR Management (1)
    • Information Management (1)
    • Logistics Tech (1)
    • Marketing Strategy (1)
    • Quality Management (1)
    • Quantitative Finance (1)
    • Real Estate Investment (1)
    • Real Estate Tech (1)
    • SEO (1)
    • SEO Content (1)
    • Technical Analysis (26)
    • Technical Finance (1)
    • Technical Leadership (1)
    • Technical Skillset (1)
    • Technical Writing (29)
    • การจัดการวิกฤต (1)
    • การทำงาน (1)
    • การบริหารจัดการทรัพย์สิน (1)
    • การบริหารอาคาร (1)
    • การสื่อสารดิจิทัล (1)
    • การเงินดิจิทัล (1)
    • การเงินธุรกิจ (1)
    • จริยธรรมวิชาชีพ (1)
    • ประกันชีวิต (1)
    • ประกันภัยรถยนต์ (1)
    • สินทรัพย์ปลอดภัย (1)
    • อาชีพ (1)
  • Cloud Computing (1,390)
    • AWS (1)
    • Cloud Infrastructure (1)
    • Configuration Management (3)
    • Decentralized Systems (1)
    • DevOps Tools (1)
    • Distributed Computing (1)
    • Embedded Linux (1)
    • High Availability (1)
    • Home Lab (1)
    • IoT Systems (1)
    • IT Operations (1)
    • Legacy Systems Integration (1)
    • Linux Guides (1)
    • Machine Learning Operations (1)
    • Mlops (1)
    • Network Protocols (1)
    • Network Technology (1)
    • Network Tools (1)
    • Observability (3)
    • Open Source (1)
    • P2P Technology (1)
    • Scalability (1)
    • System Automation (1)
    • System Control (1)
    • System Engineering (1)
    • System Logging (1)
    • System Monitoring (1)
    • System Performance (1)
    • System Reliability (1)
    • System Simulation (1)
    • System Specialist (2)
    • Troubleshooting (1)
    • Web Hosting (1)
    • Web Server (1)
    • Wi-fi Technology (1)
    • Windows Automation (1)
  • Cybersecurity (653)
    • Data Forensics (1)
    • Email Security (1)
    • Identity Management (1)
    • Intellectual Property (1)
    • Iot Security (1)
    • Legal Technology (1)
    • PDPA Compliance (1)
    • Penetration Testing (1)
    • Real Estate Law (1)
    • Security Engineering (1)
    • Signal Intelligence (1)
    • Technical Compliance (2)
    • กฎหมาย รัฐบาล (1)
    • ความปลอดภัยทางกายภาพ (1)
    • ความปลอดภัยทางไซเบอร์ (1)
    • ความรับผิดทางกฎหมาย (2)
    • นิติวิทยาศาสตร์ดิจิทัล (1)
    • ระบบความปลอดภัยอาคาร (1)
    • ระบบป้องกันสัญญาณ (1)
  • Database (3,238)
    • Caching (1)
    • Concurrency Control (1)
    • Data Governance (19)
    • Data Structuring (1)
    • Data Types (1)
    • Database Analysis (1)
    • Database Caching (1)
    • Database ORM (1)
    • Database Protocols (1)
    • Database Standards (1)
    • Nosql (1)
    • Pl/pgsql (1)
    • PostgreSQL Database (1)
    • PostgreSQL Performance (1)
    • Postgresql Theory (1)
    • Postgresql Tuning (1)
    • Sql Tutorial (1)
    • Storage Technology (1)
  • Psychology (565)
    • Biological Psychology (1)
    • Child Development (1)
    • Ergonomics (1)
    • First Aid (1)
    • Health Wellness (8)
    • Healthtech (1)
    • Personal Development (7)
    • Psychology Informatics (1)
    • Sleep Science (1)
    • Soft Skills Development (1)
    • Survival Skills (1)
    • Technology Psychology (1)
    • Toxicology (1)
    • การจัดการข้อมูลสุขภาพ (1)
    • การดูแลตัวเอง (1)
    • การนอนหลับ (1)
    • การปฐมพยาบาล (1)
    • การเลี้ยงดูบุตร (1)
    • การแพทย์ทางเลือก (1)
    • การแพทย์เชิงป้องกัน (1)
    • ความปลอดภัยในบ้าน (1)
    • จริยธรรมทางการแพทย์ (1)
    • จิตวิทยาพัฒนาการ (1)
    • ทักษะการทำงาน (1)
    • วิทยาศาสตร์การแพทย์ (1)
    • สมุนไพร (1)
    • สุขภาพ โภชนาการ (1)
    • สุขภาพองค์รวม (1)
    • เทคโนโลยีสุขภาพ (1)
  • Technology (2,165)
    • Academic Publishing (1)
    • Academic Writing (1)
    • Aerospace Systems (1)
    • Ai Ethics (1)
    • Animation (1)
    • Anime Analysis (1)
    • Astrophysics (1)
    • Aviation Systems (1)
    • Best Practices (6)
    • Cabinetry (1)
    • Chemistry (1)
    • Chemistry Safety (1)
    • Climate Change Adaptation (1)
    • Communication Skills (7)
    • Community Development (1)
    • Conservation Tech (1)
    • Content Management System (2)
    • Cosmology (1)
    • Critical Thinking (1)
    • Cultural Informatics (1)
    • Defense Technology (1)
    • Digital Art (1)
    • Digital Humanities (1)
    • Digital Literacy (1)
    • Digital Preservation (1)
    • Disaster Management (1)
    • Emergency System (1)
    • Fantasy Analysis (1)
    • Film History (1)
    • Film Studies (1)
    • Food Science (1)
    • Food Technology (1)
    • Forensic Science (1)
    • Geography (1)
    • Geopolitics (1)
    • History Science (1)
    • Home Appliances (1)
    • Hospitality Tech (2)
    • Industrial Iot (1)
    • Information Theory (1)
    • Interior Design (1)
    • Iot (25)
    • IoT Data (1)
    • Iot Development (1)
    • Landscape Architecture (1)
    • Logic (1)
    • Mermaid.js (1)
    • Military Hardware (1)
    • Military Survival (1)
    • Military Tech (1)
    • Mining Industry (1)
    • Music Analysis (1)
    • Mythology (1)
    • Productivity Tools (2)
    • Propaganda (1)
    • Research Methodology (1)
    • Sci-fi Analysis (1)
    • Search Engine Technology (1)
    • Search Rescue (1)
    • SEO Technical (2)
    • Smart Building (1)
    • Smart Home (2)
    • Smart Mobility (1)
    • Social Computing (1)
    • Space Communication (1)
    • Surveying (1)
    • Surveying Engineering (1)
    • System Biology (1)
    • System Specialization (6)
    • Tech Review (1)
    • Technical Communication (6)
    • Technical Concept (1)
    • Technical Deep Dive (11)
    • Technical Development (2)
    • Technical Ethics (1)
    • Technical Guide (7)
    • Technical Guides (1)
    • Technical Reporting (1)
    • Technical Skill Development (1)
    • Technical Skills (7)
    • Technical Tutorial (1)
    • Technology Analysis (1)
    • Technology Comparison (1)
    • Technology Development (1)
    • Technology Integration (1)
    • Technology Leadership (1)
    • Technology Learning (1)
    • Technology System Design (1)
    • Tips And Tricks (14)
    • Travel Guide (1)
    • Underwater Communication (1)
    • UNESCO (1)
    • Veteran Affairs (1)
    • Weaponry Analysis (1)
    • การตกแต่งภายใน (1)
    • การทหาร (1)
    • การออกแบบภูมิทัศน์ (1)
    • การเกษตร (1)
    • ความปลอดภัยทางโครงสร้าง (1)
    • ความปลอดภัยทางไฟฟ้า (1)
    • ความมั่นคงระหว่างประเทศ (1)
    • ความรู้พื้นฐาน (1)
    • งานหัตถกรรม (1)
    • ดนตรี (1)
    • นิติวิทยาศาสตร์ (1)
    • ประวัติศาสตร์เทคโนโลยี (1)
    • พลังงานสะอาด (1)
    • พันธุศาสตร์ (1)
    • พืชพรรณ (1)
    • พุทธ (1)
    • ภูมิทัศน์ (1)
    • ยานยนต์ไฟฟ้า (1)
    • ระบบทหาร (1)
    • ระบบนำทาง (1)
    • ระบบยานยนต์ (1)
    • ระบบอาคารอัจฉริยะ (1)
    • ระบบเทคโนโลยี (1)
    • ระบบโครงสร้าง (1)
    • ระบบไฟฟ้า (1)
    • ระบบไอที (1)
    • วรรณคดีไทย (1)
    • วิทยาศาสตร์อวกาศ (1)
    • วิศวกรรมการทหาร (1)
    • วิศวกรรมยั่งยืน (1)
    • วิศวกรรมสถาปัตยกรรม (1)
    • สงครามเวียดนาม (1)
    • สถาปัตยกรรมโบราณ (1)
    • สถาปัตยกรรมไทย (1)
    • สาธารณูปโภค (1)
    • หุ่นยนต์ (1)
    • อาวุธเคมี (1)
    • เคมีภัณฑ์ (1)
    • เครื่องประดับ (1)
    • เครื่องใช้ไฟฟ้า (1)
    • เทคโนโลยี จริยธรรม (1)
    • เทคโนโลยี ปรัชญา (1)
    • เทคโนโลยีการแพทย์ (1)
    • เทคโนโลยีรถยนต์ (1)
    • เทคโนโลยีระบบข้อมูล (1)
    • เทคโนโลยีอาคาร (1)
    • เอเชียศึกษา (1)
    • โบราณคดี (1)
    • โลหะวิทยา (1)
    • ไซไฟ (1)
  • Uncategorized (1)

Sirat WordPress Theme By VWThemes

Scroll Up
Go to mobile version