{"id":74,"date":"2024-08-30T03:09:05","date_gmt":"2024-08-30T03:09:05","guid":{"rendered":"https:\/\/kylehayhurst.com\/?p=74"},"modified":"2024-08-30T03:09:05","modified_gmt":"2024-08-30T03:09:05","slug":"using-ffmpeg-to-slice-a-video","status":"publish","type":"post","link":"https:\/\/kylehayhurst.com\/?p=74","title":{"rendered":"Using FFMPEG to Slice a Video"},"content":{"rendered":"\n<p>There&#8217;s plenty of software out there that will allow you to record a slice of a video. I like command line tools for this sort or thing because I find they often are a little more flexible and precise.<\/p>\n\n\n\n<p>I also hope to use some of these command line tools in a future automation. That will hopefully come in the near future.<\/p>\n\n\n\n<p>Assuming you have FFMPEG installed, you can create the following batch script:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-\">@echo off\nsetlocal\n\nREM Check if FFmpeg is installed\nwhere ffmpeg &gt;nul 2&gt;&amp;1\nif %errorlevel% neq 0 (\n    echo FFmpeg is not installed or not in PATH.\n    echo Please install FFmpeg and try again.\n    exit \/b\n)\n\nREM Check if enough parameters are provided\nif &quot;%~4&quot;==&quot;&quot; (\n    echo Usage: %0 input_video start_time clip_length output_video\n    exit \/b\n)\n\nREM Set input parameters\nset input_video=%1\nset start_time=%2\nset clip_length=%3\nset output_vid=%4\n\nffmpeg -ss %start_time% -i &quot;%input_video%&quot; -c copy -t %clip_length% &quot;%output_vid%&quot;\n\necho Video clip creation completed: %output_vid%\n<\/code><\/pre>\n\n\n\n<p>This is just a very simple script that will slice out a video from the given start time, and length you wish it to be. Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\\clip_video.bat &quot;.\\input.mp4&quot; 00:02:51.000 7 &quot;.\\output.mp4&quot;<\/code><\/pre>\n\n\n\n<p>The 3rd input there is the length of the video in case you were wondering. I&#8217;ll probably find some dynamic way of creating the output file so I didn&#8217;t bother trying to extract the extension to reuse. Also ffmpeg could probably save it as a different type, but I don&#8217;t care about that at the moment.<\/p>\n\n\n\n<p>Leave me a comment with any suggestions on how to improve this!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s plenty of software out there that will allow you to record a slice of a video. I like command line tools for this sort or thing because I find they often are a little more flexible and precise. I also hope to use some of these command line tools in a future automation. That [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":1,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kylehayhurst.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}