]> git.sesse.net Git - kdenlive/commitdiff
Allow to use JScript in render profile parameter values.
authorTill Theato <root@ttill.de>
Mon, 27 Jun 2011 13:01:41 +0000 (13:01 +0000)
committerTill Theato <root@ttill.de>
Mon, 27 Jun 2011 13:01:41 +0000 (13:01 +0000)
values that need evalutation need to be indicated by '%'.

svn path=/trunk/kdenlive/; revision=5737

export/profiles.xml
src/renderwidget.cpp

index 08a74ce2ca278033382bc878d8458c804ba2810f..7cc8e9bad3e123d3ea24216b57ca4da4bf15127d 100644 (file)
 </group>
 
 <group name="MPEG-2" renderer="avformat" extension="mpg" type="av">
-  <profile name="MPEG-2" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k,18000k,25000k" defaultbitrate="12000k"
-           args="f=mpeg acodec=mp2 ab=384k ar=48000 vcodec=mpeg2video minrate=0 b=%bitrate bf=2 b_strategy=1 trellis=1 aspect=%dar" />
+  <profile name="MPEG-2" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000,18000,25000" defaultbitrate="12000"
+           args="f=mpeg acodec=mp2 ab=384k ar=48000 vcodec=mpeg2video minrate=0 b=%bitrate+'k' bf=2 b_strategy=1 trellis=1 aspect=%dar" />
 </group>
 
 <group name="MPEG-4" renderer="avformat" extension="mp4" type="av">
-  <profile name="MPEG-4" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k,18000k,25000k" defaultbitrate="12000k"
-           args="f=mp4 acodec=libmp3lame ab=128k ar=44100 vcodec=mpeg4 minrate=0 b=%bitrate aspect=%dar mbd=2 trellis=1 mv4=1" />
+  <profile name="MPEG-4" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000,18000,25000" defaultbitrate="12000"
+           args="f=mp4 acodec=libmp3lame ab=128k ar=44100 vcodec=mpeg4 minrate=0 b=%bitrate+'k' aspect=%dar mbd=2 trellis=1 mv4=1" />
 </group>
 
 <group name="XVid4" renderer="avformat" extension="avi" type="av">
-  <profile name="XVid4" bitrates="400k,600k,800k,1000k,2000k,4000k,8000k,10000k,12000k" defaultbitrate="8000k"
-           args="acodec=libmp3lame ab=128k ar=44100 vcodec=libxvid minrate=0 b=%bitrate aspect=%dar mbd=2 trellis=1 mv4=1" />
+  <profile name="XVid4" bitrates="400,600,800,1000,2000,4000,8000,10000,12000" defaultbitrate="8000"
+           args="acodec=libmp3lame ab=128k ar=44100 vcodec=libxvid minrate=0 b=%bitrate+'k' aspect=%dar mbd=2 trellis=1 mv4=1" />
 </group>
 
 <group name="H.264" renderer="avformat" extension="mp4" type="av">
-  <profile name="H.264" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k,18000k,25000k" defaultbitrate="12000k"
-           args="f=mp4 hq=1 acodec=aac ab=384k ar=48000 pix_fmt=yuv420p vcodec=libx264 minrate=0 b=%bitrate g=250 bf=3 b_strategy=1 subcmp=2 cmp=2 coder=1 flags=+loop flags2=dct8x8 qmax=51 subq=7 qmin=10 qcomp=0.6 qdiff=4 trellis=1 aspect=%dar" />
+  <profile name="H.264" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000,18000,25000" defaultbitrate="12000"
+           args="f=mp4 hq=1 acodec=aac ab=384k ar=48000 pix_fmt=yuv420p vcodec=libx264 minrate=0 b=%bitrate+'k' g=250 bf=3 b_strategy=1 subcmp=2 cmp=2 coder=1 flags=+loop flags2=dct8x8 qmax=51 subq=7 qmin=10 qcomp=0.6 qdiff=4 trellis=1 aspect=%dar" />
 </group>
 
 <group name="Flash" renderer="avformat" extension="flv" type="av">
