15,891,529 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by malcomm (Top 11 by date)
malcomm
23-Dec-13 15:38pm
View
Thanks for that. Perfect!
malcomm
1-Jul-13 16:58pm
View
Thanks Mike
Not sure if you got the bit about my app working perfectly UNTIL it is run under Win7 Scheduler?
Not really much difference in our code when it all boils down except that I am referencing a font via 'drawtext' which you do not. Good idea about capturing the entire error stream, didn't think of that - I was only capturing the frame rate for progress indication. When I capture the entire stream, it shows a failure loading the font -
[drawtext @ 01A39000] Could not load fontface from file 'TWCAB___.TTF': cannot open resource
Error initializing filter 'drawtext' with args 'fontfile=TWCAB___.TTF:text=Linley Point, NSW:x=790:y=96:fontsize=20:fontcolor=white:shadowcolor=0x000000EE:shadowx=1.5:shadowy=1.5'
Error opening filters!
The font is in the bin folder where it should be and therefore supposedly doesn't need a path specified. Remember it works fine in standalone and this problem only occurs under the Scheduler.
Well you can't just give it a normal path as the colon and forward slash are reserved ffmpeg drawtext commands so you have to change things thus - C:\AppPath\fontname.ttf becomes 'C\:\\AppPath\\fontname.ttf'. Note the single quotes around it in case there are spaces in the path name.
And that is working now in Scheduler.
Hooray!!!
BTW my paths are correct.
malcomm
19-Sep-12 20:40pm
View
Hi Pete
Your code has given me some vaulable knowledge but unfortunately has failed to give me a solution to the Win7 Schduler crap.
I've gotten it to point where Win7 scheduler will fire up ffmpeg from within my app but ffmpeg is now failing with its internal processes...
I'm going to replace the Win7 scheduler and see how that goes.
Many thanks for all help. Your ideas have already been incorporated into another project of mine so are greatly appreciated.
regards
Malcom
malcomm
17-Sep-12 1:33am
View
Pete
If you want to send yourself nuts with this, heres the XML that Scheduler exports for this app- WebCam_Archerfield_NNE.exe is the app name.
If you run Win7 then you could import that into scheduler and ruin your day a bit...
<task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<registrationinfo>
<date>2012-09-13T14:44:35.2076061
<author>Malcom-PC\Malcom
<Triggers>
<calendartrigger>
<startboundary>2012-09-13T14:43:46.4258159
<enabled>false
<schedulebyday>
<daysinterval>1
</Triggers>
<Principals>
<Principal id="Author">
<userid>Malcom-PC\Malcom
<logontype>InteractiveToken
<runlevel>HighestAvailable
</Principal>
</Principals>
<settings>
<multipleinstancespolicy>IgnoreNew
<disallowstartifonbatteries>true
<stopifgoingonbatteries>true
<allowhardterminate>true
<startwhenavailable>false
<runonlyifnetworkavailable>false
<idlesettings>
<stoponidleend>true
<restartonidle>false
<allowstartondemand>true
<enabled>true
<hidden>false
<runonlyifidle>false
<disallowstartonremoteappsession>false
<useunifiedschedulingengine>false
<waketorun>false
<executiontimelimit>P3D
<Priority>7</Priority>
<actions context="Author">
<exec>
<command>"C:\Users\Malcom\Documents\Visual Studio 2008\Projects\WebCams\TAWN WebCams QLD\WebCam_Archerfield_NNE\bin\Debug\WebCam_Archerfield_NNE.exe"
<arguments>True
malcomm
17-Sep-12 1:24am
View
I ran it again with a command of 'ProcessAsUser.Launch("C:\Windows\notepad.exe")'.
Same results with the LaunchProcessAsUser function-
result = CreateProcessAsUser etc is returning false
I'll try the library as well as I have some 70 scheduled items that need to be manually entered if I ever get the roitten thing working. That'll save me a ton of time as I've had no luck creating schedule tasks in code so far.
Thanks
Malcom
malcomm
16-Sep-12 22:52pm
View
OK, I'm an idiot.
I didn't realise you are using 'explorer' as a way to get the logged on users identity. I had replaced it with ffmpeg.
OK, well unfortunately still no luck.
Within LaunchProcessAsUser, result = CreateProcessAsUser... is returning false
It all runs fine when not under Scheduler control.
Don't give up me now Pete :)
malcomm
16-Sep-12 21:42pm
View
Thanks Pete
back soon :)
malcomm
16-Sep-12 21:04pm
View
Yup, hell of a command line but it is passing the app name + vaiables so should be ok.
Exactly the same details as what my ExecuteDosCommand function above handles.
Yes the quotes are part of it as created (in part)via this -
Dim strOptions As String = " -vf " & Chr(34) & "[in]crop=in_w:in_h-20:0:0,scale=1024:576 etc etc
So the quotes appear from ' & Chr(34) & '
malcomm
16-Sep-12 20:43pm
View
I placed your code into a module in my existing app.
No, I screwed up and just placed the command variables into the appcmdline and the assumed the process was determined by the process name variable. doh!
Changed that now but I'm still having the same result.
Withing the Launch function, the appCmdLine variable is coming through as
"C:\Users\Malcom\Documents\Visual Studio 2008\Projects\WebCams\TAWN WebCams QLD\WebCam_Archerfield_NNE\bin\Debug\ffmpeg.exe -r 15 -i "D:\fcp_buffer\webcams\kalbar\%04d.jpg" -vf "[in]crop=in_w:in_h-20:0:0,scale=1024:576,drawtext=fontfile=TWCAB___.TTF:text='Archerfield, QLD':x=129:y=54:fontsize=25:fontcolor=white:shadowcolor=0x000000EE:shadowx=1.5:shadowy=1.5, drawtext=fontfile=TWCAB___.TTF:text='Monday':x=129:y=82:fontsize=16:fontcolor=white:shadowcolor=0x000000EE:shadowx=1:shadowy=1[out]" -b 6000k -s 720x576 -vcodec wmv2 -an -y "D:\fcp_buffer\webcams\kalbar\Archerfield_NNE.wmv""
The process name variable is set to "ffmpeg"
Stepping through-
ps.Length = 0
processId = -1
and obviously it returns false.
What else have I misunderstood :)
malcomm
16-Sep-12 19:45pm
View
No luck with that one. Behaves thesame.
Thanks anyway...
malcomm
16-Sep-12 19:45pm
View
Whew... and thanks
OK, I had a crack at this but now I'm lost.
As I understand it, the 'Launch' method looks for aprocess match in processes that are already running?
How do I tell it to start ffmpeg?
This is tehcode I currently use to run ffmpeg-
targetEXE is something like d:\xxx\ffmpeg.exe
arguments is something like " -vf scale=720:576 -f mov -vcodec dvvideo -r 25 -pix_fmt yuv411p -vtag dvpp -y " + outputFileName
Private Function ExecuteDosCommand(ByVal targetEXE As String, ByVal arguments As String, ByVal fileName As String) As Integer
Dim iCount As Integer = 0
Dim iExitCode As Integer = 0
Using processTranscode As New System.Diagnostics.Process
processTranscode.StartInfo.UseShellExecute = False
processTranscode.StartInfo.RedirectStandardOutput = True
processTranscode.StartInfo.RedirectStandardError = True
processTranscode.StartInfo.CreateNoWindow = True
processTranscode.StartInfo.WindowStyle = ProcessWindowStyle.Normal '.Hidden
processTranscode.StartInfo.FileName = targetEXE
processTranscode.StartInfo.Arguments = arguments
Try
processTranscode.Start()
Dim readLine As String = ""
Dim sErr As System.IO.StreamReader = processTranscode.StandardError()
Do While Not sErr.EndOfStream
readLine = sErr.ReadLine
If Not bMinimised Then
If readLine.Contains("frame") And readLine.Contains("fps") Then
Dim i1 As Integer = readLine.IndexOf("fps")
Dim s As String = readLine.Substring(0, i1)
s = "Transcoding " & fileName & " - " & s
Me.lblStatus.Text = s
Me.Refresh()
Application.DoEvents()
End If
End If
If processTranscode.HasExited Then Exit Do
Loop
sErr.Close()
Catch ex As Exception
Try
processTranscode.Close()
Catch ex1 As Exception
'
End Try
Return 6
End Try
killProc: If Not processTranscode.HasExited Then
processTranscode.Kill()
End If
Application.DoEvents()
iExitCode = processTranscode.ExitCode
processTranscode.Close()
End Using
Return iExitCode
End Function 'ExecuteDosCommand
regards
Malcom
Show More