This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to add new transcoding item: 3x speedup?

Tags: None
(comma "," separated)
TheDiveO
Registered Member
Posts
595
Karma
3
OS
In my screencasting projects I regularily need to speed up video recordings of handmade illustrations, say 3x. It's no big deal to do this from the command line ... but I would like to have a new convenient transcoding menu item. I've seen that users can create new transcoding profiles from within Kdenlive. However, I'm unclear as to how what ffmpeg parameters need to be present and which to leave out. Unfortunately, the manual does go into any details on how to setup transcoding profiles. :(

On the command line I'm using this when I need to transcode an existing clip into a new version with 3x speedup...
Code: Select all
ffmpeg -i video.mp4 -filter:v "setpts=(1/3)*PTS" video-x3.mp
Does Kdenlive supply the "-i clip filename" part automatically?

Does Kdenlive also supply the output filename? If yes, how is this derived from the input filename? Does it remove the file extension from the input filename and tucks on the new extension?
User avatar
qubodup
Registered Member
Posts
142
Karma
0
For those interested, in 15.08.3, some of the /usr/share/kdenlive/kdenlivetranscodingrc file content is:
Code: Select all
[Transcoding]
DNxHD 1080i 25 fps 185 Mb/s=-s 1920x1080 -r pal -top -1 -flags +ilme+ildct -vb 185000k -threads 2 -vcodec dnxhd -acodec copy %1.mov;High quality encoding
DNxHD 1080p 25 fps 185 Mb/s=-s 1920x1080 -r 25 -vb 185000k -threads 2 -vcodec dnxhd -acodec copy %1.mov;High quality encoding
Fix MPEG-1=-sameq -acodec copy -vcodec mpeg1video %1.mpg;Fix unplayable MPEG-1 files;;vcodec=mpeg1video
Fix Ogg Theora=-sameq -vcodec libtheora -acodec copy %1.ogv;Fix unplayable OGG Theora files;;vcodec=theora
Remux MPEG-2 PS/VOB=-vcodec copy -acodec copy %1.mpg;Fix audio sync in MPEG-2 vob files;;vcodec=mpeg2video
Remux MPEG-2 PS/VOB=-vcodec copy -acodec copy %1.mpg;Fix audio sync in MPEG-2 vob files 2;
Lossless Matroska=-sn -vcodec huffyuv -acodec flac %1.mkv;High quality lossless encoding
Wav 48000Hz=-vn -ar 48000 %1.wav;Extract audio as WAV file;audio
Remux with MKV=-vcodec copy -acodec copy -sn %1.mkv
DVD PAL 4:3=-f dvd -r 25 -vf scale=720:576 -aspect 4:3 -minrate 0 -maxrate 8000k -muxrate 10080000 -g 15 -bufsize 1835008 -packetsize 2048 -trellis 1 -me_range 63 -acodec ac3 -ab 192k -ar 48000 -vcodec mpeg2video -vb 5000k %1.vob;Dvd PAL

  1. You can add new options by adding a new line and restarting Kdenlive.
  2. The part before the first "=" is the name of the transcoding option. What follows until the first ";" appear to be inserted after a "ffmpeg -i %1" and run as a command.
  3. %1 stands for the original video's file path and name.
  4. Regarding the sections behind ";"s, I'm guessing the first is a comment (not displayed in Kdenlive as far as I can tell) and the second one is a restriction as to which file formats the transcoding may be applied to.
I think you can learn a little more about how the parameters are used by watching the command line output (start kdenlive from a terminal) when using a transcode:
Code: Select all
/ / / STARTING CUT JOB:  ("-i", "/home/qubodup/klcheck2.mkv", "-an", "-filter:v", "setpts=(1/3)*PTS", "-y", "/home/qubodup/klcheck2.mkv-3x.mkv")

