{"id":771,"date":"2018-01-31T15:54:49","date_gmt":"2018-01-31T20:54:49","guid":{"rendered":"http:\/\/main.jmah.net\/?p=771"},"modified":"2021-05-09T13:28:20","modified_gmt":"2021-05-09T17:28:20","slug":"correcting-for-audio-video-sync-issues","status":"publish","type":"post","link":"https:\/\/main.jmah.net\/?p=771","title":{"rendered":"Correcting for audio\/video sync issues"},"content":{"rendered":"<p><a href=\"http:\/\/main.jmah.net\/?attachment_id=714\" rel=\"attachment wp-att-714\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-714\" src=\"http:\/\/main.jmah.net\/wp-content\/uploads\/2017\/01\/ffmpeg-e1484897077295.jpg\" alt=\"\" width=\"300\" height=\"168\" \/><\/a>Due to various reasons, the audio and video tracks sometimes may become out-of-sync in a video clip, i.e. there are some delay between the tracks affecting the overall viewing experience. Use the following as examples to fix the issue.<\/p>\n<p><strong>CASE 1<\/strong>: Audio happens before video (aka \u201cneed to delay audio stream 1\u201d):<\/p>\n<p><strong>ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output.mp4<\/strong><\/p>\n<p>The \u201citsoffset\u201d in the above example is placed before file 1 (remember that linux counts from 0, so 0 is the first and 1 is the second), so when the mapping happens, it says \u201cTake the video of file 0 and the audio of file 1, leave the video of file 0 alone and apply the offset to the audio of file 1 and merge them into a new output file\u201d. The delay is only .15 seconds.<\/p>\n<p><strong>CASE 2<\/strong>: Video happens before audio (aka \u201cneed to delay video stream 0\u201d):<\/p>\n<p><strong>ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:1 -map 1:0 output.mp4<\/strong><\/p>\n<p>The \u201citsoffset\u201d in the above example is placed before file 1. When the mapping happens, it says \u201cTake the audio of file 0 and the video of file 1, leave the audio of file 0 alone and apply the offset to the video of file 1 and merge them into a new output file\u201d. The delay is only .15 seconds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Due to various reasons, the audio and video tracks sometimes may become out-of-sync in a video clip, i.e. there are some delay between the tracks affecting the overall viewing experience. Use the following as examples to fix the issue. CASE &hellip; <a href=\"https:\/\/main.jmah.net\/?p=771\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7],"tags":[],"class_list":["post-771","post","type-post","status-publish","format-standard","hentry","category-ffmpeg","category-research-information-technology"],"_links":{"self":[{"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/posts\/771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/main.jmah.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=771"}],"version-history":[{"count":1,"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/posts\/771\/revisions"}],"predecessor-version":[{"id":772,"href":"https:\/\/main.jmah.net\/index.php?rest_route=\/wp\/v2\/posts\/771\/revisions\/772"}],"wp:attachment":[{"href":"https:\/\/main.jmah.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/main.jmah.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/main.jmah.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}