[vlc-devel] [PATCH v3 3/3] fix: Deinterlace can be associated with codec arguments

Jérôme Froissart software at froissart.eu
Mon Oct 28 22:15:49 CET 2019


Previously, one could not convert a video into a video with both:
 * deinterlace checked (in the Convert dialog)
 * custom options (in "Profile edition" dialog, "Video codec" tab)
This was due to incorrectly handled braces in a SoutChain.

This patch requires to make VLCProfileSelector::getTranscode() return a SoutChain instead of a plain QString, which eases the handling of the sout chain
---
 .../qt/components/sout/profile_selector.cpp   | 78 +++++++++----------
 .../qt/components/sout/profile_selector.hpp   |  5 +-
 modules/gui/qt/dialogs/convert.cpp            | 37 ++++++---
 modules/gui/qt/dialogs/sout.cpp               |  4 +-
 4 files changed, 66 insertions(+), 58 deletions(-)

diff --git a/modules/gui/qt/components/sout/profile_selector.cpp b/modules/gui/qt/components/sout/profile_selector.cpp
index 82c3eaa1a8..a625926c54 100644
--- a/modules/gui/qt/components/sout/profile_selector.cpp
+++ b/modules/gui/qt/components/sout/profile_selector.cpp
@@ -204,7 +204,7 @@ void VLCProfileSelector::updateOptions( int i )
     if ( rx.indexIn( options ) != -1 )
         return updateOptionsOldFormat( i );
 
-    transcode = "";
+    transcode.clear();
 
     QStringList tuples = options.split( ";" );
     typedef QHash<QString, QString> proptovalueHashType;
@@ -243,8 +243,7 @@ void VLCProfileSelector::updateOptions( int i )
     }\
     else value = QString()
 
-    SoutChain smrl;
-    smrl.begin( "transcode" );
+    transcode.begin( "transcode" );
 
     /* First muxer options */
     HASHPICK( "muxer", "mux" );
@@ -258,19 +257,19 @@ void VLCProfileSelector::updateOptions( int i )
 
         if ( !value.isEmpty() )
         {
-            smrl.option( "vcodec", value );
+            transcode.option( "vcodec", value );
 
             HASHPICK( "vcodec", "bitrate" );
             if ( value.toInt() > 0 )
             {
-                smrl.option( "vb", value.toInt() );
+                transcode.option( "vb", value.toInt() );
             }
 
             HASHPICK( "video", "filters" );
             if ( !value.isEmpty() )
             {
                 QStringList valuesList = QUrl::fromPercentEncoding( value.toLatin1() ).split( ";" );
-                smrl.option( "vfilter", valuesList.join( ":" ) );
+                transcode.option( "vfilter", valuesList.join( ":" ) );
             }
 
             /*if ( codec is h264 )*/
@@ -287,28 +286,28 @@ void VLCProfileSelector::updateOptions( int i )
                     codecoptions << QUrl::fromPercentEncoding( value.toLatin1() );
 
                 if ( codecoptions.count() )
-                    smrl.option( "venc",
+                    transcode.option( "venc",
                         QString("x264{%1}").arg( codecoptions.join(",") ) );
             }
 
             HASHPICK( "vcodec", "framerate" );
             if ( !value.isEmpty() && value.toInt() > 0 )
-                smrl.option( "fps", value );
+                transcode.option( "fps", value );
 
             HASHPICK( "vcodec", "scale" );
             if ( !value.isEmpty() )
-                smrl.option( "scale", value );
+                transcode.option( "scale", value );
 
             HASHPICK( "vcodec", "width" );
             if ( !value.isEmpty() && value.toInt() > 0 )
-                smrl.option( "width", value );
+                transcode.option( "width", value );
 
             HASHPICK( "vcodec", "height" );
             if ( !value.isEmpty() && value.toInt() > 0 )
-                smrl.option( "height", value );
+                transcode.option( "height", value );
         }
     } else {
-        smrl.option( "vcodec", "none" );
+        transcode.option( "vcodec", "none" );
     }
 
     HASHPICK( "audio", "enable" );
