|
|
Hy
I want to create a FPS convertor in c#.
input FPS =[24] to output FPS = [23] -it will show.
it will ONLY work with *.srt files, meaning it will have to hunt and modify this type of line:
[00:00:11,409 --> 00:00:14,548] ...(from inside that file).
I want a formula for converting ANY FPS into ANY FPS. (A general formula).
4^789*242/1131(rad45*cons321)/5453+122-vect453E-453/34.23=x__<(something like this, i suppose)
It will NOT work with movie files---only with txt files in *.srt format. That's it.
Thanks.
|
|
|
|
|
_q12_ wrote: I want to create a FPS convertor in c#.
_q12_ wrote: It will NOT work with movie files
Your question does not make sense. FPS conversion actually means you are going to work with the video itself. If you mean subtitle converter and not a FPS converter, it would be best if you first have a basic understanding of the different subtitle formats.
A SRT file is just a text file so you can open and be able to modify it the same way you would open a .txt file. See below for an example.
Subtitle Synchronization with C#[^]
Signature construction in progress. Sorry for the inconvenience.
|
|
|
|
|
subtitle converter, yes.
So, the conversion idea is to Add or Extract seconds and/or milliseconds from existing time. Hmmm.
DateTime.Parse(m.Groups["start"]).AddSeconds(offset);
But if I need to change from a predefined input FPS 23.978 to output FPS 23.976,
then the difference is -0.002 ?
or from 30 into 24, the difference is -06.000 ?
. I did not made something like this ever, its my first time, so I appreciate a straight answer, please. And I know it sound stupid, but I want to be sure before start anything, because can rapidly become a time consuming process. And also, it will be good for others too. Thanks walterhevedeich! Excellent example.
|
|
|
|
|
I still don't get your question. What exactly are you having problems with? Is it on retrieving the date time stamps from the file? Or on the subtracting part? By the way, once you've put the date time stamps on a collection class(a List , for example), I'm sure you won't have a problem on the subtraction/addition part because you already have some code for it.
Signature construction in progress. Sorry for the inconvenience.
|
|
|
|
|
Adding the same offset to all entries does not change the speed of the subtitles, it just shifts them in time.
To change the speed, add a different offset depending on the number of nanoseconds (or some other unit) from the start, or stated differently, multiply the time by something.
For example, to convert 23.978 FPS to 23.976, multiply each time by 23.978 / 23.976, or perhaps slightly more accurately (due to rounding), multiply the time by 23.978, then divide it by 23.976. You can factor out the fact that those are not integers by multiplying by 23978 (make sure there is no overflow) and then dividing by 23976, but if you use integer division, the division always rounds downwards and you get no chance to round To Nearest (so you'd get when using doubles and then rounding).
If you're now thinking "what does multiplying a time even mean", it means taking the number of nanoseconds (or some other unit) that the time represents (it's just an offset from the beginning of course), do the math on that number, and convert it back to a time-thing again (with rounded as necessary).
modified 24-Jul-13 6:23am.
|
|
|
|
|
Extraordinary explanation Harold ! Well done.
But if I have to set that time, not knowing the initial time (i will test some predefined values) but if i am not so lucky in finding that value, how I can proceed?
ex of testing pseudocode :
inputTime=? outputTime=23.976 (i check movie properties);
if inputTime = 30, outputting to 23.976 will have the desired effect?
no?
then, if inputTime = 25, outputting to 23.976 will have the desired effect?
no?
then, if inputTime = 23, ...etc
This i will do manually from a list of defaults (30,25,23,etc) -Or writing it myself in a textbox whatever value i feel is right - but orbiting the default values.
My question is:
if I will have 0 for inputTime, How I will do the math then?
Your solution is: t=t*outputTime/inputTime;
if inputTime >0, t will have some specific duration.
if inputTime = 0 (I don't know what encoding can have that subtitle), t =0 and all my sub time will be 0. Subtitle file ruined.
I must make my program to guess the subtitle encoding (Its FPS encoded time) ?
Or go on manually set the inputTime? (from list of defaults and/or textbox with custom values)
Thank you!
~q12~
modified 25-Jul-13 13:17pm.
|
|
|
|
|
I don't know, I can't think of anything except a manual test that probably doesn't even work well:
See what at time the last line from the subs appears (in the sub file), and compare that with the time in the movie that the last line in the subs should appear. Then, assuming the beginning isn't shifted, you could get an approximate ratio with videotime/subtime, or the approximate old FPS with newfps*videotime/subtime.
|
|
|
|
|
Ok, Harold, Thank you very much for your help.
Your answer is the correct one, that helped me.
[newfps*videotime/subtime] - got it now.
|
|
|
|
|
I am setting formauthentication.setauthcoddkie and on the action i have written [authorise] attribute
now if i type the page url directly it redirects me to login page which is correct
but when i login then it still show the login page
how to make sure that once i have logged in it shows the page. i am using my own custom database and tables
i tried
if (HttpContext.User.Identity.IsAuthenticated) also but it is not going to the controller at all
it just kicks out even if i login
any help is appreciated
|
|
|
|
|
If you could post the code for the custom stuff, that would be handy (edit your original question rather than replying to me will be better).
Without your code it's hard to provide an answer, it sounds like the provider isn't honouring your cookie. One thing I will add is that custom-securing apps is both hard and prone to error, so you really should check out your reasons for doing this. The first thing I'd do in your position is a sanity check: Do I really need custom code, and if so can I base (preferably sub-class) it on the existing providers. In the past subclassing has provided me with the functionality I need whilst saving a lot of hassle. This article[^] explains more fully than I can in a reply such as this.
|
|
|
|
|
I'm creating a socket server in which I'm getting a string like this.
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any, 5656);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
sock.Bind(ipEnd);
sock.Listen(100);
Socket clientSock = sock.Accept();
while (true)
{
clientData = new byte[1024];
receivedBytesLen = clientSock.Receive(clientData);
clientDataInString = Encoding.ASCII.GetString(clientData, 0, receivedBytesLen);
Console.WriteLine("Received Data{0}",clientDataInString);
if(clientDataInString.Contains("Start"))
{
.....any method call....
}
}
I want to use this clientDataInString or the received string in another method.
Like this:
void abc()
{
if(clientDatainString.containg("A"))
{
Console.Writeline("Print A");
}
else if(clientDatainString.containg("B"))
{
Console.Writeline("Print B");
}
}
How can I use this String like this?
Please Suggest..
|
|
|
|
|
CodingHell wrote: How can I use this String like this?
Please Suggest.. Suggest what? You use this string the same way that you would use any string. Your question is not very clear.
Use the best guess
|
|
|
|
|
I'm unable to use the received string in a method because server socket is working in main method but abc method is not a part of this main.
So my motive is to switch and use received string in other methods of my program except where these are being received.
|
|
|
|
|
Then you need to pass the string to the other method as a fuction parameter.
Use the best guess
|
|
|
|
|
Pass the string as a parameter
[...]
Console.WriteLine("Received Data{0}",clientDataInString);
abc(clientDataInString);
} Of course, abc() has to accept a parameter of type System.String then:
void abc(string input)
{
if(input.Contains("A"))
{
Console.WriteLine("Print A");
}
else if(input.Contains("B"))
{
Console.WriteLine("Print B");
}
}
Ciao,
luker
|
|
|
|
|
I'm new to this, or precisely just realize that visual studio had this in the properties folder below visual studio project.
I'm planning to put important things like connection strings inside.
I tried to save a simple text in the setting and save it.
When I run the application, in the debug folder appear "WindowsFormsApplication1.exe.config" file.
I know that it's the setting I created, but the value of the setting is not inside.
When I re-run the application, it was able to load the text i saved before.
Where did the setting save the value?
Btw sorry for bad english.
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Constr = this.textBox1.Text;
Properties.Settings.Default.Save();
}
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Text = Properties.Settings.Default.Constr;
}
Constr is the setting I create.
Actually I'm going to put licensing there too, of course I will encrypt it before I save.
Now I still can't find it.
This is what I use > http://msdn.microsoft.com/en-us/library/aa730869%28v=vs.80%29.aspx[^]
|
|
|
|
|
That's only one of the config files. It's like a blueprint holding the values you enter in Visual Studio at coding time.
What your application saves at runtime is stored in a user-dependent copy of that file somewhere in the region of "Documents and Settings/$YourUserName$/Application Data/$Company$/$ApplicationNameWithSomeAlphaNumericFuzz$/$ProductVersion$/user.config"
The exact location may depend on your OS version.
Ciao,
luker
|
|
|
|
|
lukeer wrote: "Documents and Settings/$YourUserName$/Application Data/$Company$/$ApplicationNameWithSomeAlphaNumericFuzz$/$ProductVersion$/user.config"
I found this but nothing inside.
"C:\Documents and Settings\Administrator\Application Data\Microsoft Corporation\Microsoft (R) Visual Studio (R) 2010\1.0.30319.1"
There are no strange company name in Application Data.
Btw thank you for answering.
Edit :
I found it here[^]
It's just like what you answered, I missed Local Settings before Application Data.
Thank you very much.
modified 23-Jul-13 6:00am.
|
|
|
|
|
Midnight Ahri wrote: I found it here[^]
Documented on MSDN[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have the following Setup:
1) The WPF Thread itself (the MainWindow), which stores the Controls to Display my Content, and the Thread Safe Properties with the content to display.
2) The Update Thread (System.Threading.Thread, not BackgreoundWorker). This Thread updates the Properties of the WPF Thread.
3) The Draw Thread (System.Threading.Thread, not BackgreoundWorker), which actually manipulates the Controls of the WPF Thread (Adding Canvas, Removing Canvas, Setting Text, ...)
My Main problem is the thing, that the WPF Thread is storing the Thread Safe Properties. My Update Routine and Draw Routine are both called very very often (1000 Times a secound).
And thats exactly the problem. The WPF Thread is totally blocked due to the many Get, Set Operations of the other both Threads.
So my first Question is, does someone has an Idea where to store these Properties so the main WPF Thread isn't blocked?
My Secound Problem is the following:
The Update and Draw Thread are both working with the Dispatcher of the WPF thread. If they execute 1000 Times a secound the Dispatcher just runs out of mem (because of too many actions in queue). Is there a way to measure how many actions are in queue and to know if to store another or not. And Secound is there a way to say "Now execute the queue".
I know i can get the state of each dispatcher Object i add. But i don't want to wait till each action is e executed. I want to add as much as possible, so the Update and Draw Thread can run as fast as possible.
My Third side Question is, is my Concept to use WPF for this stupid, or not well planned? Shouldn't i use WPF for this, is there another way to achive my Goal?
My Goal explained:
via Update i have to draw content, very often to be exact, without getting the Part to display the content laggie aka responsive UI.
Please help me with any suggestions or sth else.
As a side Idea i have thought of taking the Thread safe properties into a third thread aka DataThread to store and change, but how can u store Properties into a thread? what is a good way to achive this?
thx in advance
sincerly Synergi
EDIT
Here is an example of one of my Thread Safe Properties. Maybe im loosing much time here. May there is a better Solution for this.
private Nullable<Point> Offset
{
get
{
Nullable<Point> returnValue = null;
object lockObject = objectPool.Aquire();
lockObject = this.offset;
bool locked = false;
bool aquired = false;
System.Threading.Monitor.TryEnter(lockObject, ref locked);
try
{
if (locked)
{
returnValue = this.offset;
aquired = true;
}
}
finally
{
if (locked && aquired)
{
System.Threading.Monitor.Exit(lockObject);
}
}
objectPool.Release(lockObject);
return returnValue;
}
set
{
object lockObject = objectPool.Aquire();
lockObject = this.offset;
bool locked = false;
bool aquired = false;
System.Threading.Monitor.TryEnter(lockObject, ref locked);
try
{
if (locked)
{
if (value.HasValue)
{
this.offset = value.Value;
aquired = true;
}
}
}
finally
{
if (locked && aquired)
{
System.Threading.Monitor.Exit(lockObject);
}
}
objectPool.Release(lockObject);
}
}
modified 22-Jul-13 21:16pm.
|
|
|
|
|
I SERIOUSY DOUBT you're getting 1,000 frames per second nor even have the hardware that can do it. There's just no point to it because the human eye just can't see that. Knock that back to AT MOST 60 frames a second and you might improve your situation dramatically.
|
|
|
|
|
I miss discribed my situation. I dont have over 1000 Frames, my update & Draw Thread are called more then 1000 Times. But that doesn't mean it is really the Render Thread of DirectX.
So now with ur conclusion of slowing it down to 60 fps the gui is now responsive again. Easy Solution.
Side way i still ask if someone knows a way to store properties out of the WPF Thread?
|
|
|
|