1

I want to use both -itsscale and -itsoffset in my FFmpeg command, but couldn't find any information in the docs https://ffmpeg.org/ffmpeg.html or elsewhere, if the order, in which they're mentioned in the command, matters, or in which order they will generally be applied to the video.

1 Answer 1

2

I decided to just try it out with an example video file and then compare the results I'm getting for each command.

First, we generate an example 5 seconds video file example.mp4 for testing, counting from 1 to 5, showing each number for 1 second:

for n in $(seq 1 5); do
  magick convert -size 200x200 xc:black -fill white -draw "circle 100,100 100,200" \( -background white -fill black -pointsize 200 label:"$n" -trim -resize 100x100 \) -gravity Center -composite "$n.png"
  ffmpeg -loop 1 -i "$n.png" -pix_fmt yuv420p -r 25 -t 1 "$n.ts"
done
ffmpeg -i "concat:$(printf %s.ts\| $(seq 1 5))" -c copy example.mp4
for n in $(seq 1 5); do
  rm "$n.png"
  rm "$n.ts"
done

enter image description here

Next, we generate reference videos by applying the timestamp modifications sequentially, via an intermediary file:

  • Applying an offset of 3 seconds, first, will lead to skipping numbers 1, 2 and 3 and remaining numbers 4 and 5 will be scaled to length of 3 seconds each:

    ffmpeg -itsoffset -3 -i example.mp4 -c copy itsoffset.mp4
    ffmpeg -itsscale 3 -i itsoffset.mp4 -c copy itsoffset_itsscale.mp4
    

    enter image description here

  • Scaling to 3 seconds per number and subsequently adding an offset of 3 seconds will skip only number 1 in the final output:

    ffmpeg -itsscale 3 -i example.mp4 -c copy itsscale.mp4
    ffmpeg -itsoffset -3 -i itsscale.mp4 -c copy itsscale_itsoffset.mp4
    

    enter image description here

Finally, we can run the two different variants of the command to find out which output we're getting:

  ffmpeg -itsoffset -3 -itsscale 3 -i example.mp4 -c copy test_itsoffset_itsscale.mp4
  ffmpeg -itsscale 3 -itsoffset -3 -i example.mp4 -c copy test_itsscale_itsoffset.mp4

Both commands lead to identical output files, which means that the order, in which they're mentioned in the command, doesn't matter. Furthermore, the resulting video shows that offset will be applied first, then scaling.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.