@@ -317,27 +316,27 @@ void VLCProfileSelector::updateOptions( int i )
         HASHPICK( "audio", "codec" );
         if ( !value.isEmpty() )
         {
-            smrl.option( "acodec", value );
+            transcode.option( "acodec", value );
 
             HASHPICK( "acodec", "bitrate" );
-            smrl.option( "ab", value.toInt() );
+            transcode.option( "ab", value.toInt() );
 
             HASHPICK( "acodec", "channels" );
-            smrl.option( "channels", value.toInt() );
+            transcode.option( "channels", value.toInt() );
 
             HASHPICK( "acodec", "samplerate" );
-            smrl.option( "samplerate", value.toInt() );
+            transcode.option( "samplerate", value.toInt() );
 
             HASHPICK( "audio", "filters" );
             if ( !value.isEmpty() )
             {
                 QStringList valuesList = QUrl::fromPercentEncoding( value.toLatin1() ).split( ";" );
-                smrl.option( "afilter", valuesList.join( ":" ) );
+                transcode.option( "afilter", valuesList.join( ":" ) );
             }
 
         }
     } else {
-        smrl.option( "acodec", "none" );
+        transcode.option( "acodec", "none" );
     }
 
     HASHPICK( "subtitles", "enable" );
@@ -347,20 +346,18 @@ void VLCProfileSelector::updateOptions( int i )
         if ( value.isEmpty() )
         {
             HASHPICK( "subtitles", "codec" );
-            smrl.option( "scodec", value );
+            transcode.option( "scodec", value );
         }
         else
         {
-            smrl.option( "soverlay" );
+            transcode.option( "soverlay" );
         }
     } else {
-        smrl.option( "scodec", "none" );
+        transcode.option( "scodec", "none" );
     }
-    smrl.end();
+    transcode.end();
 #undef HASHPICK
 
-    transcode = smrl.to_string();
-
     cleanup:
     /* Temp hash tables cleanup */
     foreach( proptovalueHashType *hash, categtopropHash )
@@ -377,52 +374,49 @@ void VLCProfileSelector::updateOptionsOldFormat( int i )
 
     mux = options[0];
 
-    SoutChain smrl;
     if( options[1].toInt() || options[2].toInt() || options[3].toInt() )
     {
-        smrl.begin( "transcode" );
+        transcode.begin( "transcode" );
 
         if( options[1].toInt() )
         {
-            smrl.option( "vcodec", options[4] );
+            transcode.option( "vcodec", options[4] );
             if( options[4] != "none" )
             {
-                smrl.option( "vb", options[5].toInt() );
+                transcode.option( "vb", options[5].toInt() );
                 if( !options[7].isEmpty() && options[7].toInt() > 0 )
-                    smrl.option( "fps", options[7] );
+                    transcode.option( "fps", options[7] );
                 if( !options[6].isEmpty() )
-                    smrl.option( "scale", options[6] );
+                    transcode.option( "scale", options[6] );
                 if( !options[8].isEmpty() && options[8].toInt() > 0 )
-                    smrl.option( "width", options[8].toInt() );
+                    transcode.option( "width", options[8].toInt() );
                 if( !options[9].isEmpty() && options[9].toInt() > 0 )
-                    smrl.option( "height", options[9].toInt() );
+                    transcode.option( "height", options[9].toInt() );
             }
         }
 
         if( options[2].toInt() )
         {
-            smrl.option( "acodec", options[10] );
+            transcode.option( "acodec", options[10] );
             if( options[10] != "none" )
             {
-                smrl.option( "ab", options[11].toInt() );
-                smrl.option( "channels", options[12].toInt() );
-                smrl.option( "samplerate", options[13].toInt() );
+                transcode.option( "ab", options[11].toInt() );
+                transcode.option( "channels", options[12].toInt() );
+                transcode.option( "samplerate", options[13].toInt() );
             }
         }
 
         if( options[3].toInt() )
         {
-            smrl.option( "scodec", options[14] );
+            transcode.option( "scodec", options[14] );
             if( options[15].toInt() )
-                smrl.option( "soverlay" );
+                transcode.option( "soverlay" );
         }
 
-        smrl.end();
-
-        transcode = smrl.to_string();
+        transcode.end();
     }
     else
-        transcode = "";
+        transcode.clear();
     emit optionsChanged();
 }
 
