This question already has an answer here:
dotnet ef scaffold Unrecognized option '-t firstTable -t secondTable' - pass arguments stored in a string
(1 answer)
Closed 6 months ago.
Per the suggestion from mklement0 I have shortened the output here to just the relevant code and error. Additionally, as he pointed out, I have changed how I am constructing the arguments (now passing as an array).
Additionally, the comment from kesh, I removed the "-filter_complex" and changed to just several "-map" 's.
$TEMPDIR = "E:\MediaConversions\BitLadder"
$FOLDER = 'White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO'
$OUTPUTDIR = $TEMPDIR + '\' + $FOLDER
# Mux the 8 Bitrate Ladder steps into a single file, with a common audio stream
$STEPS = #(Get-ChildItem -Path $OUTPUTDIR -Name)
$INPUT_FILES = #()
$MAP = #()
$COUNT = 0
ForEach ($STEP in $STEPS){
$INPUT_FILES += ('-i', "$STEP")
$MAP += ('-map ' + "$COUNT" + ':v', '-map ' + "$COUNT" + ':a')
$COUNT++
}
$OPTIONS = ('-' + "$INPUT_FILES", "$MAP")
#$OPTIONS
D:\Applications\ffmpeg\bin\ffmpeg.exe "$OPTIONS" -f matroska "E:\MediaConversions\White.Boy.Rick.2018_MultiStreamTest_AAC.H264.mkv"
But Sadly, I still get the same frustrating error:
Unrecognized option '-i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP1.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP2.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP3.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP4.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP5.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP6.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP7.mp4 -i White.Boy.Rick.2018.1080p.WEB-DL.H264.AC3-EVO_STEP8.mp4 -map 0:v -map 0:a -map 1:v -map 1:a -map 2:v -map 2:a -map 3:v -map 3:a -map 4:v -map 4:a -map 5:v -map 5:a -map 6:v
-map 6:a -map 7:v -map 7:a'.
Error splitting the argument list: Option not found
You don't need -complex_filter just to map input streams to output file. You just need to use -map as many times as you have streams:
... -map 0:v -map 1:v ... -map 0:a -map 1:a ...
Related
I have a set of filenames in a directory, some of which are likely to have identical substrings but not known in advance. This is a sorting exercise. I want to move the files with the maximum substring ordered letter match together in a subdirectory named with that number of letters and progress to the minimum match until no matches of 2 or more letters remain. Ignore extensions. Case insensitive. Ignore special characters.
Example.
AfricanElephant.jpg
elephant.jpg
grant.png
ant.png
el_gordo.tif
snowbell.png
Starting from maximum length matches to minimum length matches will result in:
./8/AfricanElephant.jpg and ./8/elephant.jpg
./3/grant.png and ./3/ant.png
./2/snowbell.png and ./2/el_gordo.tif
Completely lost on an efficient bash or python way to do what seems a complex sort.
I found some awk code which is almost there:
{
count=0
while ( match($0,/elephant/) ) {
count++
$0=substr($0,RSTART+1)
}
print count
}
where temp.txt contains a list of the files and is invoked as eg
awk -f test_match.awk temp.txt
Drawback is that a) this is hardwired to look for "elephant" as a string (I don't know how to make it take an input string (rather than file) and an input test string to count against, and
b) I really just want to call a bash function to do the sort as specified
If I had this I could wrap some bash script around this core awk to make it work.
function longest_common_substrings () {
shopt -s nocasematch
for file1 in * ; do for file in * ; do \
if [[ -f "$file1" ]]; then
if [[ -f "$file" ]]; then
base1=$(basename "$file" | cut -d. -f1)
base2=$(basename "$file1" | cut -d. -f1)
if [[ "$file" == "$file1" ]]; then
echo -n ""
else
echo -n "$file $file1 " ; $HOME/Scripts/longest_common_substring.sh "$base1" "$base2" | tr -d '\n' | wc -c | awk '{$1=$1;print}' ;
fi
fi
fi
done ;
done | sort -r -k3 | awk '{ print $1, $3 }' > /tmp/filesort_substring.txt
while IFS= read -r line; do \
file_to_move=$(echo "$line" | awk '{ print $1 }') ;
directory_to_move_to=$(echo "$line" | awk '{ print $2 }') ;
if [[ -f "$file_to_move" ]]; then
mkdir -p "$directory_to_move_to"
\gmv -b "$file_to_move" "$directory_to_move_to"
fi
done < /tmp/filesort_substring.txt
shopt -u nocasematch
where $HOME/Scripts/longest_common_substring.sh is
#!/bin/bash
shopt -s nocasematch
if ((${#1}>${#2})); then
long=$1 short=$2
else
long=$2 short=$1
fi
lshort=${#short}
score=0
for ((i=0;i<lshort-score;++i)); do
for ((l=score+1;l<=lshort-i;++l)); do
sub=${short:i:l}
[[ $long != *$sub* ]] && break
subfound=$sub score=$l
done
done
if ((score)); then
echo "$subfound"
fi
shopt -u nocasematch
Kudos to the original solution for computing the match in the script which I found elsewhere in this site
I'm trying to take a pile of screenshot PNGs, and the timestamp of each screenshot, and create a video with ffmpeg that recreates the timing of the screenshots.
According to the ffmpeg help, -vsync 0 seems to be what I need,
-vsync parameter
0, passthrough Each frame is passed with its timestamp from the
demuxer to the muxer.
Does anyone know how to pass this timestamp information into ffmpeg? Presently each screenshot has the recording time in milliseconds as the filename.
The below example doesn't accept any timing information that I can tell, so I'm looking for the proper format to pipe to the command.
ffmpeg -vsync 0 -pattern_type glob -i '*.png' -c:v libx264 output.mp4
Script: get time from filename, minus previous filetime = duration of temp video, then concat videos
#!/bin/bash
LST=($(ls -1tr Screenshot*.png))
TOT=${#LST[*]}
f="${LST[0]}"
#Screenshot_20201115_135335.png
FNM="${f%.*}"
SEC="${FNM:24:2}"
MIN="${FNM:22:2}"
HOU="${FNM:20:2}"
echo $f $HOU $MIN $SEC
BEG=$(echo "$HOU * 3600 + $MIN * 60 + $SEC" | bc -l)
echo $f $BEG
INP=("-i" "$f")
OUT="${f%.*}.mkv"
TXT=list.txt
echo "#png to mkv" > $TXT
for (( i=1; i<=$(( $TOT -1 )); i++ )); do
f="${LST[$i]}"
FNM="${f%.*}"
SEC="${FNM:24:2}"
MIN="${FNM:22:2}"
HOU="${FNM:20:2}"
TIM=$(echo "$HOU * 3600 + $MIN * 60 + $SEC" | bc -l)
DUR=$(echo "$TIM - $BEG" | bc -l)
echo $f $TIM $DUR
ffmpeg -y -hide_banner -loop 1 "${INP[#]}" -t $DUR "/tmp/${OUT}"
echo "file '/tmp/${OUT}'" >> $TXT
BEG=$TIM
INP=("-i" "$f")
OUT="${f%.*}.mkv"
done
ffmpeg -y -hide_banner -loop 1 "${INP[#]}" -t 5 "/tmp/${OUT}"
echo "file '/tmp/${OUT}'" >> $TXT
cat "$TXT"
ffmpeg -hide_banner -f concat -safe 0 -i "$TXT" -c:v h264_nvenc -cq 20 -y /tmp/output.mkv
ffplay /tmp/output.mkv
I am using FFPROBE to get some file durations in PowerShell.
For my video it gets the frame count properly but for my audio files it returns a different frame count.
This is my code:
$audioId = "$id.m4a"
$videoId = "$id.mp4"
$duration1 = ffprobe -i $videoId -show_frames 2>&1 | grep -c media_type=video
$duration2 = ffprobe -i $audioId -show_frames 2>&1 | grep -c media_type=audio
echo $duration1
echo $duration2
For video it returns a proper output, but for audio it returns a wrong result.
Any suggestions?
Thank you
The man pages for uconv say:
-x transliteration
Run the given transliteration on the transcoded Unicode data, and use the transliterated data as input for the transcoding to the the destination encoding.
It also includes the following two examples:
echo '\u30ab' | uconv -x 'hex-any; any-name'
uconv -f utf-8 -t utf-8 -x '::nfkc; [:Cc:] >; ::katakana-hiragana;'
The first example points towards the -x option defining a "compound transform" but the second example points to it being a "rule-based transliterator".
This is exacerbated by the fact that many of ICU's provided examples (1, 2) don't work:
$ echo "Example" | uconv -f UTF8 -t UTF8 -x 'NFD; [:Nonspacing Mark:] Remove; NFC;'
Couldn't create transliteration "NFD; [:Nonspacing Mark:] Remove; NFC;": U_MISSING_OPERATOR, line 0, offset 0.
$ echo "Example" | uconv -f UTF8 -t UTF8 -x '[:Latin:]; NFKD; Lower; Latin-Katakana;'
Couldn't create transliteration "[:Latin:]; NFKD; Lower; Latin-Katakana;": U_MISSING_OPERATOR, line 0, offset 0.
But some examples (1, 2) work just fine:
$ echo "Example" | uconv -f UTF8 -t UTF8 -x '[aeiou] Upper'
ExAmplE
$ echo "Example" | uconv -f UTF8 -t UTF8 -x 'NFKD; Lower; Latin-Katakana;'
エクサンプレ
So what the heck does -x define?
The plot thickens! It looks like uconv chokes on predefined character classes that aren't in a transform rule.
Regular character classes:
$ echo "Example" | uconv -f UTF8 -t UTF8 -x '[a-zA-Z] Upper'
EXAMPLE
$ echo "Example" | uconv -f UTF8 -t UTF8 -x ':: [a-zA-Z] Upper;'
EXAMPLE
Predefined character classes:
$ echo "Example" | uconv -f UTF8 -t UTF8 -x '[:alpha:] Upper'
Couldn't create transliteration "[:alpha:] Upper": U_MISSING_OPERATOR, line 0, offset 0.
$ echo "Example" | uconv -f UTF8 -t UTF8 -x ':: [:alpha:] Upper;'
EXAMPLE
Just in case, here's the version of uconv I'm using:
$ uconv --version
uconv v2.1 ICU 58.1
It does different things depending on what you pass.
The excerpt below is formatted code from uconv.cpp. translit is the value of the -x argument.
UnicodeString str(translit), pestr;
/* Create from rules or by ID as needed. */
parse.line = -1;
if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') ||
uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
t = Transliterator::createFromRules(UNICODE_STRING_SIMPLE("Uconv"), str,
UTRANS_FORWARD, parse, err);
} else {
t = Transliterator::createInstance(UnicodeString(translit, -1, US_INV),
UTRANS_FORWARD, err);
}
And createFromRules further differs in what it creates based on the input:
Returns a Transliterator object constructed from
the given rule string. This will be a RuleBasedTransliterator,
if the rule string contains only rules, or a
CompoundTransliterator, if it contains ID blocks, or a
NullTransliterator, if it contains ID blocks which parse as
empty for the given direction.
I just want to swap the first 64 characters of a file with the last 64 characters of the same binary file.
How can I do that?
I'm not sure if this can be done reliably with sed or awk. I can imagine a solution that would work on a specific file, or with certain odd conditions like where newlines might appear.
This is fairly easy to do in C. And if not restricted to sed or awk, it can be done with shell commands, too:
n=64
f=/tmp/test
eval $(stat -s $f)
e=$(($st_size - $n))
dd bs=1 count=$n if=$f iseek=$e of=/tmp/last64
dd bs=$n count=1 if=$f of=/tmp/first64
dd bs=1 count=$n if=/tmp/first64 seek=$e of=$f conv=notrunc
dd bs=$n count=1 if=/tmp/last64 of=$f conv=notrunc
Using xxd:
n=64
file=data
tmp=tmp
len=$(wc -c < "$file")
offset=$((len - n))
len=$((offset - n))
xxd -s -$n "$file" | xxd -r -s -$offset > "$tmp"
xxd -s $n -l $len "$file" | xxd -r >> "$tmp"
xxd -l $n "$file" | xxd -r >> "$tmp"
mv "$tmp" "$file"
Edit:
Another approach would be to use xxd and sed:
n=64; hd=$((n * 2))
file=data
tmp=tmp
xxd -c $n -p "$file" |
sed "1{x;d};:a;N;s/\n//;\${s/\(.*\)\(.\{$hd\}\)\$/\2\1/;G};ba" |
xxd -r -p > "$tmp"
mv "$tmp" "$file"
Instead of six calls to xxd, it's two to xxd and one to sed (and fewer file reads and writes, too).
Explanation of the sed command:
1{x;d} - Save the first line of hex digits in hold space. The length of the line is set to the number of bytes to swap using the -c option of xxd.
:a - Label "a"
N - Append the next line.
s/\n// - Remove the embedded newline
\${ - If it's the last line of input:
s/\(.*\)\(.\{$hd\}\)\$/\2\1/ - Swap the last $hd bytes to the beginning
G - Append the first $n bytes from hold space onto the end. Since it's the last line, the script ends.
} - end if
ba - Branch to label "a".
Additionally, sed could do some manipulation of the data.