Now TV stations basically have their own portals. We can make full use of the advantages of the network and expand the influence of local TV stations. In fact, hanging local TV stations' ace programs on the website has become one of the necessary steps to establish a TV station website. How much do you know about the automatic recording of files and vbs scripts? Let the editor of the Foot New Technology Channel take you to learn more about it!
1: Create a coding task
We will use a computer with a video acquisition card to complete the coding process. Although coding is not the focus of this article, it is still necessary to explain it. The main thing is to use helix producer plus9 to create a coded parameter file. In fact, it is just an XML file with rpjf suffix (Figure 1). It should be noted that the audio input options include wire input and microphone input, which need to be consistent with the actual access line; in addition, you do not have to select the 2 pass vedio encoding option, and selecting it will not have any effect except displaying a warning; in addition, because most network access modes at this stage are dialing and dsl, you only need to generate video files with 56k and 384k bit rates; finally, the name of the recorded video file is best identified by date, such as: 20060301.rm.
false
ZSTV
(c) ZSTV2006
ZSNews[2006-03-21]
ZSNews[2006-03-21]
Intel(r) Integrated Audio
....................................................
We can create a batch file named shixian.bat to call the parameter file shown above, the internal details are as follows:
producer -j "d:/shixian/shixian.rpjf" -daw -lc "e,i"
The default recording process will monitor audio changes in real time and record it in a file called producer.log. However, there are many wanging records, which quickly makes the log file huge and may cause unexpected interruptions in the recording process. Therefore, we can use the -daw parameter to turn off audio monitoring, and then use lc "e,i" to indicate that only errors and information are recorded. After doing this, the recording process becomes more stable.
Just add the task of executing the shixian.bat file daily in the plan, we will get a rm file with the same file attributes and names every day. Here a file named 20060321.rm with the 2006-03-21 attribute will be generated every day. It sounds terrible, and worse yet it doesn't ease the manager's job because he has to open the server every day to change the name. And even though he was lucky enough to hire a hard-working administrator (he didn't mind doing such repetitive things every day), he still couldn't change the properties of the date displayed in the file, which had been decided during the recording process. unless…….
2: Create a task to modify the coded parameter file
The principle is very simple: update the xml fields related to date in the coded parameter file every day. In this example, the file displays the attributes and file names. Here is the script code used to update the date field:
dim regOR
set regOR=new regexp ' Create a regular expression object
regOR.ignorecase=True ' Ignore case
regOR.global=True ' Search applies to the entire string
regOR.pattern="^([0-9]{1})$" ' Create a single-number expression for search mode
dim mytime
mytime=date ' Use the date function to reach the system date and assign it to mydate
yy=year(mytime) ' Extract the year in the system date
mm=month(mytime) ' Extract the month in the system date
dd=day(mytime) ' Extract the date in the system date
if regOR.test(mm) then ' Check whether the month is a single number (January to September)
mm=regOR.replace(mm,"0$1") ' If so, add 0 before the month to make it two numbers
end if
if regOR.test(dd) then ' Check whether the date is a single number (one day to nine days)
dd=regOR.replace(dd,"0$1") ' If yes, add 0 before the date to make it two numbers
end if
mytime=yy & "-" & mm & "-" & dd ' The merged year, month and day are in the form "yy-mm-dd"
dest=yy & mm & dd ' The merged year, month and day are in the form "yymmdd"
pattern1="(.*[^0-9])([0-9]{4}/-[0-9]{2}/-[0-9]{2})([^0-9].*)"
' Set the mode variable pattern1 to "%d%d%d %d- %d %d -%d %d"
pattern2="(.*[^0-9])([0-9]{8})([^0-9].*)" ' Set the mode variable pattern2 to 8 consecutive numbers
regOR.pattern=pattern1 ' Create search mode as pattern1
dim tempstring
Set fso = CreateObject("Scripting.FileSystemObject") ' Create system file object
Set f = fso.CreateTextFile("d:/shixian/temp.txt", True) ' Create a new text file named temp
Set fr = fso.GetFile("d:/shixian/shixian.rpjf") ' Get the encoding parameter file shixian.rpjf
Set ts = fr.OpenAsTextStream(1,-2) ' Open the parameter file as read-only text
do until ts.AtEndOfStream ' Create a loop until the parameter file is read
tempstring=ts.readline ' Read parameter file in behavior units
if regOR.test(tempstring) then ' Search for the date field exists in the change line parameter
tempstring=regOR.replace(tempstring,"$1" & mytime & "$3") ' If present, update
end if
regOR.pattern=pattern2 ' Create search mode as pattern2
if regOR.test(tempstring) then ' Search for the date field exists in the change line parameter
tempstring=regOR.replace(tempstring,"$1" & dest & "$3") ' If present, update
end if
regOR.pattern=pattern1 ' Re-establish the search mode as pattern1
f.writeline(tempstring) ' Write updated data to the temp.txt file
loop
ts.close 'The following is to close and log out individual objects
f.close
set regOR=nothing
set ts=nothing
set fr=nothing
set f=nothing
set fso=nothing
What is to be explained is why you need to add 0 before the month and date of a single number. It is easier to explain for an example: if 0 is not added, then for a file named 2006111.rm, does it refer to January 11, 2006 or November 1, 2006? After adding 0, it becomes 20060111.rm and it is clear at a glance, it is the former.
The specific function of the above script code is to import the data in the parameter file into a temporary text file in behavior units, monitor the time-related xml fields in real time and update it, and finally generate a temp.txt file. After that, all we have to do is to call the script with a batch file, then delete the old parameter file, and finally rename temp.txt to the parameter file.
This is the code in the update.bat batch file:
@echo off
d:/shixian/update.vbs
if exist "d:/shixian/shixian.rpjf" del "d:/shixian/shixian.rpjf"
if exist "d:/shixian/temp.txt" rename d:/shixian/temp.txt shixian.rpjf
As in the first section, add this batch file of update.bat to the schedule and task so that it can be started regularly every day.
3: Establish automatic transmission task
In order to ensure stability, the codec server is usually separated from the website server, which requires us to transfer the recorded video files to the website server every day. The ftp command in the batch file can perfectly implement this function.
The following is the code in the transfer.bat batch processing:
@echo off
ftp -s:media.txt
if exist "d:/shixian/shixian20060321.rm" del d:/shixian/shixian20060321.rm
Considering the amazing price of SCSI hard disks, the hard disk space of the coded server does not need to be too large. The purpose of the last line is to delete the video files in the coded server to save space. Media.txt is an ftp parameter file that records the name, user name, password and related operations of the ftp login server. The specific form is as follows:
open / Server name or IP address /
/ username/
/ User Password/
put / File name to be transferred/
quit
It is obvious that there are many date literal expressions that need to be updated in the above paragraphs of code. By the same token, we also need to use a similar update script, so the specific code will not be repeated.
4: Some improvements
1: Using media player can also realize the coding function.
2: In the update script, there are several lines of code used on the declaration and logout objects, which can be greatly simplified if you use perl. Because perl provides a series of operator symbols to implement the function of regular expressions, in fact perl is created to process text.
open(RPJF,"
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
$mday=sprintf("%.2d",$mday);
$mon=sprintf("%.2d",$mon+1);
$year+=1900;
$timerF="$year"."$mon"."$mday";
$timerS="$year"."-","$mon"."-","$mday";
While(
chomp();
$_=~s/(.*)([0-9]{8})(.*)/$1$timerF$3/;
$_=~s/(.*)([0-9]{4}/-[0-9]{2}/-[0-9]{2})(.*)/$1$timerS$3/;
print TEMP "$_/n";
}
close(RPJF);
close(TEMP);
3: Using disk mapping can enable file transfer more conveniently, but security issues need to be considered.
The above is wrong. The editor of the new technology channel shares with you to teach you how to automatically record videos on files and vbs scripts websites. I hope it will be of some help to everyone's learning!