diff --git a/modules/gui/qt/components/sout/profile_selector.hpp b/modules/gui/qt/components/sout/profile_selector.hpp
index 1074c7b220..1a3322511b 100644
--- a/modules/gui/qt/components/sout/profile_selector.hpp
+++ b/modules/gui/qt/components/sout/profile_selector.hpp
@@ -30,6 +30,7 @@
 #include <QHash>
 
 #include "util/qvlcframe.hpp"
+#include "util/soutchain.hpp"
 #include "ui_profiles.h"
 
 class QComboBox;
@@ -42,14 +43,14 @@ public:
     VLCProfileSelector( QWidget *_parent );
     ~VLCProfileSelector();
     QString getMux() { return mux; }
-    QString getTranscode() { return transcode; }
+    SoutChain getTranscode() { return transcode; }
 private:
     QComboBox *profileBox;
     void fillProfilesCombo();
     void editProfile( const QString&, const QString& );
     void saveProfiles();
     QString mux;
-    QString transcode;
+    SoutChain transcode;
 private slots:
     void newProfile();
     void editProfile();
diff --git a/modules/gui/qt/dialogs/convert.cpp b/modules/gui/qt/dialogs/convert.cpp
index a6505a6fd0..f8ff83d095 100644
--- a/modules/gui/qt/dialogs/convert.cpp
+++ b/modules/gui/qt/dialogs/convert.cpp
@@ -176,21 +176,20 @@ void ConvertDialog::close()
 
     for(int i = 0; i < incomingMRLs->length(); i++)
     {
-        QString mrl;
+        SoutChain mrl;
 
         if( dumpRadio->isChecked() )
         {
-            mrl = "demux=dump :demuxdump-file=" + fileLine->text();
+            mrl.header("demux=dump :demuxdump-file=" + fileLine->text());
         }
         else
         {
-            mrl = "sout=#" + profile->getTranscode();
+            mrl = profile->getTranscode();
+            mrl.header( "sout=#" + mrl.getHeader() );
             if( deinterBox->isChecked() )
             {
-                mrl.remove( '}' );
-                mrl += ",deinterlace}";
+                mrl.option("deinterlace");
             }
-            mrl += ":";
 
             QString newFileName;
 
@@ -229,15 +228,29 @@ void ConvertDialog::close()
 
             newFileName.replace( QChar('\''), "\\\'" );
 
-            QString chain = QString("std{access=file{no-overwrite},mux=%1,dst='%2'}")
-                                    .arg( profile->getMux() ).arg( newFileName );
+
+            mrl.end();
+            SoutModule dstModule("std");
+            SoutModule file("file");
+            file.option("no-overwrite");
+            dstModule.option("access", file);
+            dstModule.option("mux", profile->getMux());
+            dstModule.option("dst", "'" + newFileName + "'");
+
             if( displayBox->isChecked() )
-                mrl += QString( "duplicate{dst=display,dst=%1}" ).arg( chain );
+            {
+                SoutModule duplicate("duplicate");
+                duplicate.option("dst", "display");
+                duplicate.option("dst", dstModule);
+                mrl.module(duplicate);
+            }
             else
-                mrl += chain;
+            {
+                mrl.module(dstModule);
+            }
         }
-        msg_Dbg( p_intf, "Transcode chain: %s", qtu( mrl ) );
-        mrls.append(mrl);
+        msg_Dbg( p_intf, "Transcode chain: %s", qtu( mrl.to_string() ) );
+        mrls.append(mrl.to_string());
     }
     accept();
 }
diff --git a/modules/gui/qt/dialogs/sout.cpp b/modules/gui/qt/dialogs/sout.cpp
index 21457d5807..ac09805178 100644
--- a/modules/gui/qt/dialogs/sout.cpp
+++ b/modules/gui/qt/dialogs/sout.cpp
@@ -179,9 +179,9 @@ void SoutDialog::updateChain()
     QString qs_mux = ui.profileSelect->getMux();
 
     SoutChain smrl( ":sout=#" );
-    if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
+    if( !ui.profileSelect->getTranscode().to_string().isEmpty() && ui.transcodeBox->isChecked() )
     {
-        smrl.begin( ui.profileSelect->getTranscode() );
+        smrl.begin( ui.profileSelect->getTranscode().to_string() );
         smrl.end();
     }
 
-- 
2.20.1



More information about the vlc-devel mailing list