package require mawt

catch { file mkdir "TestOut" }

set imgFile   [file join "Data"    "Cawt-001.png"]
set movieFile [file join "TestOut" "SizesVideo.mp4"]
set numImgs   30
set flip      false

mawt SetDebugMode false

puts "MAWT version      : [mawt GetVersion]"
puts "FFmpeg version    : [mawt GetFfmpegVersion]"
puts "Image file pattern: $imgFile"
puts "Movie file        : $movieFile"

set phImg [image create photo -file $imgFile]
set wOrig [image width  $phImg]
set hOrig [image height $phImg]

set videoObj [mawt Video new $movieFile "w" -width $wOrig -height $hOrig]

puts "Adding $numImgs images of size $wOrig x $hOrig"
for { set i 0 } { $i < $numImgs } { incr i } {
    $videoObj WriteNextPhotoImage $phImg $flip
}

set smallImg [image create photo]
$smallImg copy $phImg -subsample 2 2
set w [image width  $smallImg]
set h [image height $smallImg]
puts "Adding $numImgs images of size $w x $h"
for { set i 0 } { $i < $numImgs } { incr i } {
    $videoObj WriteNextPhotoImage $smallImg $flip
}

set largeImg [image create photo]
$largeImg copy $phImg -zoom 2 2
set w [image width  $largeImg]
set h [image height $largeImg]
puts "Adding $numImgs images of size $w x $h"
for { set i 0 } { $i < $numImgs } { incr i } {
    $videoObj WriteNextPhotoImage $largeImg $flip
}

$videoObj Close

exit
