{"id":171239,"date":"2013-03-01T13:24:08","date_gmt":"2013-03-01T09:24:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=171239"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=171239","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432 \u0432\u0438\u0434\u0435\u043e\u0440\u043e\u043b\u0438\u043a\u0430 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c php5-ffmpeg<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u044e\u0442\u0443\u0431.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0441 \u0443\u0445\u043e\u0434\u043e\u043c ffmpeg \u0438\u0437 Ubuntu, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442 \u043d\u0430 \u0437\u0430\u043c\u0435\u043d\u0443 \u043c\u043e\u0434\u0443\u043b\u044e php5-ffmpeg? \u0421\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 PHP5, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u043c\u043e\u0434\u0443\u043b\u044c php5-ffmpeg, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0430\u044f \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f php5-ffmpeg \u0432 Ubuntu<\/p>\n<pre><code class=\"bash\">sudo apt-get install php5-ffmpeg <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<br \/>  $video \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0434\u043e (\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e) \u0432\u0438\u0434\u0435\u043e\u0440\u043e\u043b\u0438\u043a\u0430<br \/>  $screens_path \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0443\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b<br \/>  $screens_count \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432<\/p>\n<pre><code class=\"php\">function movie_progress($video,$screens_path = FALSE,$screens_count = 10) { \t$movie = new ffmpeg_movie($video); \tif ( ! $movie) \t{ \t\treturn; \t} \t$frame_count = $movie-&gt;getFrameCount(); \t\/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b \t$screens = FALSE; \tif ($screens_path) \t{ \t\t\/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u044b \t\t$step = floor($frame_count \/ ($screens_count)); \t\t$screens = array(); \t\t\/\/ \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b, \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \t\tfor ($i = $step; $i &lt; $frame_count; $i += $step) \t\t{ \t\t\t$filename = $path.md5(rand()).'.png'; \t\t\t$frame = $movie-&gt;getFrame($i); \t\t\t$image = $frame-&gt;toGDImage(); \t\t\timagepng($image,$filename); \t\t\tif (is_file($filename)) \t\t\t{ \t\t\t\t$screens[] = $filename; \t\t\t} \t\t} \t} \t\/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043a\u0440\u0438\u043d\u043e\u0432 \treturn array( \t\t'width' =&gt; $movie-&gt;getFrameWidth(), \/\/ \u0448\u0438\u0440\u0438\u043d\u0430 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 \t\t'height' =&gt; $movie-&gt;getFrameHeight(), \/\/ \u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 \t\t'frame_count' =&gt; $frame_count, \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0440\u0435\u0439\u043c\u043e\u0432 \t\t'bitrate' =&gt; $movie-&gt;getBitRate(), \/\/ \u0431\u0438\u0442\u0440\u0435\u0439\u0442 \t\t'video_bitrate' =&gt; $movie-&gt;getVideoBitRate(), \t\t'video_codec' =&gt; $movie-&gt;getVideoCodec(), \t\t'audio_codec' =&gt; $movie-&gt;getAudioCodec(), \t\t'screens' =&gt; $screens, \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430\u043c\u0438 \t); } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b $movie-&gt;getAuthor(), $movie-&gt;getCopyright(), $movie-&gt;getArtist(), $movie-&gt;getGenre() \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u043c\u043d\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435, \u043d\u0435 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 PHP.<\/p>\n<p>  \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"http:\/\/ffmpeg-php.sourceforge.net\/doc\/api\/index.php\">ffmpeg-php.sourceforge.net\/doc\/api\/index.php<\/a>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/171239\/\"> http:\/\/habrahabr.ru\/post\/171239\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u044e\u0442\u0443\u0431.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0441 \u0443\u0445\u043e\u0434\u043e\u043c ffmpeg \u0438\u0437 Ubuntu, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442 \u043d\u0430 \u0437\u0430\u043c\u0435\u043d\u0443 \u043c\u043e\u0434\u0443\u043b\u044e php5-ffmpeg? \u0421\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 PHP5, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u043c\u043e\u0434\u0443\u043b\u044c php5-ffmpeg, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0430\u044f \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-171239","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/171239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171239"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/171239\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}