-  <profile name="Flash" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k" defaultbitrate="8000k"
-           args="f=flv acodec=libmp3lame ab=128k ar=44100 vcodec=flv minrate=0 b=%bitrate progressive=1" />
+  <profile name="Flash" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000" defaultbitrate="8000"
+           args="f=flv acodec=libmp3lame ab=128k ar=44100 vcodec=flv minrate=0 b=%bitrate+'k' progressive=1" />
   <profile name="Flash 720x576" standard="PAL" args="f=flv acodec=libmp3lame ab=128k ar=44100 vcodec=flv minrate=0 b=12000k s=720x576 progressive=1" />
   <profile name="Flash 720x480" standard="NTSC" args="f=flv acodec=libmp3lame ab=128k ar=44100 vcodec=flv minrate=0 b=12000k s=720x480 progressive=1" />
 </group>
 
 <group name="RealVideo" renderer="avformat" extension="rm" type="av">
-  <profile name="RealVideo" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k" defaultbitrate="8000k"
-           args="vcodec=rv20 acodec=ac3 minrate=0 b=%bitrate ab=128k ar=44100 g=8" />
+  <profile name="RealVideo" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000" defaultbitrate="8000"
+           args="vcodec=rv20 acodec=ac3 minrate=0 b=%bitrate+'k' ab=128k ar=44100 g=8" />
   <profile name="RealVideo 720x576" standard="PAL" args="vcodec=rv20 acodec=ac3 minrate=0 b=12000k ab=384k ar=48000 s=720x576 g=8" />
   <profile name="RealVideo 720x480" standard="NTSC" args="vcodec=rv20 acodec=ac3 minrate=0 b=12000k ab=384k ar=48000 s=720x480 g=8" />
 </group>
 
 <group name="Theora" renderer="avformat" extension="ogv" type="av">
-  <profile name="Theora" bitrates="200k,400k,600k,800k,1000k,2000k,4000k,6000k,8000k,10000k,12000k" defaultbitrate="8000k"
-           args="acodec=vorbis ab=128k ar=44100 vcodec=libtheora minrate=0 b=%bitrate aspect=%dar" />
+  <profile name="Theora" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000" defaultbitrate="8000"
+           args="acodec=vorbis ab=128k ar=44100 vcodec=libtheora minrate=0 b=%bitrate+'k' aspect=%dar" />
   <profile name="Theora 720x576" standard="PAL" args="acodec=vorbis ab=384k aq=30 ar=44100 vcodec=libtheora minrate=0 b=12000k s=720x576 aspect=%dar" />
   <profile name="Theora 720x480" standard="NTSC" args="acodec=vorbis ab=384k aq=30 ar=44100 vcodec=libtheora minrate=0 b=12000k s=720x480 aspect=%dar" />
 </group>
 
 <group name="WebM" renderer="avformat" extension="webm" type="av" twopass="false">
-  <profile name="WebM 200k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=200k aspect=%dar maxrate=600k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 400k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=400k aspect=%dar maxrate=1200k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 600k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=600k aspect=%dar maxrate=1800k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 800k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=800k aspect=%dar maxrate=2400k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 1000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=1000k aspect=%dar maxrate=3000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 2000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=2000k aspect=%dar maxrate=4000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 4000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=4000k aspect=%dar maxrate=8000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 6000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=6000k aspect=%dar maxrate=12000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 8000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=8000k aspect=%dar maxrate=16000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 10000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=10000k aspect=%dar maxrate=20000k g=120 qmax=42 qmin=10 threads=2" />
-  <profile name="WebM 12000k" args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=12000k aspect=%dar maxrate=24000k g=120 qmax=42 qmin=10 threads=2" />
+  <profile name="WebM" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000" defaultbitrate="8000"
+          args="acodec=vorbis ab=128k ar=44100 vcodec=libvpx minrate=0 b=%bitrate+'k' aspect=%dar maxrate=%bitrate*2+'k' g=120 qmax=42 qmin=10" />
 </group>
 
 <group name="Media players" renderer="avformat" type="av">
   <groupname id="mediaplayers">Media players</groupname>
