Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Sorting a .srt file for vlc player
Forum Updated to NodeBB v4.3 + New Features

Sorting a .srt file for vlc player

Scheduled Pinned Locked Moved Mobile and Embedded
15 Posts 3 Posters 5.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #2

    Put each line in a single QString, put the QString into a QStringList and sort it afterwards:

    @
    QStringList pauseTimes;

    pauseTimes << QString("%1,00-->%2,999").arg(strc).arg(strc);

    pauseTimes.sort();

    QTextStream out(file);
    out << pauseTimes.join("\n");
    @

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ajayzizou
      wrote on last edited by
      #3

      [[blank-post-content-placeholder]]

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ajayzizou
        wrote on last edited by
        #4

        i commented these lines

        @ // QTextStream out(AjayFileD);
        //out<<"\n"<<strc<<",000"<<"-->"<<strc<<",999"<<"\n";@

        and i added this code
        @QStringList pauseTimes;

        pauseTimes << QString("%1,00--&gt;%2,999").arg(strc).arg(strc);
         
        pauseTimes.sort();
         
        QTextStream out(AjayFileD);
        out << pauseTimes.join("\n");@
        

        thank you sir, but i'm getting this error
        "collect2: ld returned 1 exit status"

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #5

          Go to the windows/tab with the complete output of your compiler and linker. It tells you which symbols are missing. Without that information we cannot advise further.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ajayzizou
            wrote on last edited by
            #6

            the previous error “collect2: ld returned 1 exit status” is solved,it was just a typing error,i'm getting the subtitles but it is not getting sorted,even though there is no error,pls can you suggest

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ajayzizou
              wrote on last edited by
              #7

              also I've used @out << "\n" << pauseTimes.join("\n") << "\n" ;
              @ instead of just @out << pauseTimes.join("\n");@

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #8

                perhaps you can post your current code and the result you now get?

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ajayzizou
                  wrote on last edited by
                  #9

                  @ QStringList pauseTimes;

                   pauseTimes << QString("%1,000--&gt;%2,999").arg(strc).arg(strc);
                    pauseTimes.sort();
                  

                  QTextStream out(AjayFileD);

                  out << "\n" << pauseTimes.join("\n") << "\n" ;@
                  the same code suggested by volker, and the result
                  00:00:00,000-->00:00:00,999

                  00:15:34,000-->00:15:34,999

                  00:34:39,000-->00:34:39,999

                  00:05:28,000-->00:05:28,999

                  1:32:35,000-->1:32:35,999

                  1:15:11,000-->1:15:11,999

                  00:12:54,000-->00:12:54,999
                  as you can see the pause times are not getting sorted in ascending order,i think it's just some small change but I'm stuck and btw i'm a beginner

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #10

                    Hi,

                    whatever you do, I checked the following code and it's output:

                    @
                    int main(int argc, char *argv[])
                    {
                    QStringList pauseTimes;
                    pauseTimes << QLatin1String("00:00:00,000—>00:00:00,999");
                    pauseTimes << QLatin1String("00:15:34,000—>00:15:34,999");
                    pauseTimes << QLatin1String("00:34:39,000—>00:34:39,999");
                    pauseTimes << QLatin1String("00:05:28,000—>00:05:28,999");
                    pauseTimes << QLatin1String("1:32:35,000—>1:32:35,999");
                    pauseTimes << QLatin1String("1:15:11,000—>1:15:11,999");
                    pauseTimes << QLatin1String("00:12:54,000—>00:12:54,999");

                    std::wcout << std::endl <<  (wchar_t*)(pauseTimes.join("\n").utf16()) << std::endl ;
                    std::wcout << L"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
                    pauseTimes.sort();
                    std::wcout << std::endl <<  (wchar_t*)(pauseTimes.join("\n").utf16()) << std::endl ;
                    
                    return 0;
                    

                    }
                    @

                    The output was:

                    @

                    00:00:00,000ù>00:00:00,999
                    00:15:34,000ù>00:15:34,999
                    00:34:39,000ù>00:34:39,999
                    00:05:28,000ù>00:05:28,999
                    1:32:35,000ù>1:32:35,999
                    1:15:11,000ù>1:15:11,999
                    00:12:54,000ù>00:12:54,999

                    
                    00:00:00,000ù>00:00:00,999
                    00:05:28,000ù>00:05:28,999
                    00:12:54,000ù>00:12:54,999
                    00:15:34,000ù>00:15:34,999
                    00:34:39,000ù>00:34:39,999
                    1:15:11,000ù>1:15:11,999
                    1:32:35,000ù>1:32:35,999
                    @
                    
                    For me, the output looks sorted....
                    

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ajayzizou
                      wrote on last edited by
                      #11

                      yeah thanks a lot,this is what i want,however i'm not entering the pause time manually,the pause time will be in const char *strc as soon as i press the pause button of the player,i'll use your code and post if i have any problem
                      thanks once again

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #12

                        is the content of the array really 8 strings? or perhaps one multiline string?

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          ajayzizou
                          wrote on last edited by
                          #13

                          no,i've just hit the pause button 8 times,so eight outputs,i can get this written into the file as many times as i like,so it is not just 8 strings ,the only problem is sorting and i'll use your code for that

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #14

                            You will need to store the stop points in a QStringList - or re-read the file, add the new line, sort an overwrite the existing data. You don't expect the file to sort automagically, do you?

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              ajayzizou
                              wrote on last edited by
                              #15

                              thank you,i'll try

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved