Open mmulhern1 opened 1 year ago
Agreed, this is a good script and your fixes made it better. I know nothing about ffmpeg but some converted videos have no video track, only an audio track. Strange. I tried both compressed and uncompressed for those conversions that had no video and neither option worked.
I had to add -map 0 to
ffmpeg -loglevel panic -f concat -safe 0 -i $tmpFileName -map 0 -c copy -scodec copy $outputVideoFilePath
for the line with concat without compression for all the subtitles to copy and the video to show. The script runs rapidly if $compress = $false is set.
For concat with compression, I had to change the line to have videos display and keep all subtitle tracks by adding -map 0 again.
ffmpeg -loglevel panic -f concat -safe 0 -i $tmpFileName -map 0 -b:v $videoRate -b:a $audioRate -c:s mov_text $outputVideoFilePath
Here is my modified script that works pretty well. I run it from cygwin, but it should work directly from Windows as well. Remove the .txt extension. I just used it to post here. PlayOnScript.ps1.txt
This script is genius, but I noticed that subtitles weren't getting preserved. I spent some time looking at it (knowing PowerShell well but very little about ffmpeg) and got it to work with a few changes.
In the part of the code that splits the recording into multiple files (the chunks between ads), change:
ffmpeg -loglevel panic -ss $startSeconds -i $videoFile -t $durationSeconds -c copy $outputChapterFile
to:
ffmpeg -loglevel panic -ss $startSeconds -i $videoFile -t $durationSeconds -c copy -map 0:v -map 0:s -scodec mov_text -map 0:a? $outputChapterFile
Adding some permutation of -map0 seems to be needed so that it captures all streams. Otherwise it just comes up with an empty subtitle. I'm not clear why. Just adding a map 0, however, results in a clip that is longer than it should be with the minutes of the next advertising section at the end of the file. Adding the "-scodec mov_text" resolves that. I think it's re-encoding the subtitle.
With these changes, you end up with chunks of files that have correct subtitles.
The ffmpeg line for compress just works as is.
The ffmpeg line to merge without compressing, needs to be changed from:
ffmpeg -loglevel panic -f concat -safe 0 -i $tmpFileName -c copy $outputVideoFilePath
to:
ffmpeg -loglevel panic -f concat -safe 0 -i $tmpFileName -c copy -scodec copy $outputVideoFilePath
Again, my level of understanding of ffmpeg is pretty basic so there may be a better way to do this, but I thought I'd share. Thank you for creating this awesome script!
As a side note, my testing was done on Forged and Fire episodes from Hulu.