-  <profile name="Windows Media Player WMV V7" bitrates="400k,1000k,2000k" defaultbitrate="2000k"
-           extension="avi" args="acodec=libmp3lame ab=128k ar=48000 ac=2 vcodec=wmv1 minrate=0 b=%bitrate aspect=%dar" />
-  <profile name="Apple Quicktime Player MPEG-4" bitrates="400k,1000k,2000k" defaultbitrate="2000k"
-           extension="mov" args="acodec=aac ab=128k ac=2 ar=48000 vcodec=mpeg4 minrate=0 b=%bitrate aspect=%dar" />
+  <profile name="Windows Media Player WMV V7" bitrates="400,1000,2000" defaultbitrate="2000"
+           extension="avi" args="acodec=libmp3lame ab=128k ar=48000 ac=2 vcodec=wmv1 minrate=0 b=%bitrate+'k' aspect=%dar" />
+  <profile name="Apple Quicktime Player MPEG-4" bitrates="400,1000,2000" defaultbitrate="2000"
+           extension="mov" args="acodec=aac ab=128k ac=2 ar=48000 vcodec=mpeg4 minrate=0 b=%bitrate+'k' aspect=%dar" />
 </group>
 
 <group name="Web sites" renderer="avformat" type="av">
index 429ffd5cc69ffee4b0f968b65045682e981bda60..441c0e15525321d8b7fd8d15787f8eaa13e2e727 100644 (file)
@@ -45,6 +45,7 @@
 #include <QDBusConnectionInterface>
 #include <QDBusInterface>
 #include <QThread>
+#include <QScriptEngine>
 
 const int GroupRole = Qt::UserRole;
 const int ExtensionRole = GroupRole + 1;
@@ -760,7 +761,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         width = m_profile.width;
         height = m_profile.height;
     }
-    renderArgs.replace("%dar", '@' + QString::number(m_profile.display_aspect_num) + '/' + QString::number(m_profile.display_aspect_den));
+
     //renderArgs.replace("%width", QString::number((int)(m_profile.height * m_profile.display_aspect_num / (double) m_profile.display_aspect_den + 0.5)));
     //renderArgs.replace("%height", QString::number((int)m_profile.height));
 
@@ -779,10 +780,6 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     if (m_view.checkTwoPass->isEnabled() && m_view.checkTwoPass->isChecked())
         renderArgs.append(" pass=2");
 
-    // bitrate
-    if (m_view.comboBitrates->isEnabled())
-        renderArgs.replace("%bitrate", m_view.comboBitrates->currentText());
-
     // Check if the rendering profile is different from project profile,
     // in which case we need to use the producer_comsumer from MLT
     QString std = renderArgs;
@@ -802,13 +799,26 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     }
     bool resizeProfile = (subsize != currentSize);
     QStringList paramsList = renderArgs.split(" ", QString::SkipEmptyParts);
-    for (int i = 0; i < paramsList.count(); i++) {
-        if (paramsList.at(i).startsWith("mlt_profile=")) {
-            if (paramsList.at(i).section('=', 1) != m_profile.path) resizeProfile = true;
-            break;
+
+    QScriptEngine sEngine;
+    sEngine.globalObject().setProperty("bitrate", m_view.comboBitrates->currentText());
+    sEngine.globalObject().setProperty("dar", '@' + QString::number(m_profile.display_aspect_num) + '/' + QString::number(m_profile.display_aspect_den));
+
+    for (int i = 0; i < paramsList.count(); ++i) {
+        QString paramName = paramsList.at(i).section('=', 0, 0);
+        QString paramValue = paramsList.at(i).section('=', 1, 1);
+        // If the profiles do not match we need to use the consumer tag
+        if (paramName == "mlt_profile=" && paramValue != m_profile.path) {
+            resizeProfile = true;
+        }
+        // evaluate expression
+        if (paramValue.startsWith('%')) {
+            paramValue = sEngine.evaluate(paramValue.remove(0, 1)).toString();
+            paramsList[i] = paramName + '=' + paramValue;
         }
+        sEngine.globalObject().setProperty(paramName.toUtf8().constData(), paramValue);
     }
-       
+
     if (resizeProfile)
         render_process_args << "consumer:" + (scriptExport ? "$SOURCE" : playlistPath);
     else