Bug 491124 - Simple export auf audio tracks
Summary: Simple export auf audio tracks
Status: REPORTED
Alias: None
Product: kdenlive
Classification: Applications
Component: Rendering & Export (show other bugs)
Version: 22.04.3
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-01 13:28 UTC by Uwe Dippel
Modified: 2024-08-04 10:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Rendering times (17.75 KB, image/png)
2024-08-04 09:52 UTC, Uwe Dippel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Dippel 2024-08-01 13:28:01 UTC
SUMMARY
At least as long as kdenlive does not support multiple audio tracks in a rendered video, it will be cumbersome to re-add audio tracks of an e.g. input file containing a video track with multiple audio tracks (e.g. languages, for the impaired) to the output
In order to keep the audio tracks in sync, it is mandatory to edit all tracks in kdenlive, however.

Under the assumption that kdenlive is mainly used to edit the video part (otherwise an audio editor like Audacity would be used in the first place), it would be most helpful to have a simple export of one or more audiotracks, without going through the complete 'rendering' process. 
Like with an icon, at the time-line, a right mouse click, or something similar, one or more audio tracks could be used 'as is' and quickly exported to a file for further processing. This could be favourable, since e.g. Audacity has many more features for audio edits. This further improved file could then be re-added to the time-line ("Add Clip or Folder").

Not knowing how feasible this is, it could as well be a call from within kdenlive to an audio processing engine, like Audacity, to solely work on an audio track, and then continue in kdenlive.
Comment 1 Bernd 2024-08-02 15:03:04 UTC
(In reply to Uwe Dippel from comment #0)
> Not knowing how feasible this is, it could as well be a call from within
> kdenlive to an audio processing engine, like Audacity, to solely work on an
> audio track, and then continue in kdenlive.

You can export just the audio track of any video asset in the project bin. Kdenlive creates a .WAV file in the same location on you file system where the video asset is stored, and adds it to the project bin. Right-click on the audio clip, and select Edit Clip, and Kdenlive opens whatever application you have specified in the Menu > Settings > Environment > Default Apps. Make your changes, save the file, and Kdenlive will update the file in the project bin. If that clip has already been added to the timeline, the changes are reflected there as well.
Comment 2 Uwe Dippel 2024-08-02 15:37:46 UTC
Thanks, though I had tried that before. 
Here in the Project Bin it says "Extract Audio", not "Edit Audio". Then a "Wav 48000" pops up as only alternative. Clicking it leads to an error. I could post the complete log (tell me if you need it), though I think it is about 

"WAVE files have exactly one stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- "

I think it is because it is a video file with 2 audio tracks. I was rather thinking of exporting it via an audio track in the time-line.
[How does one escape code in this forum, please?]
Comment 3 Bernd 2024-08-02 16:04:08 UTC
Ok, I see. (Never had that issue before so had no idea about that limitation)

But you could use the Clip Job functionality to extract the streams using ffmpeg. I found this to be helpful, potentially: https://stackoverflow.com/questions/32922226/extract-every-audio-and-subtitles-from-a-video-with-ffmpeg

You may need to create a bash script for this and specify that as the executable, or, if you always deal with the same amount of audio streams, use the 'Request option from list' option to specify the audio stream you want extracted. This means you need to run the clip job for every audio stream you need, but a) this gives you more flexibility, and b) it makes it easier to specify where the output should go (although you could use the 'Request file path' option for Parameter 2 and pass that on to the bash script).
Comment 4 Uwe Dippel 2024-08-02 16:30:27 UTC
If this worked, my problems would be fewer. Unfortunately, ffmpeg is (not yet) able to cut/trim accurately, due to the issue of key-frames. While kdenlive recently has been quite robust w.r.t. lip-synchronism. 
Initially, I had exactly that: a script that removes one or more audio tracks from a combined file, including me passing start and end times. Though the audio tracks started/ended with a sync deficiency up to two seconds. I had already studied everything on github; so far this seems to be the state of the art, as far as ffmpeg is concerned. 

Currently I render in kdenlive, single audio track, unified file. Then I import into Audacity, use the extracted (ffmpeg) audio file, and visually adjust and subsequently cat / add the milliseconds to the additional audio tracks, and reassemble with ffmpeg. 
This is also why I wrote that other bug report, since kdenlive takes about 10-fold the time to render a single audio file in comparison with extraction of an audio file with Audacity, adjusting the timing, exporting and reassembling.  

I was (and am) actually hoping that one day kdenlive can render multiple audio tracks; though until then I'd be happy if I could export a lip-synchronous audio track from the time line and render it e.g. with audacity within a few minutes in order to re-assemble within another few minutes.
Comment 5 Bernd 2024-08-02 17:40:53 UTC
(In reply to Uwe Dippel from comment #4)
I'd be happy if I could export a
> lip-synchronous audio track from the time line and render it e.g. with
> audacity within a few minutes in order to re-assemble within another few
> minutes.

Then switch off 'Video', switch on 'Separate files for each audio track', and Kdenlive will blast through the render of just the audio. In my example I rendered a small test video of 14s with a composition in 30s with video and audio; switching off video resulted in a 2s render time for the same. I could easily import the resulting .mp4 files into Audacity.
Comment 6 Bernd 2024-08-02 17:42:53 UTC
Forgot to add that you could simply use the 'Audio Only' render presets/profiles to create .ac3, .mp3, or .ogg audio files only
Comment 7 Uwe Dippel 2024-08-02 18:19:41 UTC
That's really a good one, thanks!
Somehow I never had the idea to use kdenlive as audio-renderer-only!
Will start to explore this path next. 
(It would be easier, and more obvious though, if there was a context menu item in the time-line to export just this audio track to ... . Could be most simple; why not natively to pass to Audacity like I suggested further up?)
Comment 8 Uwe Dippel 2024-08-04 09:52:11 UTC
Created attachment 172266 [details]
Rendering times
Comment 9 Uwe Dippel 2024-08-04 10:03:21 UTC
(In reply to Bernd from comment #5)
> 
> Then switch off 'Video', switch on 'Separate files for each audio track',
> and Kdenlive will blast through the render of just the audio. In my example
> I rendered a small test video of 14s with a composition in 30s with video
> and audio; switching off video resulted in a 2s render time for the same. I
> could easily import the resulting .mp4 files into Audacity.

The attachment show that this isn't quite true. 
Rendering the video, H264, plus an audio track as re-mix of two audio tracks, takes 2:57:36. Rendering a single audio track takes around 1:30:00 each. 
Turning off video wouldn't render the video track that I also need. I think, there is a bug, and that bug is - shown elsewhere earlier -, that the audio files contains a full video handler stream. Empty, though presumably processed, which would explain the times.

(Here, for reference:)
[...]
  Duration: 01:50:44.61, start: 0.000000, bitrate: 174 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 720x576 [SAR 64:45 DAR 16:9], 8 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
[...]
Yes, that's the ..._Audio_2.mp4 file.