[FFmpeg-user] ffmpeg script

Steve Boyer steveboyer85 at gmail.com
Thu Feb 8 05:24:15 EET 2018


On Feb 7, 2018 6:37 PM, "Shaun Nixon" <nixon.shaun73 at gmail.com> wrote:

i am working on an FFmpeg Bash script in linux.
I am currently using HD Homerun which downloads ,TS files or transport
stream which is a container with an mpeg2 inside with a closed caption
steam for the subtitles.  Plex media server will not recognize the closed
caption though VLC will.

my solution to date is to shrink the .ts file using ffmpeg and then extract
the subtitle using ccextract.

at present I run a bash script in each folder containing .ts files, but
would like one I can run from the main directory that would look in all sub
directories find .ts files remux them to mp4, extract the closed caption
stream to .srt and then remove the .ts files.

so far i have the following script.  Steven Penny from Stack Exchange
contributed code and i added in the ffmpeg and ccextract lines:

#! /bin/bash
 for x in *.ts
do
  y=$(basename "$x" .ts)
  ffmpeg -i "$x" -vf scale=-1:720 -c:v libx264 -crf 23 -preset ultrafast
-c:a copy "$y".mp4
  ccextractor "$x" -o "$y".srt
done


This works well if I run it in a directory.  I would like to add to it
though and maybe have something like a
Find . -name *.ts
statement or some way for it to look in all folders on multimedia hdd for
.ts files and then do the For Loop but am unsure how.


Couple of suggestions:
1) tweak the script so it takes in an argument - the .ts file name that
does the FFmpeg command and other programs. Generalize it.
2) instead of doing a for loop, do a "find . -iname '*.ts' -type f -execdir
scriptname {} \+"

This will find all filenames that end (case insensitive) with .ts, and
execute your script on it.


I also want to add something like
rm /s *.ts
but am unsure if this will work or where to add it after the For Loop.
Would it need a [wait] statement after [done] on the last line.


Another suggestion I've used in the past is FFmpeg returns 0 if
successfully. In the script, have the if statement it checks be the FFmpeg
command. If no problem, it returns 0 (if I recall correctly). Check this
value and delete if you want. Give me a bit and I have an automatic DVD
creation script I can copy and paste a section from.


any advice on writing a bash script that would search for .ts files,
convert them to mp4, and then remove the .ts files would be greatly
appreciated.

-shaun


Steve

_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list