{"id":1127,"date":"2020-11-18T00:36:06","date_gmt":"2020-11-18T06:36:06","guid":{"rendered":"https:\/\/tech.poojanblog.com\/blog\/?p=1127"},"modified":"2020-11-18T01:30:16","modified_gmt":"2020-11-18T07:30:16","slug":"splitting-up-a-zoom-video-file","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/desk\/splitting-up-a-zoom-video-file\/","title":{"rendered":"Splitting up a Zoom Video File"},"content":{"rendered":"\n<p>I recently helped out with my wife&#8217;s writing conference. During this conference, they recorded <a href=\"https:\/\/www.vanessabrantleynewton.com\/\">Vanessa Brantley Newton<\/a> doing 1:1 critiques with authors and illustrators.<\/p>\n\n\n\n<p>The conference organizers (my wife and her co-leads) offered the attendees individual recordings of their critiques. So, I had to take the overall zoom download and split it up.<\/p>\n\n\n\n<p>There were a number of files available from Zoom, but the main ones I was interested in seem to be <code>GMT&lt;datetime&gt;_&lt;username&gt;-_1920x1040.mp4<\/code> and <code>GMT&lt;datetime&gt;_&lt;username&gt;-_gallery_1920x1040.mp4<\/code>. The first had a &#8220;speaker&#8221; view and the second had a &#8220;gallery&#8221; view. (In both views, screen sharing took the whole screen, and the speaker was reduced to a window.)<\/p>\n\n\n\n<p>The hardest part was finding the time points to split the files up&#8211;a little bit because it was a manual process, but more importantly, because it was difficult for me not to get engrossed in the discussion. While illustration isn&#8217;t my cup of tea, it is intriguing watching someone deliver constructive feedback.<\/p>\n\n\n\n<p>Anyway, once I had these time segments recorded, I had a few ways to split them up:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>MKToolnix: this worked well, but only outputs Matroska (MKV) files. I wasn&#8217;t sure if this would be accessable to the people downloading the files.<\/li><li>FFMPEG: it took a while to figure out the syntax, but this could spit out mp4 files, and can copy direct from input to output, so executes very fast.<\/li><\/ol>\n\n\n\n<p>For #1, I used the MKToolnix GUI. It seemed to work OK, but I did not pursue it very far.<\/p>\n\n\n\n<p>For #2, I used the following (Unix) command line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ffmpeg -i ..\/GMT20201115-172325_poojan-_gallery_1920x1040.mp4 -c copy -map 0 -segment_times 4:48,21:40,37:23,37:53,52:10,52:33,1:07:45,1:09:20,1:22:40,1:23:13,1:36:27 -f segment -reset_timestamps 1 -segment_list_type csv -segment_list 'gallery.csv' 'gallery-%1d.mp4<\/pre>\n\n\n\n<p>This worked OK, except I found that the timing swere off. I said to cut the 1st segment at 4:48 (4 minutes 48 seconds), but it ended up being a bit later (at 4:52). This wasn&#8217;t a big deal, except the timing at 21:40 ended up also being later, and the 1st file included a tiny bit of discussion about the 2nd person.<\/p>\n\n\n\n<p>The reason for this timing uncertainty is that ffmpeg can&#8217;t really break up a file at an arbitrary location. Since the video codecs are incremental&#8211;that is, each frame depends on the previous frame, you can&#8217;t just arbitrary break the stream at any point. You can only break it on what are called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Video_compression_picture_types#Intra-coded_(I)_frames\/slices_(key_frames)\">key frames<\/a>&#8211;points in the stream where the entire image is sent. Unfortunately, the placement of these frames does not line up with where I want them.<\/p>\n\n\n\n<p>I even tried trimming some of the post-critique banter by following the above command with:<\/p>\n\n\n\n<p>ffmpeg -y -i gallery-1.mp4 -c copy -map 0 -t 16:32 &#8220;Person 1 &#8211; Gallery View.mp4&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:default decode:true\">ffmpeg -y -i gallery-1.mp4 -c copy -map 0 -t 16:32 \"Person 1 - Gallery View.mp4\"<\/pre>\n\n\n\n<p>This forces a truncation of the 1st segment after 16:32 (16 minutes 32 seconds). While I can&#8217;t pick where this segment starts, I can truncate it anywhere I want.<\/p>\n\n\n\n<p>Unfortunately, the only way to split at arbitrary points is to decode and re-encode the whole video stream. (The audio can still be copied.) I used the following command to do so:<\/p>\n\n\n\n<pre class=\"wp-block-code lang:default decode:true\"><code>ffmpeg -i ..\/GMT20201115-172325_poojan-_gallery_1920x1040.mp4 -c:v libx264 -c:a copy -segment_times 4:48,21:40,37:23,37:53,52:10,52:33,1:07:45,1:09:20,1:22:40,1:23:13,1:36:27 -f segment -reset_timestamps 1 -segment_list_type csv -segment_list 'gallery.csv' 'gallery-%1d.mp4' <\/code><\/pre>\n\n\n\n<p>This works well, but is much slower. While it runs 9x the frame rate on my Unix server, the copy version is much faster.<\/p>\n\n\n\n<p>This works well, but is much slower. While it runs 9x the frame rate on my Unix server, the copy version is much faster.<\/p>\n\n\n\n<p>I also tried to use the nVidia-accelerated ffmpeg on my Windows PC (with GTX 1050 Ti):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i ..\\GMT20201115-172325_wisconsin-_gallery_1920x1040.mp4 -c:v h264_nvenc -c:a copy -segment_times 4:48,21:40,22:04,37:23,37:53,52:10,52:33,1:07:45,1:09:20,1:22:40,1:23:13,1:36:27 -f segment -reset_timestamps 1 -segment_list_type csv -segment_list \"gallery.csv\" \"gallery-%%2d.mp4\"<\/code><\/pre>\n\n\n\n<p>With GPU acceleration, this 2nd verison runs at 20x the frame rate. So, for having to do a pointless encoding, it&#8217;s not so bad.<\/p>\n\n\n\n<p>Edit: one more quirk. It seems like the GPU-accelerated (Windows version) of ffmpeg creates output that is always a multiple of 10 seconds in length. I&#8217;m not sure if this is a limitation of key frames in the output stream using the Nvidia CUDA-based encoder.<\/p>\n<\/p><div class='wp_likes' id='wp_likes_post-1127'><a class='like' href=\"javascript:wp_likes.like(1127);\" title='' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>Be the first to like.<\/span><div class='like' ><a href=\"javascript:wp_likes.like(1127);\">Like<\/a><\/div><div class='unlike' ><a href=\"javascript:wp_likes.unlike(1127);\">Unlike<\/a><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>I recently helped out with my wife&#8217;s writing conference. During this conference, they recorded Vanessa Brantley Newton doing 1:1 critiques with authors and illustrators. The conference organizers (my wife and her co-leads) offered the attendees individual recordings of their critiques. So, I had to take the overall zoom download and split it up. There were [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[38],"tags":[258,255,256,257],"class_list":["post-1127","post","type-post","status-publish","format-standard","hentry","category-desk","tag-command-line","tag-ffmpeg","tag-mkvtoolinx","tag-video-editing"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=1127"}],"version-history":[{"count":10,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1127\/revisions"}],"predecessor-version":[{"id":1137,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1127\/revisions\/1137"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=1127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=1127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=1127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}