Jump to content

Archive:Kdenlive/Manual/Useful Information/Surround Sound: Difference between revisions

From KDE Wiki Sandbox
Claus chr (talk | contribs)
m Claus chr moved page Kdenlive/Manual/Useful Information/Surround Sound to Archive:Kdenlive/Manual/Useful Information/Surround Sound without leaving a redirect: Part of translatable page "Kdenlive/Manual/Useful Information/Surround Sound"
 
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{construction}}
<languages/>


=Editing Surround Sound with Kdenlive=
<translate>
===Editing Surround Sound with Kdenlive=== <!--T:1-->


At the time of writing, '''Kdenlive''' can only handle stereo (two channel) audio tracks. There is limited support for more than two channels, but in order to edit and create surround sound, some manual steps including external tools are required.
<!--T:2-->
At the time of writing, '''Kdenlive''' only supports rendering a project to a video containing stereo audio. It is not possible to render to more audio channels or to explicitly map audio tracks to channels in the rendered audio. In order to edit and create surround sound, some manual steps, including external tools, are required.


This guide is using a six-channel 5.1 surround sound as example.
<!--T:3-->
This guide is using a 6 channel 5.1 surround sound as example.


==External Tools Used Here==
====External Tools Used Here==== <!--T:4-->


<!--T:5-->
*[http://audacity.sourceforge.net/ Audacity] - Free Audio Editor and Recorder
*[http://audacity.sourceforge.net/ Audacity] - Free Audio Editor and Recorder
*[http://libav.org/avconv.html avconv] - A Video and Audio Converter
*[http://libav.org/avconv.html avconv] - A Video and Audio Converter


<!--T:6-->
{{Note|Kdenlive uses ffmpeg, while on (k)ubuntu, ffmpeg is deprecated and avconv is used instead. So these (and possibly other) distributions already have avconv installed.}}
{{Note|Kdenlive uses ffmpeg, while on (k)ubuntu, ffmpeg is deprecated and avconv is used instead. So these (and possibly other) distributions already have avconv installed.}}


==Creating New Surround Sound==
====Creating New Surround Sound==== <!--T:7-->


'''Kdenlive''' currently only supports rendering a project with stereo audio. It is not possible to render to more audio channels or to explicitly map audio tracks to channels in the rendered audio.
<!--T:8-->
This guide describes one possible workaround using '''Audacity''' to create and render a 5.1 surround sound audio track that can be added to the video rendered by '''Kdenlive'''.


There are however some relatively simple ways to manually work around this issue, this guide describes just one:
<!--T:9-->
{{Note|More advanced features such as surround panning (i.e. let a sound move from rear to front) are beyond the capabilities of Audacity - but it is possible to create similar effects manually.}}


* Create and edit surround sound with an external application like '''Audacity'''
=====Create and Edit Surround Sound with Audacity===== <!--T:10-->


<!--T:11-->
The following example of a simple 5.1 surround sound is used in this guide:


{{Note|More advanced features such as surround panning (i.e. let a sound move from rear to front) are beyond the capabilities of Kdenlive as well as Audacity - but it is possible to create similar effects manually.}}
<!--T:12-->
* Some original field recording from the front (stereo)


===Create and Edit Surround Sound with Audacity===
<!--T:13-->
 
* Some voice from the (front) center (mono)
This guide describes how to create a simple 5.1 surround using the following as example:


* Some original field recording from the front (stereo)
<!--T:14-->
* Some voice from the (front) center (mono)
* Some music from the rear (stereo)
* Some music from the rear (stereo)




If, like in this example, some original field recording from a video clip is supposed to be used to create the surround sound audio track, it can be easily extracted using Kdenlive with <menuchoice>Extract Audio->Wav 48000Hz</menuchoice> from the context menu of the clip. This creates a WAV audio file in the same folder as where the video clip is located.
<!--T:15-->
If, like in this example, some original field recording from a video clip is supposed to be used to create the surround sound audio track, it can be easily extracted using Kdenlive with <menuchoice>Extract Audio->Wav 48000Hz</menuchoice> from the context menu of the clip. This creates a WAV audio file in the same folder where the video clip is located.


<!--T:16-->
The audio clips to be used in this example are:
The audio clips to be used in this example are:


<!--T:17-->
* Field.wav (stereo) for Front L+R
* Field.wav (stereo) for Front L+R
<!--T:18-->
* Voice.wav (mono) for Center
* Voice.wav (mono) for Center
<!--T:19-->
* Music.mp3 (stereo) for Surround L+R (rear)
* Music.mp3 (stereo) for Surround L+R (rear)




<!--T:20-->
In a new Audacity project, they can be imported in the above order with <menuchoice>File->Import->Audio...</menuchoice>, the project should now look something like this:
In a new Audacity project, they can be imported in the above order with <menuchoice>File->Import->Audio...</menuchoice>, the project should now look something like this:


<!--T:21-->
[[File:AudacitySurround.jpg]]
[[File:AudacitySurround.jpg]]


<!--T:22-->
The channel mapping for 5.1 surround sound is:
The channel mapping for 5.1 surround sound is:


<!--T:23-->
*1 - Front Left
*1 - Front Left
<!--T:24-->
*2 - Front Right
*2 - Front Right
<!--T:25-->
*3 - Center
*3 - Center
<!--T:26-->
*4 - LFE
*4 - LFE
<!--T:27-->
*5 - Surround Left
*5 - Surround Left
<!--T:28-->
*6 - Surround Right
*6 - Surround Right




{{Note|LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer, in this case the surround system will redirect the LFE channel to "large" speakers, usually the front speakers.}}
<!--T:29-->
{{Note|LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer. In this case the surround sound system will redirect the LFE channel to "large" speakers, usually the front speakers.}}


The stereo track "Field" can now be mapped to Front L+R, "Voice" to Center and "Music" to Surround L+R. There is just one problem: The Surround (rear) speakers of a surround speaker system are usually "small" and not able to reproduce low frequencies. So it would be necessary to map the low frequency range of the "Music" track to the LFE channel, otherwise the music might sound a little "thin".
<!--T:30-->
To do this, the "Music" track can simply be duplicated with <menuchoice>Edit->Duplicate</menuchoice> after selecting it, and then <menuchoice>Split Stereo to Mono</menuchoice> from the context menu of the third track. Then one of the two mono tracks can be deleted, the other one can be renamed to "LFE".
The stereo track "Field" can now be mapped to Front L+R, "Voice" to Center and "Music" to Surround L+R. There is just one problem: the Surround (rear) speakers of a surround speaker system are usually "small" and not able to reproduce low frequencies. So it would be necessary to map the low frequency range of the "Music" track to the LFE channel, otherwise the music might sound a little "thin".


<!--T:31-->
To do this, the "Music" track can simply be duplicated with <menuchoice>Edit->Duplicate</menuchoice> after selecting it, and then <menuchoice>Split Stereo to Mono</menuchoice> from the context menu of the third track. Then one of the two mono tracks can be deleted; the other one can be renamed to "LFE".
<!--T:32-->
Now the "Equalization..." effect could be used to cut off frequencies above around 100Hz from the "LFE" track, and reverse, cut off frequencies below around 100Hz from the "Music" track.
Now the "Equalization..." effect could be used to cut off frequencies above around 100Hz from the "LFE" track, and reverse, cut off frequencies below around 100Hz from the "Music" track.


{{Note|Creating technically correct surround sound is out of scope of this guide, please refer to respective resources on the web for details.}}
<!--T:33-->
{{Note|Creating technically perfect surround sound is a science all its own and thus beyond the scope of this guide - please refer to respective resources on the web for details.}}


What remains for now is to make sure that the surround sound track has the same length as the video track it should be added to. The video track used in this example has a length of 1:00 minute, so the length of the audio tracks in Audacity are adjusted accordingly:
<!--T:34-->
What remains for now is to make sure that the surround sound track has the same length as the video track it should be added to. The video track used in this example has a length of 1:00 minute, so the lengths of the audio tracks in Audacity are adjusted accordingly:


<!--T:35-->
The Audacity project should now look something like this:
The Audacity project should now look something like this:


<!--T:36-->
[[File:AudacitySurroundLFE.jpg]]
[[File:AudacitySurroundLFE.jpg]]


The next thing to do is to export the  
<!--T:37-->
The next thing to do is to export the project to a multichannel 5.1 surround sound audio file. The format used here is AC-3 (Dolby Digital).
 
<!--T:38-->
Before exporting, Audacity needs to be configured to allow exporting to a multichannel audio file: In <menuchoice>Edit->Preferences</menuchoice>, under <menuchoice>Import/Export</menuchoice>, select "Use custom mix (for example to export a 5.1 multichannel file)".
 
<!--T:39-->
The project can now be exported into a 5.1 surround sound audio file:
 
<!--T:40-->
* Select <menuchoice>File->Export...</menuchoice>
 
<!--T:41-->
* Provide a name for "Name" and select "AC3 Files (FFmpeg)"
 
<!--T:42-->
* Click "Options..." and choose "512 kbps" as "Bit Rate"
 
 
<!--T:43-->
The "Advanced Mixing Options" dialog should show up. The number of "Output Channels" should be 6 and the channel mapping should already be correct:
 
<!--T:44-->
[[File:AdvancedMixingOptions2.jpg]]
 
<!--T:45-->
The result of the export should be an *.ac3 file which is playable with e.g. '''VLC''' or '''Dragon Player'''.
 
=====Muxing Video and Audio Together===== <!--T:46-->
 
<!--T:47-->
The final step is to add the surround sound audio track to the video track, assuming the video was rendered without audio.


<!--T:48-->
{{Note|When muxing audio and video files into one file, the actual streams are just copied, and not transcoded. So there is no quality loss to either the audio or the video streams. Also, because the streams are just copied, muxing is very fast.}}


<!--T:49-->
Assuming the video track was rendered to "Video.mkv" and the surround sound was exported to "5.1.ac3" the command to mux both to "Video-5.1.mkv" with '''avconv''' would be:


First, Audacity needs to be configured to not always export to stereo audio files: In <menuchoice>Edit->Preferences</menuchoice>, under <menuchoice>Import/Export</menuchoice>, select "Use custom mix (for example to export a 5.1 multichannel file)".
<!--T:50-->
{{Input|<syntaxhighlight lang="bash">
avconv -i Video.mkv -i 5.1.ac3 -c copy -map 0:0 -map 1:0 Video-5.1.mkv
</syntaxhighlight>}}
 
<!--T:51-->
The result should be an MKV video containing a Dolby Digital 5.1 surround sound audio track.


==Editing Existing Surround Sound==
====Editing Existing Surround Sound==== <!--T:52-->


When adding a clip with more than two channels to a project, kdenlive creates an audio thumbnail that correctly shows all audio channels:
<!--T:53-->
When adding a clip with more than two channels to a project, '''Kdenlive''' creates an audio thumbnail that correctly shows all audio channels:


<!--T:54-->
[[File:AudioThumbnail.png]]
[[File:AudioThumbnail.png]]


<!--T:55-->
The clip can be edited and (audio) effects applied to it, and all appears to work just fine - but once rendering the project, it turns out that the audio track in the resulting video file is 2 channels (stereo) only.
The clip can be edited and (audio) effects applied to it, and all appears to work just fine - but once rendering the project, it turns out that the audio track in the resulting video file is 2 channels (stereo) only.


<!--T:56-->
The following steps provide a manual workaround for this issue.
The following steps provide a manual workaround for this issue.


===Extract and Split the Audio Track===
=====Extract and Split the Audio Track===== <!--T:57-->


The first step is to extract the audio track from the video clip. This can be done in Kdenlive with <menuchoice>Extract Audio->Wav 48000Hz</menuchoice> from the context menu of the clip. This creates a WAV audio file in the same folder as where the video clip is located.
<!--T:58-->
The first step is to extract the audio track from the video clip. This can be done in '''Kdenlive''' with <menuchoice>Extract Audio->Wav 48000Hz</menuchoice> from the context menu of the clip. This creates a WAV audio file in the same folder as where the video clip is located.


<!--T:59-->
The extracted WAV audio file can then be opened in '''Audacity''', it should show all 6 channels, these are:
The extracted WAV audio file can then be opened in '''Audacity''', it should show all 6 channels, these are:


<!--T:60-->
*1 - Front Left
*1 - Front Left
<!--T:61-->
*2 - Front Right
*2 - Front Right
<!--T:62-->
*3 - Center
*3 - Center
<!--T:63-->
*4 - LFE
*4 - LFE
<!--T:64-->
*5 - Surround Left
*5 - Surround Left
<!--T:65-->
*6 - Surround Right
*6 - Surround Right




{{Note|LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer, in this case the surround system will redirect the LFE channel to "large" speakers, usually the front speakers.}}
<!--T:66-->
{{Note|LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer. In this case the surround sound system will redirect the LFE channel to "large" speakers, usually the front speakers.}}


The idea now is to split the surround sound into four separate (stereo/mono) audio files that Kdenlive can handle:
<!--T:67-->
The idea now is to split the surround sound into four separate (stereo/mono) audio files that '''Kdenlive''' can handle:


<!--T:68-->
* Front (stereo)
* Front (stereo)
<!--T:69-->
* Center (mono)
* Center (mono)
<!--T:70-->
* LFE (mono)
* LFE (mono)
<!--T:71-->
* Surround (stereo)
* Surround (stereo)




<!--T:72-->
First, Audacity needs to be configured to not always export to stereo audio files: In <menuchoice>Edit->Preferences</menuchoice>, under <menuchoice>Import/Export</menuchoice>, select "Use custom mix (for example to export a 5.1 multichannel file)".
First, Audacity needs to be configured to not always export to stereo audio files: In <menuchoice>Edit->Preferences</menuchoice>, under <menuchoice>Import/Export</menuchoice>, select "Use custom mix (for example to export a 5.1 multichannel file)".


Now, in the first and the fifth track, click on the small triangle besides the name and select <menuchoice>Make Stereo Track</menuchoice> - you should end up with 4 tracks, two stereo and two mono.
<!--T:73-->
Now, tracks 1+2 and 5+6 should be turned into stereo tracks by choosing <menuchoice>Make Stereo Track</menuchoice> from the context menu of the 1st and the 5th track, respectively. This should result in 4 tracks, two stereo and two mono.


Next, rename the tracks to "Front", "Center", "LFE" and "Surround" starting from the top, using <menuchoice>Name...</menuchoice> from the context menu of each track.
<!--T:74-->
Next, the 4 tracks should be renamed to "Front", "Center", "LFE" and "Surround" starting from the top, using <menuchoice>Name...</menuchoice> from the context menu of each track.


The tracks should now look like this:
<!--T:75-->
The tracks now look like this:


<!--T:76-->
[[File:AudacityChannels2.jpg]]
[[File:AudacityChannels2.jpg]]


After all this hard work, exporting the four tracks to four separate audio files is easy with <menuchoice>File->Export Multiple...</menuchoice>. Use "WAV" as "Export format", the rest of the settings should be already okay: "Split files based on: Tracks" and "Name files: Using Label/Track name".
<!--T:77-->
After all this hard work, exporting the four tracks to four separate audio files is easy with <menuchoice>File->Export->Export Multiple...</menuchoice>. Use "WAV" as "Export format", the rest of the settings should already be okay: "Split files based on: Tracks" and "Name files: Using Label/Track name".


The "Edit metadata" dialog might pop up for each track, it is fine to just say "OK". At the end there should be a confirmation dialog, and four audio files should have been exported: "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav".
<!--T:78-->
The "Edit metadata" dialog might pop up for each track. It is fine to just say "OK". At the end there should be a confirmation dialog and four audio files should have been exported: "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav".


===Import Audio Tracks into Kdenlive===
=====Import Audio Tracks into Kdenlive===== <!--T:79-->


<!--T:80-->
The previously created audio files can now be added to the Kdenlive project using <menuchoice>Project->Add Clip</menuchoice>.
The previously created audio files can now be added to the Kdenlive project using <menuchoice>Project->Add Clip</menuchoice>.


SInce there are only two audio tracks in a project by default, it is necessary to add two more using <menuchoice>Project->Tracks->Insert Track</menuchoice> before adding the four audio tracks to the timeline.
<!--T:81-->
Since there are only two audio tracks in a project by default, it is necessary to add two more using <menuchoice>Project->Tracks->Insert Track</menuchoice> before adding the four audio tracks to the timeline.


<!--T:82-->
The next thing to do is to group the four audio tracks with the video clip by selecting all of them and then choosing <menuchoice>Timeline->Group Clips</menuchoice>.
The next thing to do is to group the four audio tracks with the video clip by selecting all of them and then choosing <menuchoice>Timeline->Group Clips</menuchoice>.




<!--T:83-->
{{Note|Don't forget to mute the original audio track in the video clip if necessary!}}
{{Note|Don't forget to mute the original audio track in the video clip if necessary!}}


The Kdenlive project should now be ready for the usual editing, like cutting clips and adding effects, and should look something like this:
<!--T:84-->
The '''Kdenlive''' project should now be ready for the usual editing, like cutting clips and adding effects, and should look something like this:


<!--T:85-->
[[File:KdenliveProjectEdit.jpg]]
[[File:KdenliveProjectEdit.jpg]]


===Rendering the Project===
=====Rendering the Project===== <!--T:86-->


The pity now is, that it is still not possible to render the project with a surround sound audio track. Several manual steps are necessary to accomplish that.
<!--T:87-->
Since it is not possible to render the project with a surround sound audio track, some manual steps are necessary to work around this.


<!--T:88-->
First, the video track needs to be rendered without audio. This is simply done by rendering the project as it would normally be done, but without audio, by deselecting the "Export audio" checkbox.
First, the video track needs to be rendered without audio. This is simply done by rendering the project as it would normally be done, but without audio, by deselecting the "Export audio" checkbox.


Then, each of the four surround sound audio tracks "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" need to be rendered into a separate audio file. For each of them, do the following:
<!--T:89-->
Then, each of the four surround sound audio tracks "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" needs to be rendered into a separate audio file. For each of them, do the following:


<!--T:90-->
* Mute all other audio tracks
* Mute all other audio tracks
<!--T:91-->
* Enter a respective file name for "Output file"
* Enter a respective file name for "Output file"
<!--T:92-->
* Select "Audio only" as "Destination"
* Select "Audio only" as "Destination"
<!--T:93-->
* Select profile "WAV 48000 KHz"
* Select profile "WAV 48000 KHz"
* Check "Export audio"


<!--T:94-->
* Make sure "Export audio" is checked


<!--T:95-->
[[File:RenderAudio.jpg]]
[[File:RenderAudio.jpg]]


<!--T:96-->
{{Note|Unfortunately, the mono tracks "Center.wav" and "LFE.wav" are rendered as stereo tracks, and there seems to be no way to avoid this. But this can be handled later in Audacity.}}
{{Note|Unfortunately, the mono tracks "Center.wav" and "LFE.wav" are rendered as stereo tracks, and there seems to be no way to avoid this. But this can be handled later in Audacity.}}


===Compose a Surround Sound Audio File===
=====Compose a Surround Sound Audio File===== <!--T:97-->


Now the separate audio tracks rendered by Kdenlive need to be "merged" into a single multichannel 5.1 surround sound audio file. This is again done in Audacity:
<!--T:98-->
Now the separate audio tracks rendered by '''Kdenlive''' need to be "merged" into a single multichannel 5.1 surround sound audio file. This is again done in Audacity:


<!--T:99-->
* Import "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" (in this order!) using <menuchoice>File->Import->Audio...</menuchoice>
* Import "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" (in this order!) using <menuchoice>File->Import->Audio...</menuchoice>




<!--T:100-->
"Center" and "LFE" are now stereo, which is not what is needed. This can be fixed by selecting <menuchoice>Split Stereo to Mono</menuchoice> from the context menu of each track, and deleting one of the two resulting mono tracks.
"Center" and "LFE" are now stereo, which is not what is needed. This can be fixed by selecting <menuchoice>Split Stereo to Mono</menuchoice> from the context menu of each track, and deleting one of the two resulting mono tracks.


<!--T:101-->
Eventually, there should be four tracks in the Audacity project:
Eventually, there should be four tracks in the Audacity project:


<!--T:102-->
* Front (stereo)
* Front (stereo)
<!--T:103-->
* Center (mono)
* Center (mono)
<!--T:104-->
* LFE (mono)
* LFE (mono)
<!--T:105-->
* Surround (stereo)
* Surround (stereo)




<!--T:106-->
The project can now be exported into a 5.1 surround sound audio file:
The project can now be exported into a 5.1 surround sound audio file:


<!--T:107-->
* Select <menuchoice>File->Export...</menuchoice>
* Select <menuchoice>File->Export...</menuchoice>
* Provide a name for "Name:" and select "AC3 Files (FFmpeg)"
 
* Click "Options..." and choose "512 kbps" as "Bit Rate:"
<!--T:108-->
* Provide a name for "Name" and select "AC3 Files (FFmpeg)"
 
<!--T:109-->
* Click '''Options...''' and choose "512 kbps" as "Bit Rate"




The "Advanced Mixing Options" dialog should show up. The number of "Output Channels" should be 6 and the channel mapping should already be correct:
<!--T:110-->
The '''Advanced Mixing Options''' dialog should show up. The number of '''Output Channels''' should be 6 and the channel mapping should already be correct:


<!--T:111-->
[[File:AdvancedMixingOptions.jpg]]
[[File:AdvancedMixingOptions.jpg]]


<!--T:112-->
The result of the export should be an *.ac3 file which is playable with i.e. '''VLC''' or '''Dragon Player'''.
The result of the export should be an *.ac3 file which is playable with i.e. '''VLC''' or '''Dragon Player'''.


===Muxing Video and Audio Together===
=====Muxing Video and Audio Together===== <!--T:113-->


<!--T:114-->
Since video and audio was rendered separately, both need to be multiplexed into a single file containing both the video and audio stream.
Since video and audio was rendered separately, both need to be multiplexed into a single file containing both the video and audio stream.


{{Note|When muxing audio and video files into one file, the actual streams are just copied, and not transcoded. So there is no quality loss to neither the audio nor the video streams. Also, because the streams are just copied, muxing is very fast.}}
<!--T:115-->
{{Note|When muxing audio and video files into one file, the actual streams are just copied, and not transcoded. So there is no quality loss to either the audio or the video streams. Also, because the streams are just copied, muxing is very fast.}}


Assuming the video track was rendered to "Video.mkv" and the surround sound was exported to "5.1.ac3" the command to mux both to "Video-5.1.mkv" with '''avconv''' would be:
<!--T:116-->
Assuming the video track was rendered to "Video.mkv" and the surround sound was exported to "5.1.ac3", the command to mux both to "Video-5.1.mkv" with '''avconv''' would be:


<!--T:117-->
{{Input|<syntaxhighlight lang="bash">
{{Input|<syntaxhighlight lang="bash">
avconv -i Video.mkv -i 5.1.ac3 -c copy -map 0:0 -map 1:0 Video-5.1.mkv
avconv -i Video.mkv -i 5.1.ac3 -c copy -map 0:0 -map 1:0 Video-5.1.mkv
</syntaxhighlight>}}
</syntaxhighlight>}}


<!--T:118-->
The result should be an MKV video containing a Dolby Digital 5.1 surround sound audio track.
The result should be an MKV video containing a Dolby Digital 5.1 surround sound audio track.
<!--T:119-->
{{Prevnext2
| prevpage=Special:MyLanguage/Kdenlive/Manual/Useful_Information/Shortcuts | nextpage=Special:MyLanguage/Kdenlive/Manual/Useful_Information/Tips_Tricks
| prevtext=Keyboard Shortcuts | nexttext= Tips and Tricks
| index=Special:MyLanguage/Kdenlive/Manual | indextext=Back to menu
}}
[[Category:Kdenlive]]
</translate>

Latest revision as of 10:03, 11 August 2023

Editing Surround Sound with Kdenlive

At the time of writing, Kdenlive only supports rendering a project to a video containing stereo audio. It is not possible to render to more audio channels or to explicitly map audio tracks to channels in the rendered audio. In order to edit and create surround sound, some manual steps, including external tools, are required.

This guide is using a 6 channel 5.1 surround sound as example.

External Tools Used Here

  • Audacity - Free Audio Editor and Recorder
  • avconv - A Video and Audio Converter

Note

Kdenlive uses ffmpeg, while on (k)ubuntu, ffmpeg is deprecated and avconv is used instead. So these (and possibly other) distributions already have avconv installed.


Creating New Surround Sound

This guide describes one possible workaround using Audacity to create and render a 5.1 surround sound audio track that can be added to the video rendered by Kdenlive.

Note

More advanced features such as surround panning (i.e. let a sound move from rear to front) are beyond the capabilities of Audacity - but it is possible to create similar effects manually.


Create and Edit Surround Sound with Audacity

The following example of a simple 5.1 surround sound is used in this guide:

  • Some original field recording from the front (stereo)
  • Some voice from the (front) center (mono)
  • Some music from the rear (stereo)


If, like in this example, some original field recording from a video clip is supposed to be used to create the surround sound audio track, it can be easily extracted using Kdenlive with Extract Audio->Wav 48000Hz from the context menu of the clip. This creates a WAV audio file in the same folder where the video clip is located.

The audio clips to be used in this example are:

  • Field.wav (stereo) for Front L+R
  • Voice.wav (mono) for Center
  • Music.mp3 (stereo) for Surround L+R (rear)


In a new Audacity project, they can be imported in the above order with File->Import->Audio..., the project should now look something like this:

The channel mapping for 5.1 surround sound is:

  • 1 - Front Left
  • 2 - Front Right
  • 3 - Center
  • 4 - LFE
  • 5 - Surround Left
  • 6 - Surround Right


Note

LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer. In this case the surround sound system will redirect the LFE channel to "large" speakers, usually the front speakers.


The stereo track "Field" can now be mapped to Front L+R, "Voice" to Center and "Music" to Surround L+R. There is just one problem: the Surround (rear) speakers of a surround speaker system are usually "small" and not able to reproduce low frequencies. So it would be necessary to map the low frequency range of the "Music" track to the LFE channel, otherwise the music might sound a little "thin".

To do this, the "Music" track can simply be duplicated with Edit->Duplicate after selecting it, and then Split Stereo to Mono from the context menu of the third track. Then one of the two mono tracks can be deleted; the other one can be renamed to "LFE".

Now the "Equalization..." effect could be used to cut off frequencies above around 100Hz from the "LFE" track, and reverse, cut off frequencies below around 100Hz from the "Music" track.

Note

Creating technically perfect surround sound is a science all its own and thus beyond the scope of this guide - please refer to respective resources on the web for details.


What remains for now is to make sure that the surround sound track has the same length as the video track it should be added to. The video track used in this example has a length of 1:00 minute, so the lengths of the audio tracks in Audacity are adjusted accordingly:

The Audacity project should now look something like this:

The next thing to do is to export the project to a multichannel 5.1 surround sound audio file. The format used here is AC-3 (Dolby Digital).

Before exporting, Audacity needs to be configured to allow exporting to a multichannel audio file: In Edit->Preferences, under Import/Export, select "Use custom mix (for example to export a 5.1 multichannel file)".

The project can now be exported into a 5.1 surround sound audio file:

  • Select File->Export...
  • Provide a name for "Name" and select "AC3 Files (FFmpeg)"
  • Click "Options..." and choose "512 kbps" as "Bit Rate"


The "Advanced Mixing Options" dialog should show up. The number of "Output Channels" should be 6 and the channel mapping should already be correct:

The result of the export should be an *.ac3 file which is playable with e.g. VLC or Dragon Player.

Muxing Video and Audio Together

The final step is to add the surround sound audio track to the video track, assuming the video was rendered without audio.

Note

When muxing audio and video files into one file, the actual streams are just copied, and not transcoded. So there is no quality loss to either the audio or the video streams. Also, because the streams are just copied, muxing is very fast.


Assuming the video track was rendered to "Video.mkv" and the surround sound was exported to "5.1.ac3" the command to mux both to "Video-5.1.mkv" with avconv would be:

avconv -i Video.mkv -i 5.1.ac3 -c copy -map 0:0 -map 1:0 Video-5.1.mkv

The result should be an MKV video containing a Dolby Digital 5.1 surround sound audio track.

Editing Existing Surround Sound

When adding a clip with more than two channels to a project, Kdenlive creates an audio thumbnail that correctly shows all audio channels:

The clip can be edited and (audio) effects applied to it, and all appears to work just fine - but once rendering the project, it turns out that the audio track in the resulting video file is 2 channels (stereo) only.

The following steps provide a manual workaround for this issue.

Extract and Split the Audio Track

The first step is to extract the audio track from the video clip. This can be done in Kdenlive with Extract Audio->Wav 48000Hz from the context menu of the clip. This creates a WAV audio file in the same folder as where the video clip is located.

The extracted WAV audio file can then be opened in Audacity, it should show all 6 channels, these are:

  • 1 - Front Left
  • 2 - Front Right
  • 3 - Center
  • 4 - LFE
  • 5 - Surround Left
  • 6 - Surround Right


Note

LFE (Low Frequency Effects) is often referred to as "subwoofer channel", which is not quite correct. A surround sound speaker setup is perfectly valid without subwoofer. In this case the surround sound system will redirect the LFE channel to "large" speakers, usually the front speakers.


The idea now is to split the surround sound into four separate (stereo/mono) audio files that Kdenlive can handle:

  • Front (stereo)
  • Center (mono)
  • LFE (mono)
  • Surround (stereo)


First, Audacity needs to be configured to not always export to stereo audio files: In Edit->Preferences, under Import/Export, select "Use custom mix (for example to export a 5.1 multichannel file)".

Now, tracks 1+2 and 5+6 should be turned into stereo tracks by choosing Make Stereo Track from the context menu of the 1st and the 5th track, respectively. This should result in 4 tracks, two stereo and two mono.

Next, the 4 tracks should be renamed to "Front", "Center", "LFE" and "Surround" starting from the top, using Name... from the context menu of each track.

The tracks now look like this:

After all this hard work, exporting the four tracks to four separate audio files is easy with File->Export->Export Multiple.... Use "WAV" as "Export format", the rest of the settings should already be okay: "Split files based on: Tracks" and "Name files: Using Label/Track name".

The "Edit metadata" dialog might pop up for each track. It is fine to just say "OK". At the end there should be a confirmation dialog and four audio files should have been exported: "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav".

Import Audio Tracks into Kdenlive

The previously created audio files can now be added to the Kdenlive project using Project->Add Clip.

Since there are only two audio tracks in a project by default, it is necessary to add two more using Project->Tracks->Insert Track before adding the four audio tracks to the timeline.

The next thing to do is to group the four audio tracks with the video clip by selecting all of them and then choosing Timeline->Group Clips.


Note

Don't forget to mute the original audio track in the video clip if necessary!


The Kdenlive project should now be ready for the usual editing, like cutting clips and adding effects, and should look something like this:

Rendering the Project

Since it is not possible to render the project with a surround sound audio track, some manual steps are necessary to work around this.

First, the video track needs to be rendered without audio. This is simply done by rendering the project as it would normally be done, but without audio, by deselecting the "Export audio" checkbox.

Then, each of the four surround sound audio tracks "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" needs to be rendered into a separate audio file. For each of them, do the following:

  • Mute all other audio tracks
  • Enter a respective file name for "Output file"
  • Select "Audio only" as "Destination"
  • Select profile "WAV 48000 KHz"
  • Make sure "Export audio" is checked


Note

Unfortunately, the mono tracks "Center.wav" and "LFE.wav" are rendered as stereo tracks, and there seems to be no way to avoid this. But this can be handled later in Audacity.


Compose a Surround Sound Audio File

Now the separate audio tracks rendered by Kdenlive need to be "merged" into a single multichannel 5.1 surround sound audio file. This is again done in Audacity:

  • Import "Front.wav", "Center.wav", "LFE.wav" and "Surround.wav" (in this order!) using File->Import->Audio...


"Center" and "LFE" are now stereo, which is not what is needed. This can be fixed by selecting Split Stereo to Mono from the context menu of each track, and deleting one of the two resulting mono tracks.

Eventually, there should be four tracks in the Audacity project:

  • Front (stereo)
  • Center (mono)
  • LFE (mono)
  • Surround (stereo)


The project can now be exported into a 5.1 surround sound audio file:

  • Select File->Export...
  • Provide a name for "Name" and select "AC3 Files (FFmpeg)"
  • Click Options... and choose "512 kbps" as "Bit Rate"


The Advanced Mixing Options dialog should show up. The number of Output Channels should be 6 and the channel mapping should already be correct:

The result of the export should be an *.ac3 file which is playable with i.e. VLC or Dragon Player.

Muxing Video and Audio Together

Since video and audio was rendered separately, both need to be multiplexed into a single file containing both the video and audio stream.

Note

When muxing audio and video files into one file, the actual streams are just copied, and not transcoded. So there is no quality loss to either the audio or the video streams. Also, because the streams are just copied, muxing is very fast.


Assuming the video track was rendered to "Video.mkv" and the surround sound was exported to "5.1.ac3", the command to mux both to "Video-5.1.mkv" with avconv would be:

avconv -i Video.mkv -i 5.1.ac3 -c copy -map 0:0 -map 1:0 Video-5.1.mkv

The result should be an MKV video containing a Dolby Digital 5.1 surround sound audio track.