'Ffmpeg won't cut excerpt of video correctly

I am using a DOS batch to automate and cut excerpts of various high definition videos (mkv's with more than 1GB each). The script is very convenient and runs fast and fine, but Ffmpeg is not doing its job correctly (it seems Murphy's law is inexorably enthralled into technology, things never come easy, which is why I love and hate it).

Anyway, to cut a long story short, each time the batch job runs, a code like below is executed. Note the path to ffmpeg is specified, since it's not in the PATH environment variable, so the below form works always.

"C:\ffmpeg\bin\ffmpeg.exe" -y -i "D:\S01\SATC - S01E03 - Bay of Married Pigs.mkv" -ss 00:18:05 -to 00:19:15 -codec copy "002-SATC - S01E03 - Bay of Married Pigs-00_18_05-00_19_15.mp4"

The problem is that the first 6 seconds or so of the resulting video has no video, only audio with a frozen image that only starts to move after about 6 seconds, which is a huge defect, not to mention very annoying (a big let down, after all my meticulous scripting work :(). And this happens for most of the files, except a few ones.

Even though this is copying and changing the format from mkv to mp4, per another thread on this site (https://askubuntu.com/questions/396883/how-to-simply-convert-video-files-i-e-mkv-to-mp4), this is not re-encoding, so this is not the issue. Actually, the same problem occurs even if I don't change the format from mkv to mp4.

Even though I foresee a "there's no way to fix this", let me ask: is there a way to fix this? Hopefully there is a way.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source