Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st October 2011, 03:08   #1  |  Link
xekon
Registered User
 
Join Date: Jul 2011
Posts: 224
New Application trimsrt trims and shifts srt subtitle file based on range of frames

I made a couple of posts and searched everywhere I could think of for an application that would take an srt subtitle file and trim/shift it based on a range of frames for situations where you do something like this in Avisynth:
Code:
A = NicAC3Source("E:\AviSynth\job.ac3")
V = FFVideoSource("E:\AviSynth\job.mkv")
AudioDub(V, A)
AlignedSplice(Trim(2832, 16727), Trim(16896, 31295))
I was unable to find an application that would do this via command line, so I wrote this program.

The Source code is included, I release it under the GPL.

If you find any problems please report them. If you know c++ and fix a problem or extend the application, please share.

I just started using Avisynth a couple of weeks ago, and I just wrote this application over the last couple days.

So far it has worked perfectly for me, but consider it to be in Beta testing stage.

most of my testing has been using 2 frame ranges (2832,16727,16896,31295), but it should accept as many frame ranges as you need.
Code:
Usage is -i <file> -f <fps> -t <frames>

omitting -f <fps> assumes an fps of 23.976024

trimsrt -i 004.srt -t 2832,16727,16896,31295

trimsrt -i 004.srt -f 29.97 -t 2832,16727,16896,31295
Guide showing trimsrt usage via batch script: http://forum.doom9.org/showthread.php?t=162830

other format conversion to srt tip:
To convert SUB/IDX or .SUP to .SRT. I recommend using Subtitle Edit: http://forum.doom9.org/showthread.php?t=162721
Attached Files
File Type: zip trimsrt.zip (54.6 KB, 127 views)

Last edited by xekon; 25th October 2011 at 21:42.
xekon is offline   Reply With Quote
Old 21st October 2011, 03:36   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
[bump after attachment approval -- thanks for your contribution!]
Guest is offline   Reply With Quote
Old 21st October 2011, 15:45   #3  |  Link
mastrboy
Registered User
 
Join Date: Sep 2008
Posts: 365
Thanks, any chance you will add support for .ass subtitles?

Last edited by mastrboy; 21st October 2011 at 20:02. Reason: typo
mastrboy is offline   Reply With Quote
Old 21st October 2011, 18:55   #4  |  Link
b66pak
Registered User
 
b66pak's Avatar
 
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
thanks a lot...
_
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note...
Visit The Land Of Dracula (Romania - EU)!
b66pak is offline   Reply With Quote
Old 21st October 2011, 21:04   #5  |  Link
xekon
Registered User
 
Join Date: Jul 2011
Posts: 224
Quote:
Originally Posted by mastrboy View Post
Thanks, any chance you will add support for .ass subtitles?
I have not worked with that format but after quickly checking I see that it is also text based so it should be easy enough to add support for.

I will look into it, and see about adding support for that.
xekon is offline   Reply With Quote
Old 21st October 2011, 22:11   #6  |  Link
mastrboy
Registered User
 
Join Date: Sep 2008
Posts: 365
Thanks.. You can easily convert a .srt subtitle to .ass subtitle format with Aegisub if you don't have any .ass files lying around...

Have to say I'm quite surprised you haven't touch .ass subtitles before, it's a superior subtitle format compared to srt.
mastrboy is offline   Reply With Quote
Old 18th March 2015, 22:44   #7  |  Link
duedel
Registered User
 
Join Date: Nov 2014
Posts: 36
Does anyone still use this tool? It sounds exactly like something I'd love to use, unfortunately, the cuts are never correct, and I don't know why.
I noticed that no matter what fps value I entered (-f 25 or -f 50, PAL region), the resulting srt file were exactly the same. What am I missing here?
duedel is offline   Reply With Quote
Old 18th March 2015, 22:49   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Dont know but just a daft suggestion, try eg -f 25.0 or -f 50.0 ie with .0
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 18th March 2015, 22:51   #9  |  Link
duedel
Registered User
 
Join Date: Nov 2014
Posts: 36
Thanks, your quick
Tried it, same result
duedel is offline   Reply With Quote
Old 18th March 2015, 22:58   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Give the exact command that fails please.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 18th March 2015, 23:00   #11  |  Link
xekon
Registered User
 
Join Date: Jul 2011
Posts: 224
Everything I have used it with so far is 23.976 fps.

This was the initial release and I may possibly still have the fps value hard coded in the code.

