Gource does not stop simulation when reading from STDIN
I have a powershell script to generate a mp4 video using gource. The script looks like this:
$Command = @"
`$CombinedLog ``
| gource ``
--load-config ./gource.config ``
--path - ``
--log-format custom ``
--seconds-per-day $SecondsPerDay ``
--output-ppm-stream - ``
| ffmpeg ``
-i - ``
-y ``
-vcodec ppm ``
-vcodec libx264 ``
-preset veryfast ``
-pix_fmt yuv420p ``
-crf 1 ``
-filter:v "setpts=PTS/2" ``
-threads 0 ``
-bf 0 ``
$VideoOutput
"@
# Execute the command
if ($PSCmdlet.ShouldProcess($CombinedLog, "$Command")){
Invoke-Expression $Command
}
Overall the script does what it should. The issue I have is that at the end of the $CombinedLog, the gource simulation does not terminate.
The reason I use a $CombinedLog is that I am merging multiple repositories.
Is there any way to tell gource that the stream is finished?
The stream currently consists of concatenated newline-separated lines in a single string.
Did you try ending your stream with ^D? I am not familiar with Windows. Othrwise consider writing the stream to a (temporary) file and passing that to gource.
@mschilli87, I am running PowerShell on MacOS, but I do not think it makes much of a difference since PowerShell is cross-platform? I tried adding ^D to the end, but so far did not get any effect.
I tried:
$CombinedLog += "`^D"
(which I am aware is very naive)
and
$CombinedLog += [char]4
Neither worked.
The temporary file solution works and was my original approach. I just would like to avoid temporary files lying around in case the script is aborted. Streaming seems like the perfect solution for that.
The simulation also stops if the StopDate is within the streamed lines, but not if the stream ends. Is this maybe a Bug?
By ^D I meant Ctrl+D. I don't use powershell so I don't know how to do that. I just think that gource keeps waiting for more input because the stream is not terminated.
@mschilli87 yes, I think that [char]4 should do the trick since this is the EOT byte, right?
How would you do that in e.g. bash? Maybe I can translate it to pwsh, but I would not even know how to do it in bash.
In bash one can type Ctrl+V followed by Ctrl+D IIRC.
And within a bash script? Is that possible?
I meant when writing the script you can use Ctrl+V followed by Ctrl+D to enter a literal Ctrl+D . This way you can use printf and cat or sed or any other tool to edit the stream to append it to your stream. But I never had to do this is bash. And I don't know powershell. I just doubt there is any issue with gource but rather with your script. If you replace gource by wc, do you get a word count or is it also waiting for more input?
When replacing gource with wc in my script
$Command = @"
`$CombinedLog | wc``
"@
# Execute the command
if ($PSCmdlet.ShouldProcess($CombinedLog, "$Command")){
Invoke-Expression $Command
}
I received this answer:
1675 4112 182684
So I think the stream is correct.
Is there any way to confirm this issue in gource? I am not sure how to set a similar situation up in bash.
I don't know powershell. But in your original script there were more backticks and linebreaks:
$Command = @"
`$CombinedLog ``
| gource ``
vs
$Command = @"
`$CombinedLog | wc``
.
Does is also work with
$Command = @"
`$CombinedLog ``
| wc ``
?
If so, can you get it to work without piping a PPM stream to ffmpeg but simply running standard gource?
I did try the
$Command = @"
`$CombinedLog ``
| wc ``
version as well, with the same result. The double "`" are just line continuations. So they should not have any effect.
The simulation also keeps running indefinitely without ffmpeg:
$Command = @"
`$CombinedLog ``
| gource ``
--load-config ./gource.config ``
--path - ``
--log-format custom ``
--seconds-per-day $SecondsPerDay ``
$MultipleRepositoriesArguments ``
--output-ppm-stream $FileName.ppm
"@
Something similar happened to me when I tried to run gource on git repo with submodules. At the end it worked after writing the log into a temp file and passing it to gource.
#!/bin/sh
set -ex
# Without this --loop and --stop-at-end won't work
LOG_FILE="$(mktemp)"
git submodule foreach \
--recursive \
--quiet 'printf "$PWD\0"' |\
xargs -0I {} -- sh -c 'gource --output-custom-log - "$1" | sed -r "s#(.+)\|#\1|/$1#"' - {} |\
sort -n > "$LOG_FILE"
gource "$LOG_FILE" --log-format custom "$@"