You are not logged in.
This test
#!/bin/bash
encode() {
input="$HOME/tmp/t e s t.mp4"
output="$HOME/tmp/out.mp4"
encarr=("ffmpeg")
encarr+=("-i ${input}")
encarr+=("-vf yadif=0") # deinterlace
encarr+=("-pix_fmt yuv420p")
encarr+=("-c:v libx264")
encarr+=("-preset slow")
encarr+=("-tune film")
encarr+=("-crf 18")
encarr+=("-threads 0")
encarr+=("-an")
#encarr+=("-aspect 16:9")
#encarr+=("-level 4.1")
encarr+=("${output}")
encarr+=("-movflags +faststart -loglevel panic -stats")
# preview
for i in "${!encarr[@]}"; do
printf "%s\t%s\n" "$i" "${encarr[$i]}"
done
# action
"${encarr[@]}"
}
encode
will fail with "Unrecognized option 'i /mnt/...'.", if I unquote "${encarr[@]}" it will fail due to spaces in input, what is the way to do this correctly?
Last edited by brontosaurusrex (2020-01-21 14:59:48)
Online
This just from a novice, but wouldn't "input="$HOME/tmp/t e s t.mp4" be the issue? Spaces in file names would be treated as directories?
Offline
Well, dunno, this works for example
#!/bin/bash
encode() {
input="$HOME/tmp/t e s t.mp4"
output="$HOME/tmp/out.mp4"
encarr=(ffmpeg)
encarr+=(-i "$input") # fixed
encarr+=(-vf yadif=0)
encarr+=(-pix_fmt yuv420p)
encarr+=(-c:v libx264)
encarr+=(-preset fast)
encarr+=(-tune film)
encarr+=(-crf 18)
encarr+=(-threads 0)
encarr+=(-an)
#encarr+=(-aspect 16:9)
#encarr+=(-level 4.1)
encarr+=("$output")
encarr+=(-movflags +faststart -loglevel panic -stats)
# preview
for i in "${!encarr[@]}"; do
printf "%s\t%s\n" "$i" "${encarr[$i]}"
done
# action
"${encarr[@]}"
}
encode
but it's not human-pretty-readable, returns:
0 ffmpeg
1 -i
2 /home/ticho/tmp/t e s t.mp4
3 -vf
4 yadif=0
5 -pix_fmt
6 yuv420p
7 -c:v
8 libx264
9 -preset
10 fast
11 -tune
12 film
13 -crf
14 18
15 -threads
16 0
17 -an
18 /home/ticho/tmp/out.mp4
19 -movflags
20 +faststart
21 -loglevel
22 panic
23 -stats
Perhaps I'll just use this and blame ffmpeg for ugliness.
Last edited by brontosaurusrex (2020-01-22 10:52:29)
Online
Not when qouted (" ").
Cd $HOME/tmp/t e s t.mp4"
, brings me to directory ~/tmp/t e s t.mp4...
edit:
dropped one quote, should been: Cd "$HOME/tmp/t e s t.mp4"
Last edited by rbh (2020-01-21 16:20:53)
// Regards rbh
Please read before requesting help: "Guide to getting help", "Introduction to the Bunsenlabs Lithium Desktop" and other help topics under "Help & Resources" on the BunsenLabs menu
Offline
clusterF wrote:This just from a novice, but wouldn't "input="$HOME/tmp/t e s t.mp4" be the issue? Spaces in file names would be treated as directories?
Not when qouted (" ").
Cd $HOME/tmp/t e s t.mp4"
, brings me to directory ~/tmp/t e s t.mp4...
Never knew that. Thanks
Not sure i get the gist of the script though, looks like a media converter maybe?
Offline
Right, part of it, other parts are audio encoder, r128 thing, some logic around hasAudio, ..., some logic around audio channel types and similar.
Online
What happens if you have
encarr+=("-i \"${input}\"")
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
@damo:
Unrecognized option 'i "/home/ticho/tmp/t e s t.mp4"'.
I guess ffmpeg want's this to get as two separated parameters (which actually makes sense).
Online
^Right, all those array elements need to be separate words, unless you want to pass something with spaces as one word.
ie
encarr+=(-vf)
encarr+=(yadif=0)
But [SOLVED] means you've got that already.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Online
That, so what can I/we learned from this, this are two elements of array
encarr+=(-i)
encarr+=("$input")
(and I don't know how to write that as single assignment).
And btw this are also two elements of an array
encarr+=(-vf yadif=0)
Online
^yes
And "single assignment": does this not work?
encarr+=(-i "$input")
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Online
Duh, of course it does, so I should I mark this "[SOLVED] and [SOLVED]"?
edit, proof:
file="/some/f i l e"
arr1=(-i "$file")
arr2=(-i)
arr2+=("$file")
[[ ${arr1[@]} == ${arr2[@]} ]] && echo "ok"
ok
Last edited by brontosaurusrex (2020-01-23 13:40:07)
Online
^That test doesn't check how the words are divided up though, does it?
Wouldn't
two words "second pair"
evaluate the same as
"two words" second pair
??
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Online
True^, that test is useless.
Online