Unfortunately I am too busy to look at it now, but the source code trimsrt.cpp file was included in the zip, if anyone wants to make updates before I get the time to, feel free.
xekon is offline   Reply With Quote
Old 18th March 2015, 23:06   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
xekon, fps is defaulted to 23.976 FPS and then updated if -f flag used, but not used at all after that, ,seems to use 23.976 for everything.
I'll try to fix it but really dislike the CPP style lib funcs.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 18th March 2015, 23:21   #13  |  Link
duedel
Registered User
 
Join Date: Nov 2014
Posts: 36
Quote:
Originally Posted by StainlessS View Post
I'll try to fix it but really dislike the CPP style lib funcs.
This would be beyond awesome!! Can't wait
duedel is offline   Reply With Quote
Old 18th March 2015, 23:28   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Ok, made changes but getting error
Code:
        char* myFile;
        string myFileb;
        char* myFrames;
        vector<string> v;
        double fps=23.976024;
        for (int i = 1; i < argc; i++) { //We will iterate over argv[] to get the parameters stored inside.
            string param = argv[i];
            if (param == "-i") {
                myFile = argv[i + 1];
                myFileb = string(myFile).substr(0,(string(myFile).length())-4);
                myFileb.append("new.srt");
                i=i++;//skip next param, its a value
            } else if (param == "-f") {
                fps = godouble(argv[i + 1]);
                i=i++;//skip next param, its a value
            } else if (param == "-t") {
                myFrames = argv[i + 1];
                i=i++;//skip next param, its a value                                
                string s = myFrames;
                split(s, ',', v);
                if ((v.size( ) % 2) != 0) {
                    std::cout << "Not an even number of frames, please try again.\n";
                    system("Pause");
                    exit(0);
                }
            } else {
                std::cout << "Not enough or invalid arguments, please try again.\n";
                system("Pause");
                exit(0);
            }
        }
        ifstream a_file (myFile);
        ofstream a_file_out (myFileb);
Error line in red

Code:
Compiling...
trimsrt.cpp
N:\SJ\SOURCE ARCHIVE\VC\AVISYNTH FILTERS\25\_NOTMINE\trimsrt\trimsrt.cpp(123) : error C2664: '__thiscall 
std::basic_ofstream<char,struct std::char_traits<char> >::std::basic_ofstream<char,struct std::char_traits<char> >(const char *,int)' :
cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.

trimsrt.exe - 1 error(s), 0 warning(s)
I never really used CPP libraries for at least 20 years (and only a little bit back then), anybody suggest what is required, some kind of cast ?

EDIT: xekon, what was it originally compiled with ?
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 18th March 2015 at 23:41.
StainlessS is offline   Reply With Quote
Old 18th March 2015, 23:39   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Tried with VS6 originally, re-tried with VS2008 and still same error.
What was it originally compiled with ? (non modded source produces error too).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 18th March 2015 at 23:42.
StainlessS is offline   Reply With Quote
Old 19th March 2015, 00:03   #16  |  Link
duedel
Registered User
 
Join Date: Nov 2014
Posts: 36
I really wish I could help, StainlessS.
Let's hope xekon sees this.
duedel is offline   Reply With Quote
Old 19th March 2015, 00:06   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, managed to get it to compile by adding myFileb.c_str() stuff in blue.

VS2008 compiles OK, but VS6 produces Linker errors about "__security_check_cookie", no idea what that is.

Anyways, heres the fixed (I hope) version together with original source.
http://www.mediafire.com/download/8o...yv/trimsrt.zip

EDIT:
Code:
libcp.lib(xlocale.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th March 2015 at 00:08.
StainlessS is offline   Reply With Quote
Old 19th March 2015, 00:38   #18  |  Link
duedel
Registered User
 
Join Date: Nov 2014
Posts: 36
Yep, working fine now. Again, thank you so much!
duedel is offline   Reply With Quote
Old 19th March 2015, 00:41   #19  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, I'll attach the zip here.

EDIT: No runtimes required.
Attached Files
File Type: zip trimsrt.zip (126.3 KB, 31 views)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th March 2015 at 00:51.
StainlessS is offline   Reply With Quote
Old 22nd January 2016, 10:32   #20  |  Link
xekon
Registered User
 
Join Date: Jul 2011
Posts: 224
Thanks for the update StainlessS! I figured i must forgot to swap out the hard coded values for the variable, strange about those compiler problems, I believe i originally used VS2008, but it could have been VS2010 i really cant remember. Need to remember to put stuff like that in the comments
xekon is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.