I was able to add a 3x speedup option (the options are automatically sorted alphabetically - in case you don't find yours) by adding this line:
Code: Select all
Speed up 3x=-an -filter:v setpts=(1/3)*PTS %1-3x.mp4;Speed up using filter, works with multiple formats but probably requires you to change file ending accordingly


Image

-an removes audio, as it would otherwise keep playing while frozen at the last frame of the 3x video stream (might cause other issues?). I used it because I couldn't find a satisfactory method to speed up audio to 300% speed and didn't test the method described at https://trac.ffmpeg.org/wiki/How%20to%2 ... 0a%20video but if you find a way please share and let us know whether the results are any good.

Hope this helps! Thanks for letting me discover this part of Kdenlive customization!
TheDiveO
Registered Member
Posts
595
Karma
3
OS
Qubodup, thank you very much! Yes, that helps.

I've later found the configuration dialog that makes adding user transcoding jobs more easy. Unfortunately, the manual is terse on the configuration dialog.

The -an option is a good thing to do. I was lazy on it, because my footage is captured by an HDMI recorder without any sound. Silence is golden :) ... nah, I simply prefer a well-made voice over using a good studio mic and some audio post-processing.

I'll try later as I'm in the scene production process, so that'll be a good test case.
TheDiveO
Registered Member
Posts
595
Karma
3
OS
So, tested and works like a charm. However, I went through Kdenlive's Settings->Configure Kdenlive, then in the Transcode section I added a new profile called "Speedup 3x", extension "mp4", parameters "-an -filter:v setpts=(1/3)*PTS". Note that in the UI transcode profiles there is no %1; Kdenlive seems to add instead later the output filename as entered in the job UI.
User avatar
qubodup
Registered Member
Posts
142
Karma
0
Oh, I didn't realize there was a UI method to do this :)

By the way, in 15.08.3, the transcode setting set via UI get saved at
Code: Select all
~/.local/share/kdenlive/kdenlivetranscodingrc
User avatar
CorrosiveTruths
Registered Member
Posts
87
Karma
0
OS
qubodup wrote:
Image

-an removes audio, as it would otherwise keep playing while frozen at the last frame of the 3x video stream (might cause other issues?). I used it because I couldn't find a satisfactory method to speed up audio to 300% speed and didn't test the method described at https://trac.ffmpeg.org/wiki/How%20to%2 ... 0a%20video but if you find a way please share and let us know whether the results are any good.

Hope this helps! Thanks for letting me discover this part of Kdenlive customization!

Code: Select all
ffmpeg -i input.mkv -filter_complex "[0:v]setpts=(1/3)*PTS[v];[0:a]atempo=2.0[2x];[2x]atempo=1.5[3x]" -map "[v]" -map "[3x]" output.mkv
would be the command to speed up x3 with audio in ffmpeg.
User avatar
CorrosiveTruths
Registered Member
Posts
87
Karma
0
OS
Oh.

That was a lot easier to get working than I thought it would be!

Do the following to get 3x speed transcoding with audio and video using Kdenlive.

Settings -> Configure Kdenlive

Select the Transcode tab, select Lossless Matroska as a basis, change the Name to 3x Speed, the Description to Fast lossless encoding, leave the extension be.

For the parameters use:

Code: Select all
-vf setpts=1/3*PTS -af atempo=2.0,atempo=1.5 -qp 0 -vcodec libx264 -preset superfast -acodec flac


Obviously you can adjust as you see fit, maybe add a -tune fastdecode, or change the group of pictures for smoother backframes (-g 1).

But yeah, that worked for me.

And you should be able to do preeeetty much any speed multiplier bearing in mind that you can only use between 0.5-2.0 atempo speed, which is why I've used it twice. So for x16, you'd string together four atempo=2.0's, etc.

Bonus; like it says in the ffmpeg trac linked to earlier, it does this by maintaining the framerate and dropping frames, but you can set the -r to keep 'em. Say you had some videogame footage from a capture device in your usual framerate of 30000/1001, if you specified -r 60000/1001 and double speed you wouldn't lose any frames, just get double the framerate of the original.

I'm so going to use this loads.
TheDiveO
Registered Member
Posts
595
Karma
3
OS
Interesting and really helpful discussion! Thank you very much for bringing in this additional knowledge. I only have simple footage without audio, but some day this will come in very handy. In my current project the new self-made x3 and x5 transcoding jobs were already incredible useful, as I had to speed up several scenes of "hand-made illustrations". I've found a bug though there the job result will be added to the currently used project bin folder, no the one where the job was started.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient