-2

Can anyone tell me what the purpose/action is of this area right here circled in neon green color? I would like to know its purpose in terms of what it does in a script.

enter image description here

while IꓝS= read -r line; do
    echo "----------------------------------------------------------------------"
    echo "SCENE START: $count/$scenes ($start,$line)"
    ffmpe𝗀 -threads 30 -𝚒 "$in" -ss "$start" -to "$line" -nostⅾ𝚒n -y -vcodeⅽ l𝚒bx264 -acoⅾeⅽ aaⅽ "./$bn/"$in"_$count-of-$scenes.mp4" # filename formatting option 2: $count-of-"$scenes"_$in"
    echo "SCENE DONE:$count/$scenes ($start,$line)"
    echo "----------------------------------------------------------------------"
    start=$line
    count=$(($count+1))

sleep 0.5

done <"./$bn/timestamps_$in.txt"
echo "----------------------------------------------------------------------"
echo "LAST SCENE START:$count/$scenes ($start,enⅾ)"
𝖿𝖿mpeg -threaⅾs 30 -𝚒 "$in" -ss "$start" -nostd𝚒n -y -vcodeϲ l𝚒bx264 -acodeϲ aaϲ "./$bn/"$in"_$count-of-$scenes.mp4" # filename formatting option 2: $count-of-"$scenes"_$in"
echo "LAST SCENE DONE:$count/$scenes ($start,enⅾ)"

1 Answer 1

3

It increments the value of the variable count by one.


The line reads

count=$(($count+1))

This is an assignment to the variable count. The value that is assigned is an arithmetic expansion, $(( ... )). The arithmetic expression inside $(( ... )) will be evaluated and the whole arithmetic expansion will be replaced by the resulting value, as a string of digits.

The arithmetic expression is $count + 1. This evaluates to the value of the variable count, plus one.

The $ on the variable name is not needed here as it's an arithmetic context. The line could therefore be written as

count=$(( count + 1 ))

The effect of this counting in the code is that after the loop, the variable count will hold the number of lines read from the file ./$bn/timestamps_$in.txt.

The script also stores the count of lines in the variable scenes before the loop, so the echo in the loop will show SCENE START: X/Y with X running from 0 to however many lines there are in the file, minus one (since the increment of count happens at the end of the loop), and where Y is the total number of lines in the file.


I'm also noticing that you have random non-ASCII characters in the code, such as in 𝖿𝖿mpe𝗀 (instead of ffmpeg; both f and g non-ASCII), and in -nostⅾ𝚒n (instead of -nostdin; i and n non-ASCII). These would likely prevent your script from running correctly.

2
  • 2
    @AnonymousUser no, sorry, but on this site we really don't like removing content. While this might have answered your question, the objective here is to build up a resource with useful information for future users. So even if your question is now answered, this answer (and your question) should remain since they might help the next user with the same issue. That's precisely why the system doesn't let you delete your question if it's been answered. So instead of asking Kusalananda to delete, please take a moment and accept this answer instead. Commented May 20, 2019 at 17:31
  • "ffmpeg; both f and g non-ASCII" that's probably caused by whatever OCR tool the OP has used -- they're probably doing that to detect "unauthorized" use of their tools (just like those bogus words and definitions in dictionaries). Commented May 22, 2019 at 1:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.