วันนี้มีงานที่ต้องหา duration ของไฟล์วีดีโอซึ่งมีจำนวนมากเกินไปที่จะใช้คนทำ ดังนั้นจึงเลือกใช้ FFmpeg ในการทำงาน ซึ่ง code มีดังนี้
command = "ffmpeg -i filename.m4v 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//" output = `#{command}` if output =~ /([\d][\d]):([\d][\d]):([\d][\d]).([\d]+)/ duration = (($1.to_i * 60 + $2.to_i) * 60 + $3.to_i) * 10 + $4.to_i end


