{"id":1956,"date":"2016-02-25T07:34:20","date_gmt":"2016-02-24T22:34:20","guid":{"rendered":"http:\/\/www.white-room.jp\/blog\/?p=1956"},"modified":"2016-02-25T07:34:20","modified_gmt":"2016-02-24T22:34:20","slug":"%e5%8b%95%e7%94%bb%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%8b%e3%82%89%e7%ad%89%e9%96%93%e9%9a%94%e3%81%ab%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%e3%82%92","status":"publish","type":"post","link":"https:\/\/www.white-room.jp\/blog\/?p=1956","title":{"rendered":"\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u7b49\u9593\u9694\u306b\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u308b"},"content":{"rendered":"<p>\u3053\u3061\u3089<a href=\"http:\/\/askubuntu.com\/questions\/684834\/need-help-with-mpv-bash-script\">http:\/\/askubuntu.com\/questions\/684834\/need-help-with-mpv-bash-script<\/a>\u306eUbuntu\u7528\u306e\u56de\u7b54\u3092OSX\u3067\u4f7f\u3046\u3002<\/p>\n<h3>\u4f7f\u3046\u3082\u306e<\/h3>\n<p>bash &#8211;\u672c\u4f53<br \/>\nmplayer &#8211;\u52d5\u753b\u306e\u5c3a\u3068\u304b\u3092\u53d6\u308b<br \/>\nmpv &#8211;\u4e3b\u5f79<br \/>\nrename &#8211;\u7121\u3044\u3068\u3081\u3093\u3069\u304f\u3055\u3044<\/p>\n<h3>\u5165\u308c\u308b\u3082\u306e<\/h3>\n<p>home brew\u306f\u5165\u308c\u3068\u3044\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\nbrew install mplayer<br \/>\nbrew install mpv<br \/>\nbrew install rename<\/p>\n<h3>\u4f7f\u3044\u65b9<\/h3>\n<p>\u4e0b\u8a18\u306esh\u3067\u3000bash [\u4e0b\u8a18\u306e\u30b9\u30af\u30ea\u30d7\u30c8] [\u52d5\u753b\u30d5\u30a1\u30a4\u30eb]\u3000\u3067\u3001\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7b49\u9593\u9694\u306b100\u679a\u64ae\u308c\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306esh\u306e\u901a\u308a\u3001mplayer\u3060\u3051\u3067\u3084\u3063\u305f\u307b\u3046\u304c\u5408\u7406\u7684\u306a\u6c17\u3082\u3057\u307e\u3059\u304c\u3001mpv\u306e\u307b\u3046\u304c\u591a\u5c11\u901f\u3044\u306e\u3067\u3001\u3069\u3046\u305b\u898b\u3048\u306a\u3044\u306a\u3089\u901f\u3044\u307b\u3046\u304c\u3044\u3044\u3068\u3044\u3046\u3053\u3068\u3067mvp\u3002<\/p>\n<p>\u30a8\u30ed\u95a2\u4fc2\u3067\u306f\u975e\u5e38\u306b\u4fbf\u5229\u2026\u2026\u3067\u3082\u306a\u3044\u3002\u901f\u3044\u3057\u4fbf\u5229\u305d\u3046\u306a\u3093\u3067\u3059\u304c\u3001\u52d5\u753b\u3082\u97f3\u58f0\u3082\u4e00\u5207\u306e\u8868\u793a\u3092\u305b\u305a\u306b\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u308b\u306e\u3067\u3001\u898b\u305b\u305f\u3044\u30ab\u30c3\u30c8\u304c\u64ae\u308c\u3066\u3044\u308b\u4fdd\u8a3c\u306f\u5168\u304f\u7121\u304f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3082\u3063\u3068\u7d30\u304b\u304f\u5272\u308c\u3070\u2026\u3002\u5f8c\u304b\u3089\u306e\u30bb\u30ec\u30af\u30c8\u306e\u624b\u9593\u3092\u8003\u3048\u308b\u3068\u52d5\u753b\u3092\u898b\u306a\u304c\u3089\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u3068\u3063\u305f\u307b\u3046\u304c\u65e9\u3044\u3002<\/p>\n<p>36\u679a\u64ae\u308a\u306e\u30dd\u30b8\u3067\u30a8\u30ed\u30d3\u30c7\u30aa3\u672c\u5206\u3092\u64ae\u308b\u306e\u306b2000\u5186\u304f\u3089\u3044\u304b\u304b\u3063\u3066\u3044\u305f\u6642\u4ee3\u306b\u30011\u672c\u309212\u30b3\u30de\uff081\u30b3\u30de\u76ee\u306f\u30bf\u30a4\u30c8\u30eb\u30ab\u30c3\u30c8\uff09\u306b\u307e\u3068\u3081\u308b\u4ed5\u4e8b\u3067\u935b\u3048\u306c\u3044\u305f\u306e\u3067\u3001\u898b\u306a\u304c\u3089\u64ae\u308b\u4f5c\u696d\u306f\u4f59\u88d5\u3067\u3059\u3057\u3002<\/p>\n<p>\u4f7f\u3044\u307f\u3061\u3068\u3057\u3066\u306f\u3001\u5927\u96d1\u628a\u306a\u30ab\u30bf\u30ed\u30b0\u7684\u306a\u3082\u306e\u306b\u3057\u304b\u4f7f\u3048\u307e\u305b\u3093\u3002<\/p>\n<p>\u4f7f\u3044\u6240\u304c\u4eca\u3072\u3068\u3064\u3042\u308a\u307e\u305b\u3093\u304c\u3001OSX\u3067\u81ea\u52d5\u3067\u5927\u96d1\u628a\u306a\u9759\u6b62\u753b\u30ea\u30b9\u30c8\u3092\u4f5c\u308a\u305f\u3044\u3068\u304b\u3044\u3046\u3053\u3068\u304c\u5e74\u306b\uff11\u56de\u4f4d\u306f\u3042\u308b\u306e\u3067\u3001\u52d5\u3044\u305f\u3068\u3053\u308d\u3067\u30e1\u30e2\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/env bash\r\n\r\n### Global variables\r\nfilename=&quot;$1&quot;\r\n\r\n### Error handling\r\nif &#x5B; -z &quot;${filename}&quot; ];\r\nthen\r\n    echo &quot;ERROR: No video file supplied. Please enter a video file as argument.&quot;\r\n    exit 1;\r\nfi\r\n\r\nNUM_OF_SCREENSHOTS=100 ## \u679a\u6570\r\n\r\nif &#x5B; ! -z &quot;$2&quot; ]; \r\nthen\r\n    NUM_OF_SCREENSHOTS=$2\r\n    echo &quot;WARNING: Overwrite default number of screenshots to ${NUM_OF_SCREENSHOTS}.&quot;\r\n    sleep 3s\r\nfi\r\n\r\n# Get the total length of the video in seconds.\r\n#  Use mplayer to display the info of the video and then get the value of ID_LENGTH, the total number of seconds of the video.\r\n# \u8a33\uff09Mplayer\u3092\u4f7f\u3063\u3066\u3001\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u306e\u5c3a\u3092\u6e2c\u308b\u3088\u3002\r\n\r\ntotal_length=$(mplayer -identify -frames 0 -vc null -vo null -ao null &quot;$filename&quot; | grep ID_LENGTH | sed 's\/ID_LENGTH=\/\/' | sed 's\/\\..*\/\/')\r\n\r\n# Reference https:\/\/github.com\/mpv-player\/mpv\/blob\/master\/TOOLS\/mpv_identify.sh\r\n\r\n# Remove 4 seconds from the video so that it doesn't take screenshot at the ends.\r\n# \u672b\u5c3e\u304b\u30894\u79d2\u7aef\u6298\u308b\u3088\r\nlet total_length-=4\r\n\r\n# time_slice: At which time interval should mplayer take screenshots.\r\n# \u9593\u9694\u3092\u6c7a\u3081\u308b\u3088\r\nlet time_slice=${total_length}\/${NUM_OF_SCREENSHOTS}\r\n\r\n# time_at: When should mplayer take screenshots.\r\ntime_at=${time_slice};\r\n\r\n# Looping to take screenshots.\r\n# \u7b49\u9593\u9694\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u958b\u59cb\r\nfor ((i=1; i &lt;= NUM_OF_SCREENSHOTS ; i++))\r\ndo\r\n\r\n    # Take the screenshot.\r\n    #mplayer -loop 1 -nosound -frames 1 -ss ${time_at} -vo png:z=9 ${filename} #mplayer\u306e\u4eba\u306f\u3053\u3063\u3061\r\n    mpv --quiet --no-audio --vo=image --start=${time_at} --frames=1 &quot;$filename&quot; #mpv\u306e\u4eba\u306f\u3053\u3063\u3061\r\n    rename 's\/^&#x5B;0-9]+\/out'&quot;${time_at}&quot;'\/' 00000001.jpg\r\n\r\n    # Increment to the next time slice.\r\n    let time_at+=${time_slice}\r\n\r\ndone\r\n\r\nexit 0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3061\u3089http:\/\/askubuntu.com\/questions\/684834\/need-help-with-mpv-bash-script\u306eUbuntu\u7528\u306e\u56de\u7b54\u3092OSX\u3067\u4f7f\u3046\u3002 \u4f7f\u3046\u3082\u306e bash &#8211;\u672c\u4f53 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1956","post","type-post","status-publish","format-standard","hentry","category-usually"],"_links":{"self":[{"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1956"}],"version-history":[{"count":3,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1956\/revisions"}],"predecessor-version":[{"id":1965,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1956\/revisions\/1965"}],"wp:attachment":[{"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.white-room.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}