{"id":10716,"date":"2021-12-13T00:32:11","date_gmt":"2021-12-13T00:32:11","guid":{"rendered":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=10716"},"modified":"2021-12-28T01:34:22","modified_gmt":"2021-12-28T01:34:22","slug":"20211213-%e4%bd%9c%e6%a5%ad%e3%83%a1%e3%83%a2-python-%e3%81%a8-ffmpeg-%e3%82%92%e6%8b%85%e5%bd%93%e3%81%99%e3%82%8b%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc","status":"publish","type":"post","link":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=10716","title":{"rendered":"(20211213 \u4f5c\u696d\u30e1\u30e2) python \u3068 ffmpeg \u3092\u62c5\u5f53\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3066\u308b"},"content":{"rendered":"<p>\u3000\u5148\u306b python \u3092\u5b9f\u884c\u3059\u308b\u306e\u306b <a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=10627\">wsgi \u3092\u5229\u7528\u3059\u308b\u8a18\u4e8b<\/a>\u3092\u66f8\u304d\u307e\u3057\u305f\u3002\u7d50\u5c40 \u3053\u306e wsgi \u306f\u72ec\u7acb\u3057\u305f\u4eee\u60f3\u3067\u306a\u3044\u30b5\u30fc\u30d0\u30fc\u3067\u52d5\u304b\u3059\u4e88\u5b9a\u3067\u3059\u3002\u51e6\u7406\u304c\u3060\u3044\u305f\u3044\u306f\u901f\u304f\u306a\u308b\u306e\u3068\u3001\u3053\u306e\u5148\u30d3\u30c7\u30aa\u30ab\u30fc\u30c9\u306e\u6f14\u7b97\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u3068\u306a\u308b\u3068\u3001\u4eca\u306e\u3068\u3053\u308d\u4eee\u60f3\u3067\u306f\u96e3\u3057\u3044\u306e\u3067\u5b9f\u4f53\u306e\u3042\u308b\u30b5\u30fc\u30d0\u30fc\u3092\u4e00\u53f0\u7528\u610f\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3000\u30d3\u30c7\u30aa\u30ab\u30fc\u30c9\uff08geforce GTX 1050\uff09\u3092\u523a\u3057\u305f\u30d1\u30bd\u30b3\u30f3\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002\u3064\u3044\u3067\u306b\u3001 ffmpeg \u3082\u52d5\u304b\u3057\u3066\u52d5\u753b\u306e\u5909\u63db\u51e6\u7406\u3082\u3053\u306e\u30b5\u30fc\u30d0\u30fc\u3067\u62c5\u5f53\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3067\u3059\u3002\u30d3\u30c7\u30aa\u30ab\u30fc\u30c9\u306e\u30a2\u30af\u30bb\u30e9\u30ec\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092 ffmpeg \u3067\u5229\u7528\u3059\u308b\u4ef6\u306f<a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=10675\">\u5148\u65e5\u306e\u8a18\u4e8b<\/a>\u306b\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3000\u307e\u305a\u306f\u5b9f\u4f53\u30b5\u30fc\u30d0\u30fc\u3078\u52d5\u753b\u30c7\u30fc\u30bf\u3092\u8ee2\u9001\u3057\u307e\u3059\u3002\u3053\u308c\u306f base64 \u5909\u63db\u3055\u308c\u305f\u30c6\u30ad\u30b9\u30c8\u30c7\u30fc\u30bf\u3067\u3059\u3002\u9001\u53d7\u4fe1\u306f PHP \u3092\u5229\u7528\u3057\u307e\u3059\u3002\u30b5\u30a4\u30ba\u304c 200MB \u8d85\u3068\u5927\u304d\u3044\u306e\u3067\u3001\u53d7\u3051\u53d6\u308b\u5074\u306e PHP \u306e\u74b0\u5883\u5909\u6570\u3092\u5909\u66f4\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u6700\u5927\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30b5\u30a4\u30ba\u3084 PHP \u81ea\u8eab\u304c\u5229\u7528\u3059\u308b\u30e1\u30e2\u30ea\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3057\u307e\u3059\u3002200MB \u7a0b\u5ea6\u306e base64 \u30c7\u30fc\u30bf\u3092\u30d0\u30a4\u30ca\u30ea\u30fc\u30c7\u30fc\u30bf\u306b\u5909\u63db\u3059\u308b\u3068\u304d\u306b\u306f\u3001\u78ba\u304b 1GB \u7a0b\u5ea6\u306e\u30e1\u30e2\u30ea\u30fc\u304c\u5fc5\u8981\u3068\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u4ed6\u306b\u306f php-mbstring \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3082\u5fc5\u8981\u3067\u3057\u305f\u3002\u591a\u5206\u4ed6\u306b\u3082\u3042\u308a\u305d\u3046\u3067\u3059\u3002Moodle \u306a\u3069\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30b5\u30fc\u30d0\u30fc\u306a\u3089\u3059\u3067\u306b\u5165\u3063\u3066\u3044\u308b\u3082\u306e\u306a\u306e\u3067\u3057\u3087\u3046\u3051\u3069\u3002<\/p>\n<p>\u3000\u30c7\u30fc\u30bf\u30b5\u30a4\u30ba\u306e\u5927\u304d\u3055\u304b\u3089\u3001\u5148\u65e5\u306e\u8a18\u4e8b\u3068\u306f\u9055\u3063\u3066 POST \u3067\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3057\u307e\u3059\u3002\u5927\u4f53\u306e\u30b3\u30fc\u30c9\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\uff08<a href=\"https:\/\/so-zou.jp\/web-app\/tech\/programming\/php\/network\/http\/request\/\">\u53c2\u8003\u30b5\u30a4\u30c8<\/a>\uff09\u3002\u30b3\u30fc\u30c9\u3067\u306f\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u3092\u9001\u4fe1\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">&lt;?php\r\n$fileName = &quot;xxxxxx.mp4&quot;; \r\n$tmpbinary = file_get_contents($fileName);\r\n$strBase64 = base64_encode($tmpbinary);\r\n\r\n$postdata = http_build_query(\r\n\tarray(\r\n\t\t'fileName' =&gt; $fileName,\r\n\t\t'base64data' =&gt; $strBase64\r\n\t)\r\n);\r\n\r\n$headers = array(\r\n    'Content-Type: application\/x-www-form-urlencoded',\r\n    'Content-Length: '.strlen($postdata)\r\n    );\r\n\r\n$context = stream_context_create([\t\r\n\t'http' =&gt; ['method'  =&gt; 'POST',\r\n\t\t'header'=&gt;implode( &quot;\\r\\n&quot;, $headers),\r\n\t\t'ignore_errors' =&gt; true,\r\n\t\t'content' =&gt; $postdata\r\n\t]\t\r\n]);\r\n\r\n$res = file_get_contents(&quot;http:\/\/xxx.xxx.xxx.xxx\/xxx.php&quot;, false, $context);\r\n\r\nif (strpos($http_response_header[0], '200') !== false) {\r\n\techo $res . &quot;\\n&quot;;\t\r\n} else {\r\n\t$res = false;\r\n\techo 'false' . &quot;\\n&quot;;\t\r\n}\r\n?&gt;<\/code><\/pre>\n<p>\u8fd4\u4e8b\u306f\u7e26\u6a2a\u306e\u30d4\u30af\u30bb\u30eb\u30b5\u30a4\u30ba\u3084\u6642\u9593\u3001\u304a\u3088\u3073\u753b\u8cea\u8abf\u6574\u3055\u308c\u305f\u52d5\u753b\u306e\u30c7\u30fc\u30bf\uff08base64\uff09\u3092\u53d7\u3051\u53d6\u308b\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n<p>\u53d7\u3051\u53d6\u308b\u65b9\u3067\u3059\u304c\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002\u53d7\u3051\u53d6\u308b\u3068\u3053\u308d\u3057\u304b\u66f8\u3044\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<pre><code style=\"color: midnightblue; font-size: 12px; white-space: pre-wrap;\">&lt;?php\r\n\r\n$fileName = $_POST['fileName'];\r\n$base64data = $_POST['base64data'];\r\n\r\n$movie = base64_decode($base64data);\r\n\r\n$a_file = fopen(&quot;\/var\/www\/html\/xxxxxx\/$fileName&quot;,&quot;w&quot;);\r\nfwrite($a_file,$movie);\r\nfclose($a_file);\r\n\r\necho &quot;success! \\n&quot;;\r\n\r\n?&gt;<\/code><\/pre>\n<p>\u3053\u306e\u3042\u3068\u52d5\u753b\u5909\u63db\u306a\u3069\u306e\u30b3\u30fc\u30c9\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u7701\u7565\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u5148\u306b python \u3092\u5b9f\u884c\u3059\u308b\u306e\u306b wsgi \u3092\u5229\u7528\u3059\u308b\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u3002\u7d50\u5c40 &#8230; <a class=\"more-link\" href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=10716\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10716","post","type-post","status-publish","format-standard","hentry","category-column"],"_links":{"self":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10716"}],"version-history":[{"count":30,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10716\/revisions"}],"predecessor-version":[{"id":10748,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/10716\/revisions\/10748"}],"wp:attachment":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10716"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}