{"id":727,"date":"2017-02-26T15:18:48","date_gmt":"2017-02-26T14:18:48","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=727"},"modified":"2017-02-26T15:18:48","modified_gmt":"2017-02-26T14:18:48","slug":"kdenlive-audacity-and-lessons-in-audio-sync","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2017\/02\/kdenlive-audacity-and-lessons-in-audio-sync\/","title":{"rendered":"kdenlive, audacity and lessons in audio sync"},"content":{"rendered":"<p>During the last <a href=\"http:\/\/foss-gbg.se\/\">foss-gbg<\/a> meeting I tried filming the entire event. The idea is to produce videos of each talk and publish them on YouTube. Since I&#8217;m lazy, I simply put up a camera on a tripod and recorder the whole event, some 3h and 16 minutes and a few seconds. A few seconds that would cause me quite some pain, it turns out.<\/p>\n<p>All started with me realizing that I can hear the humming sound of the AC system in the video. No problem, simply use ffmpeg to separate the audio from the video and use the noise reduction filter in <a href=\"http:\/\/www.audacityteam.org\/\">Audacity<\/a>. However, when putting it all together I recognized a sound sync drift (after 6h+ of rendering videos, that is).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-728\" src=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2017\/02\/20170222_172133-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2017\/02\/20170222_172133-300x225.jpg 300w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2017\/02\/20170222_172133-768x576.jpg 768w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2017\/02\/20170222_172133-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>ffprobe told me that the video is\u00a003:16:07.58 long, while the extracted audio is\u00a003:16:04.03. This means that the video of the last speaker drifts more than 3s &#8211; unwatchable. So, googling for a solution, I realized that I will have to try to stretch the audio to the same duration as the video. Audacity has a tempo effect to do this, but I could not get the UI to accept my very small adjustment in tempo (or my insane number of seconds in the clip). Instead, I had to turn to ffmpeg and the atempo filter.<\/p>\n<pre>ffmpeg -i filtered.ac3 -filter:a \"atempo=0.9996983236995207\" -vn slower.ac3<\/pre>\n<p>This resulted in an audio clip of the correct length. (By the way, the factor is the difference in length of the audio and video).<\/p>\n<p>Back to <a href=\"https:\/\/kdenlive.org\/\">kdenlive<\/a> &#8211; I imported the video clip, put it on the time line, separated the audio and video (just a right click away), ungrouped them, removed the audio, added the filtered, slowed down audio, grouped it with the video and everything seems nice. I about 1h43 I will know when the first clip has been properly rendered :-)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During the last foss-gbg meeting I tried filming the entire event. The idea is to produce videos of each talk and publish them on YouTube. Since I&#8217;m lazy, I simply put up a camera on a tripod and recorder the whole event, some 3h and 16 minutes and a few seconds. A few seconds that &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2017\/02\/kdenlive-audacity-and-lessons-in-audio-sync\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">kdenlive, audacity and lessons in audio sync<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,11],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-foss-gbg","category-kde"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":1,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":729,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/727\/revisions\/729"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}