{"id":9520,"date":"2020-10-09T07:54:16","date_gmt":"2020-10-09T07:54:16","guid":{"rendered":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=9520"},"modified":"2020-10-10T16:45:53","modified_gmt":"2020-10-10T16:45:53","slug":"%e6%90%ba%e5%b8%af%e3%81%aa%e3%81%a9%e3%81%ae%e7%b8%a6%e9%95%b7%e5%8b%95%e7%94%bb%e3%82%92ffmpeg%e3%81%a7%e6%89%b1%e3%81%86","status":"publish","type":"post","link":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=9520","title":{"rendered":"\u643a\u5e2f\u306a\u3069\u306e\u7e26\u9577\u52d5\u753b\u3092ffmpeg\u3067\u6271\u3046"},"content":{"rendered":"<p><a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2020\/10\/20201009a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2020\/10\/20201009a.png\" alt=\"\" width=\"280\" height=\"179\" class=\"aligncenter size-full wp-image-9524\" \/><\/a><br \/>\n\u643a\u5e2f\u3067\u64ae\u5f71\u3057\u305f\u52d5\u753b\u3067\u3001\u7e26\u9577\u306e\u52d5\u753b\u306b\u3064\u3044\u3066\u8abf\u3079\u305f\u3053\u3068\u3092\u8a18\u9332\u3057\u307e\u3059\u3002<\/p>\n<p>\u3000\u7e26\u52d5\u753b\u3092\u3001VLC \u30d7\u30ec\u30a4\u30e4\u30fc\u306a\u3069\u3067\u518d\u751f\u3059\u308b\u3068\u3001\u7279\u306b\u554f\u984c\u306a\u304f\u518d\u751f\u3067\u304d\u307e\u3059\u3002\u52d5\u753b\u306e\u60c5\u5831\u3092 ffprobe \u3067\u8aad\u307f\u53d6\u3063\u3066\u307f\u308b\u3068\u3001\u4f8b\u3048\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306a\u51fa\u529b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code style=\"color:midnightblue; font-size:12px;white-space:pre-wrap\">$ ffprobe -hide_banner -v error -show_streams -print_format json -i friend1602229681823.mov \r\n{\r\n    \"streams\": [\r\n        {\r\n            \"index\": 0,\r\n            \"codec_name\": \"aac\",\r\n            \"codec_long_name\": \"AAC (Advanced Audio Coding)\",\r\n            \"profile\": \"LC\",\r\n            \"codec_type\": \"audio\",\r\n            \"codec_time_base\": \"1\/44100\",\r\n            \"codec_tag_string\": \"mp4a\",\r\n            \"codec_tag\": \"0x6134706d\",\r\n            \"sample_fmt\": \"fltp\",\r\n            \"sample_rate\": \"44100\",\r\n            \"channels\": 1,\r\n            \"channel_layout\": \"mono\",\r\n            \"bits_per_sample\": 0,\r\n            \"r_frame_rate\": \"0\/0\",\r\n            \"avg_frame_rate\": \"0\/0\",\r\n            \"time_base\": \"1\/44100\",\r\n            \"start_pts\": 0,\r\n            \"start_time\": \"0.000000\",\r\n            \"duration_ts\": 526336,\r\n            \"duration\": \"11.935057\",\r\n            \"bit_rate\": \"87244\",\r\n            \"max_bit_rate\": \"96000\",\r\n            \"nb_frames\": \"514\",\r\n            \"disposition\": {\r\n                \"default\": 1,\r\n                \"dub\": 0,\r\n                \"original\": 0,\r\n                \"comment\": 0,\r\n                \"lyrics\": 0,\r\n                \"karaoke\": 0,\r\n                \"forced\": 0,\r\n                \"hearing_impaired\": 0,\r\n                \"visual_impaired\": 0,\r\n                \"clean_effects\": 0,\r\n                \"attached_pic\": 0\r\n            },\r\n            \"tags\": {\r\n                \"creation_time\": \"2020-10-09 07:47:59\",\r\n                \"language\": \"und\",\r\n                \"handler_name\": \"Core Media Data Handler\"\r\n            }\r\n        },\r\n        {\r\n            \"index\": 1,\r\n            \"codec_name\": \"h264\",\r\n            \"codec_long_name\": \"H.264 \/ AVC \/ MPEG-4 AVC \/ MPEG-4 part 10\",\r\n            \"profile\": \"High\",\r\n            \"codec_type\": \"video\",\r\n            \"codec_time_base\": \"1\/1200\",\r\n            \"codec_tag_string\": \"avc1\",\r\n            \"codec_tag\": \"0x31637661\",\r\n            \"width\": 1280,\r\n            \"height\": 720,\r\n            \"coded_width\": 1280,\r\n            \"coded_height\": 720,\r\n            \"has_b_frames\": 0,\r\n            \"sample_aspect_ratio\": \"0:1\",\r\n            \"display_aspect_ratio\": \"0:1\",\r\n            \"pix_fmt\": \"yuv420p\",\r\n            \"level\": 31,\r\n            \"color_range\": \"tv\",\r\n            \"color_space\": \"bt709\",\r\n            \"color_transfer\": \"bt709\",\r\n            \"color_primaries\": \"bt709\",\r\n            \"chroma_location\": \"left\",\r\n            \"refs\": 2,\r\n            \"is_avc\": \"1\",\r\n            \"nal_length_size\": \"4\",\r\n            \"r_frame_rate\": \"30000\/1001\",\r\n            \"avg_frame_rate\": \"106800\/3563\",\r\n            \"time_base\": \"1\/600\",\r\n            \"start_pts\": 0,\r\n            \"start_time\": \"0.000000\",\r\n            \"duration_ts\": 7126,\r\n            \"duration\": \"11.876667\",\r\n            \"bit_rate\": \"2560888\",\r\n            \"bits_per_raw_sample\": \"8\",\r\n            \"nb_frames\": \"356\",\r\n            \"disposition\": {\r\n                \"default\": 1,\r\n                \"dub\": 0,\r\n                \"original\": 0,\r\n                \"comment\": 0,\r\n                \"lyrics\": 0,\r\n                \"karaoke\": 0,\r\n                \"forced\": 0,\r\n                \"hearing_impaired\": 0,\r\n                \"visual_impaired\": 0,\r\n                \"clean_effects\": 0,\r\n                \"attached_pic\": 0\r\n            },\r\n            \"tags\": {\r\n                \"rotate\": \"90\",\r\n                \"creation_time\": \"2020-10-09 07:47:59\",\r\n                \"language\": \"und\",\r\n                \"handler_name\": \"Core Media Data Handler\",\r\n                \"encoder\": \"H.264\"\r\n            },\r\n            \"side_data_list\": [\r\n                {\r\n                    \"side_data_type\": \"Display Matrix\",\r\n                    \"side_data_size\": 36,\r\n                    \"displaymatrix\": \"\\n00000000:            0       65536           0\\n00000001:       -65536           0           0\\n00000002:     47185920           0  1073741824\\n\",\r\n                    \"rotation\": -90\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}<\/code><\/pre>\n<p>width \u304c 1280 \u3067\u3001height \u304c 720 \u3067\u3001\u6a2a\u9577\u306e\u30b5\u30a4\u30ba\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u305b\u3044\u3067\uff0cffmpeg \u3067\u52d5\u753b\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u304d\u306b\uff0c\u5b9f\u969b\u306e\u7e26\u3068\u6a2a\u304c\u7570\u306a\u308b\u3082\u306e\u3067\u3059\u304b\u3089\uff0c\u5999\u306b\u6a2a\u306b\u5f15\u304d\u4f38\u3070\u3055\u308c\u305f\u52d5\u753b\u304c\u51fa\u6765\u4e0a\u304c\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3053\u308c\u306f\u4f55\u304b\u306e\u30d0\u30b0\u306a\u3093\u3060\u308d\u3046\u304b\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001ubuntu16 \u3067\u306e\u7e26\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30a4\u30b3\u30f3\u8868\u793a\u306f\u4e0b\u56f3\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2020\/10\/20201009b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/wp-content\/uploads\/2020\/10\/20201009b.png\" alt=\"\" width=\"143\" height=\"179\" class=\"aligncenter size-full wp-image-9528\" \/><\/a><\/p>\n<p>\u3053\u308c\u306f\u52d5\u753b\u304c\u6a2a\u306b\u306a\u3063\u3066\u3044\u308b\u611f\u3058\u306e\u8868\u793a\u3067\u3059\u3002\u3053\u308c\u3092\u898b\u3066\uff08\u78ba\u8a8d\u306f\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3059\u304c\uff09\u30c7\u30fc\u30bf\u305d\u306e\u3082\u306e\u306f\u3053\u306e\u30a2\u30a4\u30b3\u30f3\u306e\u3088\u3046\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u63a8\u6e2c\u3057\u307e\u3057\u305f\u3002\u305f\u3060 VLC \u30d7\u30ec\u30a4\u30e4\u30fc\u7b49\u304c\u518d\u751f\u3059\u308b\u3068\u304d\u306b\u306f\u3001\u3053\u308c\u3092\u56de\u8ee2\u3055\u305b\u3066\u8868\u793a\u3055\u305b\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002ffprobe \u3067\u3082\u5f97\u3089\u308c\u308b tags:rotate:90 \u3092\u8aad\u307f\u53d6\u3063\u3066\u3001\u56de\u8ee2\u3055\u305b\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u305d\u308c\u3067\u3053\u306e\u3088\u3046\u306a\u7e26\u52d5\u753b\u3092 ffmpeg \u3067\u5909\u63db\u3059\u308b\u6642\u306b\u306f\u3001rotate:90 \u3068 rotate:270 \u3067\u3042\u308c\u3070\u3001width \u3068 height \u3092\u5165\u308c\u66ff\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre><code style=\"color:midnightblue; font-size:12px;white-space:pre-wrap\">$tmp=\"ffprobe -v quiet -hide_banner -show_streams -print_format json $filename\";\r\n\r\n$str = shell_exec($tmp);\r\n$tmpjson = json_decode($str,true);\r\n\r\n\/\/ video \u304c streams \u306e0\u304b1\u306b\u3042\u308b\u3068\u4eee\u5b9a\u3057\u3066\u3044\u308b \r\n\r\nif ($tmpjson['streams'][0]['codec_type'] == \"video\") {\r\n\t$streamsNumber = 0;\r\n} else {\r\n\t$streamsNumber = 1;\r\n}\r\n\r\n$a_codec = $tmpjson['streams'][$streamsNumber]['codec_name'];\r\n$a_width = $tmpjson['streams'][$streamsNumber]['width'];\r\n$a_height = $tmpjson['streams'][$streamsNumber]['height'];\r\n$a_fps = $tmpjson['streams'][$streamsNumber]['r_frame_rate'];\r\n\r\n\/\/ \u56de\u8ee2\u3092\u8abf\u3079\u308b\r\n\r\nif ($tmpjson['streams'][$streamsNumber]['tags']['rotate']) {\r\n\t$a_rotate = $tmpjson['streams'][$streamsNumber]['tags']['rotate'];\r\n} else {\r\n\t$a_rotate = '0';\r\n}\r\n\r\nif (($a_rotate == '90') || ($a_rotate == '270')) {\r\n\t$tmp = $a_width;\r\n\t$a_width = $a_height;\r\n\t$a_height = $tmp;\r\n}<\/code><\/pre>\n<p>\u30b5\u30a4\u30ba\u3092\u5909\u3048\u3066 ffmpeg \u3067\u66f8\u304d\u51fa\u3057\u3066\u307f\u308b\u3068 ubuntu16 \u3067\u3082\u7e26\u9577\u306e\u30a2\u30a4\u30b3\u30f3\u306b\u5909\u308f\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u643a\u5e2f\u3067\u64ae\u5f71\u3057\u305f\u52d5\u753b\u3067\u3001\u7e26\u9577\u306e\u52d5\u753b\u306b\u3064\u3044\u3066\u8abf\u3079\u305f\u3053\u3068\u3092\u8a18\u9332\u3057\u307e\u3059\u3002 \u3000\u7e26\u52d5\u753b\u3092\u3001V &#8230; <a class=\"more-link\" href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=9520\">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-9520","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\/9520","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=9520"}],"version-history":[{"count":13,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/9520\/revisions"}],"predecessor-version":[{"id":9536,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/9520\/revisions\/9536"}],"wp:attachment":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9520"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}