Skip to content

Commit

Permalink
QSV/NV/VCEncCのtime_id3変換を使用。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed May 22, 2021
1 parent 605f3dc commit 8345fa5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
Binary file modified bin/NVEncC/NVEncC-tvrp.exe
Binary file not shown.
Binary file modified bin/QSVEncC/QSVEncC-tvrp.exe
Binary file not shown.
Binary file modified bin/VCEEncC/VCEEncC-tvrp.exe
Binary file not shown.
43 changes: 34 additions & 9 deletions modules/stream.php
Expand Up @@ -201,6 +201,9 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
// UDPポート
$stream_port = $udp_port + intval($stream);

// UDP受信スキーム
$receive = "udp://127.0.0.1:{$stream_port}?pkt_size=262144&fifo_size=1000000&overrun_nonfatal=1";

// 以前の state が ONAir (TSTask を再利用できる)
if ($settings[strval($stream)]['state'] === 'ONAir') {

Expand Down Expand Up @@ -258,7 +261,7 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,

case 'true':
$subtitle_ffmpeg_cmd = '-map 0:d?';
$subtitle_other_cmd = '--data-copy timed_id3';
$subtitle_other_cmd = '--sub-codec arib_caption?timed_id3:handler=aribb24.js';
break;

case 'false':
Expand Down Expand Up @@ -406,6 +409,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
// 出力
' stream'.$stream.'.m3u8';

$use_ast = true;
$protocol = 'tcp';
break;

case 'QSVEncC':
Expand All @@ -414,7 +419,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
$stream_cmd = '"'.$qsvencc_path.'"'.

// 入力
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7 -i -'.
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7'.
' -i '.$receive.
// avhw エンコード
' --avhw'.
// HLS
Expand All @@ -436,6 +442,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
$protocol = 'udp';
break;

case 'NVEncC':
Expand All @@ -444,7 +452,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
$stream_cmd = '"'.$nvencc_path.'"'.

// 入力
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7 -i -'.
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7'.
' -i '.$receive.
// avhw エンコード
' --avhw'.
// HLS
Expand All @@ -466,6 +475,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
$protocol = 'udp';
break;

case 'VCEEncC':
Expand All @@ -474,7 +485,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
$stream_cmd = '"'.$vceencc_path.'"'.

// 入力
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7 -i -'.
' --input-format mpegts --fps 30000/1001 --input-probesize 1000K --input-analyze 0.7'.
' -i '.$receive.
// avhw エンコード
' --avhw'.
// HLS
Expand All @@ -496,6 +508,8 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
$protocol = 'udp';
break;
}

Expand All @@ -508,7 +522,7 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
@unlink($base_dir.'logs/stream'.$stream.'.tstask.log');
}

$tstask_cmd = '"'.$tstask_path.'" '.($TSTask_window == 'true' ? '/xclient' : '/min /xclient-').' /tcp /port '.$stream_port.' /sid '.$sid.' /tsid '.$tsid.
$tstask_cmd = '"'.$tstask_path.'" '.($TSTask_window == 'true' ? '/xclient' : '/min /xclient-').' /'.$protocol.' /port '.$stream_port.' /sid '.$sid.' /tsid '.$tsid.
' /d '.$BonDriver.' /sendservice 1 /logfile '.$base_dir.'logs/stream'.$stream.'.tstask.log';
$tstask_cmd = 'start "TSTask Process" /B /min cmd.exe /C "'.win_exec_escape($tstask_cmd).' & rem TVRP('.$udp_port.'):TSTask('.$stream.')"';
win_exec($tstask_cmd);
Expand All @@ -522,8 +536,11 @@ function stream_start($stream, $ch, $sid, $tsid, $BonDriver, $quality, $encoder,
}

// エンコードコマンド
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($ast_cmd).' | '.win_exec_escape($stream_cmd);

if ($use_ast) {
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($ast_cmd).' | '.win_exec_escape($stream_cmd);
} else {
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($stream_cmd);
}
// ログを書き出すかどうか
if ($encoder_log == 'true') {

Expand Down Expand Up @@ -573,7 +590,7 @@ function stream_file($stream, $filepath, $extension, $quality, $encoder, $subtit

case 'true':
$subtitle_ffmpeg_cmd = '-map 0:d?';
$subtitle_other_cmd = '--data-copy timed_id3';
$subtitle_other_cmd = '--sub-codec arib_caption?timed_id3:handler=aribb24.js';
break;

case 'false':
Expand Down Expand Up @@ -720,6 +737,7 @@ function stream_file($stream, $filepath, $extension, $quality, $encoder, $subtit
// 出力
' stream'.$stream.'.m3u8';

$use_ast = true;
break;

case 'QSVEncC':
Expand Down Expand Up @@ -750,6 +768,7 @@ function stream_file($stream, $filepath, $extension, $quality, $encoder, $subtit
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
break;

case 'NVEncC':
Expand Down Expand Up @@ -780,6 +799,7 @@ function stream_file($stream, $filepath, $extension, $quality, $encoder, $subtit
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
break;

case 'VCEEncC':
Expand Down Expand Up @@ -810,11 +830,16 @@ function stream_file($stream, $filepath, $extension, $quality, $encoder, $subtit
// 出力
' -o stream'.$stream.'.m3u8';

$use_ast = false;
break;
}

// エンコードコマンド
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($ast_cmd).' | '.win_exec_escape($stream_cmd);
if ($use_ast) {
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($ast_cmd).' | '.win_exec_escape($stream_cmd);
} else {
$stream_cmd = 'start "'.$encoder.' Encoding..." '.($encoder_window == 'true' ? '' : '/B /min').' cmd.exe /C "'.win_exec_escape($stream_cmd);
}

// ログを書き出すかどうか
if ($encoder_log == 'true') {
Expand Down

0 comments on commit 8345fa5

Please sign in to comment.