{"id":65,"date":"2011-03-28T17:40:51","date_gmt":"2011-03-28T16:40:51","guid":{"rendered":"http:\/\/hamsterhirn.de\/?p=65"},"modified":"2012-11-26T18:54:57","modified_gmt":"2012-11-26T17:54:57","slug":"videos-fur-youtube-splitten-mit-mplayer-und-ffmpeg-mit-einem-bash-script","status":"publish","type":"post","link":"https:\/\/hamsterhirn.de\/index.php\/2011\/03\/videos-fur-youtube-splitten-mit-mplayer-und-ffmpeg-mit-einem-bash-script\/","title":{"rendered":"Videos f\u00fcr YouTube splitten mit mplayer und ffmpeg mit einem bash script"},"content":{"rendered":"<blockquote><p><pre><code class=\"preserve-code-formatting\">&lt;pre&gt;\n#!\/bin\/bash\n# splits videos for youtube in ~15 minute parts\n\nif [ -z &quot;$1&quot; ];then\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;usage: $0 filename&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit\nfi\n\nFILENAME=$1\nNAME=$(echo &quot;$FILENAME&quot; | sed &#039;s\/\\.[^\\.]*$\/\/&#039;)\nEXTENSION=$(echo &quot;$FILENAME&quot; | sed &#039;s\/^.*\\.\/\/&#039;)\n# is the same as 00:14:55\nSPLITTIME=895\n# starts at 0 seconds\nSTARTTIME=0\n# runtime of the video file\n#RUNTIME=$(ffprobe -pretty &quot;$FILENAME&quot; 2&gt;&amp;1 | grep duration | sed -e &#039;1d&#039; | awk &#039;{ print $3 }&#039;)\nRUNTIME=$(mplayer -vo dummy -ao dummy -identify &quot;$FILENAME&quot; 2&gt;&amp;1 | grep ID_LENGTH | awk -F= &#039;{ print $2 }&#039; | sed &#039;s\/\\.[^\\.]*$\/\/&#039;)\nCOUNTER=1\n\nwhile [ $STARTTIME -lt $RUNTIME ];do\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ffmpeg -vcodec copy -i &quot;$FILENAME&quot; -ss $STARTTIME -t &quot;$SPLITTIME&quot; &quot;$NAME&quot;_part&quot;$COUNTER&quot;.&quot;$EXTENSION&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let COUNTER=COUNTER+1\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let STARTTIME+=$SPLITTIME\ndone&lt;\/pre&gt;<\/code><\/pre>\n<\/p><\/blockquote>\n<p>So schaut der Bash Code aus. Musste leider auch noch mplayer ben\u00fctzen weil ich mit ffprobe die Laufzeit der Datei nicht richtig herausfiltern konnte. Ansonsten das Script mit dem Videonamen als Parameter starten. Mit mplayer bekam ich nur asynchron gesplittete Dateien. Mit ffmpeg ging das besser. Au\u00dferdem sollte man beachten, dass man evtl. ffmpeg aus den Quellen kompilieren muss weil sonst m\u00f6glicherweise kein MP3, AAC, AMR, MPEG-4 und H.264 (bzw. MPEG-4 AVC) geht. Wie das gemacht wird findet man auf ( http:\/\/wiki.ubuntuusers.de\/ffmpeg )<\/p>\n<blockquote><p><code class=\"preserve-code-formatting\">.\/split_video.sh some_video.mp4<\/code><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>&lt;pre&gt; #!\/bin\/bash # splits videos for youtube in ~15 minute parts if [ -z &quot;$1&quot; ];then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;usage: $0 filename&quot; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit fi FILENAME=$1 NAME=$(echo &quot;$FILENAME&quot; | sed &#039;s\/\\.[^\\.]*$\/\/&#039;) EXTENSION=$(echo &quot;$FILENAME&quot; | sed &#039;s\/^.*\\.\/\/&#039;) # is the same as 00:14:55 SPLITTIME=895 # starts at 0 seconds STARTTIME=0 # runtime of the video file #RUNTIME=$(ffprobe -pretty &quot;$FILENAME&quot; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[38,37,39,36],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-it","tag-ffmpeg","tag-mplayer","tag-splitten","tag-youtube"],"_links":{"self":[{"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":7,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hamsterhirn.de\/index.php\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}