- 论坛徽章:
- 0
|
本帖最后由 zhjwlgh01 于 2017-05-21 10:25 编辑
自己写了个函数,求大神优化$testCommand = 'gst-launch-1.0 qcarcamsrc dumpable=true input=0 ! video/x-raw, format=NV12, width=720, height=480, framerate=30/1 ! queue ! omxmpeg4videoenc ! avimux ! filesink location=/data/captured/camera0-D1-30fps-mpeg4.avi';
sub checkResult{
my $cmd = undef;
my $cmdresult = undef;
my $recordFile = undef;
my $line = undef;
my $recordFileName = undef;
my $dumpFormat = undef;
my $playList = undef;
my @recordFileName = ("cam" , "fromfile", "dump", "encoder","videosrcsh264enc"); # Used for getting the record file
my @dumpFormat = (".avi", ".mkv", ".h263" , ".264" , ".h265" , ".NV12" , ".nv12" , ".dump" , ".mpeg4"); #Used for getting the dump file which can't be playback in the device
my @playList = (".avi", ".mkv", ".h263" , ".264" , ".h265" ,".mpeg4"); #Used for checking the record file could be playback
my $checkResult = CommonUtils::FAIL;
#Got dunmp file name from the testCommand first;
foreach $recordFile (split/\/+|\s/,$testCommand){
foreach $recordFileName (@recordFileName){
if ($recordFile =~ /$recordFileName/){
foreach $dumpFormat (@dumpFormat){
if ($recordFile =~ /$dumpFormat/ ){
if( CommonUtils::isExists("$recordPath/$recordFile","-f")) {
Logger::log(Logger::INFORMATIONAL, "Found the recorded file: $recordFile");
foreach $playList (@playList){
if ($recordFile =~ /$playList/ ){
$cmd = "adb shell su -c 'gst-play-1.0 $recordPath/$recordFile'";
$cmdresult = Command::getOutput($cmd);
foreach $line (split /\n/, $cmdresult) {
Logger::log(Logger::INFORMATIONAL, $line);
if($line =~ /Setting pipeline to PLAYING/) {
Logger::log(Logger::INFORMATIONAL, "\n play the recored file: $recordFile successfully\n");
$checkResult = CommonUtils::PASS;
return $checkResult;
}
}
return $checkResult;
}
}
Logger::log(Logger::INFORMATIONAL, "\nRecord file $recordFile can't be played in the device, need check with special tool in PC side\n");
$checkResult = CommonUtils::PASS;
return $checkResult;
}
else{
Logger::log(Logger::INFORMATIONAL, "Can't find the recorded file: $recordFile");
}
}
}
}
}
}
return $checkResult;
}
|
|