$filename = 'INPUT.avi' ffmpeg.exe -i $filename -f ffmetadata FFMETADATAFILE.txt $table = Import-Csv .\chapters.csv -Delimiter ';' $table | ForEach-Object { $time = $_.endtime -split ':' $end = [int](New-TimeSpan -Hours $time[0] -Minutes $time[1] -Seconds $time[2]).TotalMilliseconds if (!$start) { $start = '00:00:35' -split ':' $start = [int](New-TimeSpan -Hours $start[0] -Minutes $start[1] -Seconds $start[2]).TotalMilliseconds } $chapter = @" [CHAPTER] TIMEBASE=1/1000 START=$start END=$end title=$($_.title) "@ $start = $end $chapter | Out-File -FilePath FFMETADATAFILE.txt -Append -NoNewline } ffmpeg.exe -i $filename -i FFMETADATAFILE.txt -map_metadata 1 -codec copy OUTPUT.mp4