Jump to content

Post Processing script to transcode recordings?


snorkel

Recommended Posts

snorkel

Hi,

Is there a post processing script available(python/bash etc) to transcode recordings after they are recorded?

I was using that "Convert to friendly format" option but that disables fast forward and rewind if you try to watch a recording in progress.

 

Thanks in advance :-)

 

Snorkel.

 

PS

 

The update that came through last night is working perfectly.

 

Link to comment
Share on other sites

Baenwort

I use the script from the FreeBSD forum: https://emby.media/community/index.php?/topic/49900-automated-commercial-removal-from-tv-recordings/

 

You don't have to use it for commercial removal if you just create the post.sh with just the handbreak command in it and on the setup tab for LiveTV in your server configuration you put the location of the .sh file you created.

5a63817f742d9_postprocessing.jpg

 

One thing to remember if you are creating a post recording script like this is to uncheck the option for Emby to automatically convert the file for you.

Link to comment
Share on other sites

mastrmind11

These scripts should be incorporated into some kind of sticky.  I've seen several out there now for various things, are/can be extremely useful, and are impossible to find after the fact (since a lot of us are weekend tinkerers).  I didn't even know this one existed other than this post because I don't subscribe to FreeBSD stuff, but is easily translated to another script language.  I know I've seen a Debian variation of this using Python as well.

 

@@Luke @@CBers @@ebr

  • Like 3
Link to comment
Share on other sites

jasonmcroy

Agreed on posting something like this as a sticky. I have spent time searching the forums with little luck on how to create a script program just to remux a recording to MKV with little luck. I currently use MCEBuddy which is overkill for what I need it for. Plus, I would like to switch over to using a Linux machine but not know how to create one of these scripts is keeping me from doing that. I have even searched Google but there is something about doing this I don't get.

 

I feel like it must be a simple command just to remux a file.

Link to comment
Share on other sites

mastrmind11

Agreed on posting something like this as a sticky. I have spent time searching the forums with little luck on how to create a script program just to remux a recording to MKV with little luck. I currently use MCEBuddy which is overkill for what I need it for. Plus, I would like to switch over to using a Linux machine but not know how to create one of these scripts is keeping me from doing that. I have even searched Google but there is something about doing this I don't get.

 

I feel like it must be a simple command just to remux a file.

ffmpeg -i your_recording.ts -codec copy your_recording.mkv
  • Like 1
Link to comment
Share on other sites

jasonmcroy

Thanks for providing this!

 

How would I put that in the post processing script section for the DVR? I currently have the post processing application pointed to C:\ffmpeg\bin\ffmpeg.exe, but I am not sure how to put the command correctly in the next line under "Post-processor command line arguments:". I tried putting it like this: ffmpeg -i "D:/Emby DVR/" -codec copy "D:/Emby DVR/", but that doesn't seem to work.

 

I know I have something input incorrectly here, I just can't seem to figure out what.

Link to comment
Share on other sites

mastrmind11

Thanks for providing this!

 

How would I put that in the post processing script section for the DVR? I currently have the post processing application pointed to C:\ffmpeg\bin\ffmpeg.exe, but I am not sure how to put the command correctly in the next line under "Post-processor command line arguments:". I tried putting it like this: ffmpeg -i "D:/Emby DVR/" -codec copy "D:/Emby DVR/", but that doesn't seem to work.

 

I know I have something input incorrectly here, I just can't seem to figure out what.

Not entirely sure how this would work on a Windows machine, but you probably have to create a batch script.

Link to comment
Share on other sites

jasonmcroy

Thanks. Yes, that is where I get lost. There is something I don't understand about how to create that, despite using Google and reading the documentation on the ffmpeg website as well.

Link to comment
Share on other sites

I am curious on this, I have ffmpeg installed on my ubuntu machine with emby, would it really be so simple as entering the ffmpeg command in that post process line to have it convert a recorded movie into mp4?

Link to comment
Share on other sites

So i made a post.sh and i put it in /usr/local/bin and made it executable.

the contents of post.sh are:

#!/bin/bash
ffmpeg -i "$1"  -strict -2 -vf scale=960:480 -threads 2 "$1.mp4"
 
For me it works but its messy with the whole.ts.mp4 thing i see they addressed this already with the other thread but i cant help but wonder if there is a way to also just create a file named nice and clean .mp4
But for now i think i will test this out more ( only ran it as a test havent run it from emby yet ) and if it works well i will probably just make that other cleanup script they have.
Actually come to think of it this might be a bad idea for my setup, This process will be triggered every time a program finishes recording right?
So if i record 3 shows at once and they all finish at the same time that would fire this off 3 times right?
 
I could limit the threads down to 1 but then i am just betting that it finishes one before too many other recordings finish. Ya i think on my system this is just a gamble that i wont choke out my cpu.
Edited by tdiguy
Link to comment
Share on other sites

snorkel

I think the best way would be to create a daemon with a thread queue, when the post process is kicked off you would have the path added to the queue. I have used Lazarus and free Pascal to create a similar thing for moving and converting line feeds on a sftp server.

 

You guys should really check out Lazarus and free Pascal it creates really fast native code on Linux windows freebsd etc.

 

There are ffmpeg headers available so it could be done with full exception handling.

 

I will see what I can come up with as Lazarus and free Pascal apps are completely stand alone no runtime or interpreter needed.

Link to comment
Share on other sites

mastrmind11

 

So i made a post.sh and i put it in /usr/local/bin and made it executable.

the contents of post.sh are:

#!/bin/bash
ffmpeg -i "$1"  -strict -2 -vf scale=960:480 -threads 2 "$1.mp4"
 
For me it works but its messy with the whole.ts.mp4 thing i see they addressed this already with the other thread but i cant help but wonder if there is a way to also just create a file named nice and clean .mp4
But for now i think i will test this out more ( only ran it as a test havent run it from emby yet ) and if it works well i will probably just make that other cleanup script they have.
Actually come to think of it this might be a bad idea for my setup, This process will be triggered every time a program finishes recording right?
So if i record 3 shows at once and they all finish at the same time that would fire this off 3 times right?
 
I could limit the threads down to 1 but then i am just betting that it finishes one before too many other recordings finish. Ya i think on my system this is just a gamble that i wont choke out my cpu.

 

I know you're pretty well versed in nix land, but the $1 is just the command line arg passed into the script, so you can do whatever you want to $1 prior to passing it to the ffmpeg command line.  Initialize a different variable, tell bash to manipulate the string, then send the variable to the ffmpeg command.  Unless I'm missing what you're hung up on?

Link to comment
Share on other sites

dcrdev

 

So i made a post.sh and i put it in /usr/local/bin and made it executable.

the contents of post.sh are:

#!/bin/bash
ffmpeg -i "$1"  -strict -2 -vf scale=960:480 -threads 2 "$1.mp4"
 
For me it works but its messy with the whole.ts.mp4 thing i see they addressed this already with the other thread but i cant help but wonder if there is a way to also just create a file named nice and clean .mp4
But for now i think i will test this out more ( only ran it as a test havent run it from emby yet ) and if it works well i will probably just make that other cleanup script they have.
Actually come to think of it this might be a bad idea for my setup, This process will be triggered every time a program finishes recording right?
So if i record 3 shows at once and they all finish at the same time that would fire this off 3 times right?
 
I could limit the threads down to 1 but then i am just betting that it finishes one before too many other recordings finish. Ya i think on my system this is just a gamble that i wont choke out my cpu.

 

 

Surely you just want to do some variable expansion pokery:

#!/bin/bash
videoName="${1%%.*}"
ffmpeg -i "$1"  -strict -2 -vf scale=960:480 -threads 2 "$videoName.mp4"

  • Like 1
Link to comment
Share on other sites

I know you're pretty well versed in nix land, but the $1 is just the command line arg passed into the script, so you can do whatever you want to $1 prior to passing it to the ffmpeg command line. Initialize a different variable, tell bash to manipulate the string, then send the variable to the ffmpeg command. Unless I'm missing what you're hung up on?

What is nix? I am getting familiar with bash more and more but I am not familiar with manipulating variables.

 

Sent from my SM-G900P using Tapatalk

Link to comment
Share on other sites

mastrmind11

What is nix? I am getting familiar with bash more and more but I am not familiar with manipulating variables.

 

Sent from my SM-G900P using Tapatalk

Sorry, confused you w/ @@dcrdev for a minute.  See his post, which just basically assigns $1 to 'videoName', then uses that variable in the rest of the script.

Edited by mastrmind11
Link to comment
Share on other sites

  • 2 weeks later...

Well.. i went looking for the same thing.. nothing really fits, but I'm getting really used to that in the "Linux World".. (I'm an old NT4 MCSE if that gives you any insight into my experience, its anything windows more or less!)

 

So I run Ubuntu server 17.10, with a decent drive to store media on (1TB) and the OS is on SSD. Its also a VMWare VM (cause i find its much easier to recover from hardware failures when you run things as VMs), and I can over-commit my CPU resources since the other VMs i run don't get used at the same times as my TVServer... (TV has priority, of course). My tv box is a roku ultimate. I have the roku thumbs plugin installed as well. And once i watch a TV show, i delete it and never return.. more or less.

 

My script runs at 1130pm, using find to look for .ts files in my recording folder. ones found are passed to a process function, which looks for an existing SRT for that .ts file, and makes one if it isnt found. Then it looks for an MKV and if one isnt found, it builds it.

 

Converting to a high compression format (HEVC) made sense to me - but subtitles embedded or as a stream in the MKV was messy and didnt work well.. also I don't use a high end audio system - stereo works fine for me cause that's all i have for speakers (aka, 2 of them). But the way roku and emby handle SRT files made it easy once i figured it out..

 

Also, and this was a big one - I constantly ran into issues escaping single quotes in folder names.  Mainly with ffmpeg, where you have to "magic escape" (what were they smoking when they came up with that??) you have to use like 5 \\\\\ slashes to escape the quote. So "Marvel's Agents of Sitcom" folder paths threw me for a loop...

 

I gave up on that.. and i now sed out the (is Sed a verb?) quotes from my xmltvlistings EPG data and don't have to mess with quotes in the first place. (thats another post)

 

So, here is what I use.. tailored for my uses... somewhat commented... and probably really crappy code. But hey its not bad for my 1st "real" bash script right?

 

Its not an attachment cause sometimes downloading scripts breaks.. this way you can see the code before going to that trouble. :)  As you can see - its still got old FFMPEG commands in it as i tried to find a good balance of quality and resource requirements.

#!/bin/bash
# find ts files and convert to h265 with 120 second limit for testing
# Location of source video
sourcelocation="/media/embymedia/tvshows/"
# Extension of source video
sourceext=".ts"
# Location of convert log
logfile="/media/embymedia/tvshows/convert.log"

tsprocess()
{
 # Location of Convert Log file.
 logfile="/media/embymedia/tvshows/convert.log"
 # Location of FFMPEG static binary
 ffmpgpath="/media/embymedia/utils/ffmpeg-git-20180111-64bit-static"
 
 mkvfile="${1%.ts}.mkv"
 srtfile="${1%.ts}.english.srt"

 echo -e "Processing starting for $1 at $(date)" >> "$logfile"
 echo -e "Processing starting for $1 at $(date)"
 
 # Determine if subs are needed.. does srt already exist?
 if [ ! -e "$srtfile" ]; then
  # No SRT file, try to create it.
  echo -e "Extracting SRT: $1 at $(date)" >> "$logfile"
  echo -e "Extracting SRT: $1 at $(date)\n"
  $ffmpgpath/ffmpeg -f lavfi -i movie="$1"[out0+subcc] -map s "$srtfile"
  sed 's#\\h#''#g' "$srtfile" > "$srtfile.temp"
  sed 's#{\\an7}#''#g' "$srtfile.temp" > "$srtfile.temp2"
  rm -f "$srtfile"
  rm -f "$srtfile.temp"
  mv "$srtfile.temp2" "$srtfile"
 else
  echo -e "SRT already exists for $1" >> "$logfile"
  echo -e "SRT already exists for $1"
 fi
 
 # Determine if conversion is needed.. does mkv already exist?
 if [ ! -e "$mkvfile" ]; then
  echo -e "Converting: $1 to $mkvfile at $(date)" >> "$logfile"
  echo -e "Converting: $1 to $mkvfile at $(date)"
  # Run FFMPEG to convert the file
#  $ffmpgpath/ffmpeg -ss 0 -i "$1" -map_metadata 0 -map_chapters 0 \
#  -map 0:0 -metadata:s:v:0 language=eng -map 0:1 -metadata:s:a:0 language=eng -metadata:s:a:0 title="Stereo" \
#  -map 0:2 -metadata:s:s:0 language=eng -metadata:s:s:0 title="English" -s hd720 -c:v libx265 -preset ultrafast \
#  -x265-params crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 \
#  -c:a copy -c:s copy -t 120 "$mkvfile.pending"

  $ffmpgpath/ffmpeg -i "$1" -s hd720 -c:v libx265 -crf 22 -preset ultrafast \
  -ac 2 -c:a aac -map_chapters 0 "inprocess.mkv"

  # removed this: -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR"
  # removed this -x265-params crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 
  if [ -e "inprocess.mkv" ]; then
   mv "inprocess.mkv" "$mkvfile"
  else
   echo -e "? Cant find temp MKV. Encoding may have FAILED: $1" >> "$logfile"
   echo -e "? Cant find temp MKV. Encoding may have FAILED: $1"
  fi
 else
  echo -e "MKV Already Exists: $1" >> "$logfile"
  echo -e "MKV Already Exists: $1"
 fi
 
 # Now if the MKV was created, delete the TS
 if [ -e "$1" ] && [ -e "$mkvfile" ]; then
   # Delete TS video
   echo -e "rm $1" >> "$logfile"
   echo -e "rm $1"
 else
   echo -e "Encoding FAILED: $1" >> "$logfile"
   echo -e "Encoding FAILED: $1"
 fi
}

export -f tsprocess

echo
echo
echo "Script Starting at $(date)"
echo -e "Script Starting at $(date)\n" > "$logfile"

cd $sourcelocation
# find and convert any TS files
find ${sourcelocation} -iname "*${sourceext}" -exec bash -c 'tsprocess "$0"' {} \;

echo -e "Script Ending at $(date)" >> "$logfile"
echo -e "Script Ending at $(date)\n"
echo
exit

My tvshows folder is my recording folder for emby. I share it out with samba and i can easily attach from my windows boxes (cause its just easier, for me) to open the convert log or see whats going on. And yeah, i haven't decided to remove those TS files just yet.. you can un-remark that out if you are braver than me.

 

Oh - one nice tweak - i put an inprogress.jpg in the root of my tvshows folder. While most of my encoding happens from 1130-3am, if i happened to open a client against emby i would see a nice "encoding in progress" image for that show in process. Its just a simple jpg with a black background and the text "in progress" on it.. simple enough. Once encoded the MKV is moved out so that video isnt shown any longer, and the jpg and nfo can just sit there until the next night's processing.

 

At 5am, my thumb generation script runs and media updates scripts.. i don't watch TV in the morning.. 

 

I have found some weird glitches.. of course. and I don't try to watch TV files while they are being converted (or while emby records them, as its painful to not have ff/rewind).  And roku was showing \h and {\an4} positioning text in the subtitles so i removed those in the script also.

 

But i have achieved direct play and subtitles for all the shows that last overnight (as in i dont watch and delete them before they are processed) now, with some space savings (once I start deleting ts files) to boot.

 

Anyhow... enjoy it if you want.. I am by no means a linux expert. I probably cant help tell you why some of that script works like it does.. i have to run off to Google a lot. But i think i got something useful enough to share. 

Edited by RBRBRB
Link to comment
Share on other sites

Oh - yeah - i had to download a static copy of ffmpeg to get ffmpeg to work right?  I tried to use the emby one and kept getting some weird errors that indicated dynamic wasn't going to work (couldn't find something, i don't remember what.. that was 20 script versions ago!)

 

I think i had to go get PERL and something, but that was probably more for the mc2xml alternative i was trying (I tried mythtv ages ago and sent the MC2XML tv guy $25 to get a linux version that grabbed the new MS rovi EPG data.. and it works well for xmltvlistings also, so i didnt lose that $25 after all.)  

 

If you have other questions I'll try to answer but I don't live on the net, so give me a day or so. :)

Link to comment
Share on other sites

  • 1 year later...
Westiewill

Well.. i went looking for the same thing.. nothing really fits, but I'm getting really used to that in the "Linux World".. (I'm an old NT4 MCSE if that gives you any insight into my experience, its anything windows more or less!)

 

So I run Ubuntu server 17.10, with a decent drive to store media on (1TB) and the OS is on SSD. Its also a VMWare VM (cause i find its much easier to recover from hardware failures when you run things as VMs), and I can over-commit my CPU resources since the other VMs i run don't get used at the same times as my TVServer... (TV has priority, of course). My tv box is a roku ultimate. I have the roku thumbs plugin installed as well. And once i watch a TV show, i delete it and never return.. more or less.

 

My script runs at 1130pm, using find to look for .ts files in my recording folder. ones found are passed to a process function, which looks for an existing SRT for that .ts file, and makes one if it isnt found. Then it looks for an MKV and if one isnt found, it builds it.

 

Converting to a high compression format (HEVC) made sense to me - but subtitles embedded or as a stream in the MKV was messy and didnt work well.. also I don't use a high end audio system - stereo works fine for me cause that's all i have for speakers (aka, 2 of them). But the way roku and emby handle SRT files made it easy once i figured it out..

 

Also, and this was a big one - I constantly ran into issues escaping single quotes in folder names.  Mainly with ffmpeg, where you have to "magic escape" (what were they smoking when they came up with that??) you have to use like 5 \\\\\ slashes to escape the quote. So "Marvel's Agents of Sitcom" folder paths threw me for a loop...

 

I gave up on that.. and i now sed out the (is Sed a verb?) quotes from my xmltvlistings EPG data and don't have to mess with quotes in the first place. (thats another post)

 

So, here is what I use.. tailored for my uses... somewhat commented... and probably really crappy code. But hey its not bad for my 1st "real" bash script right?

 

Its not an attachment cause sometimes downloading scripts breaks.. this way you can see the code before going to that trouble. :)  As you can see - its still got old FFMPEG commands in it as i tried to find a good balance of quality and resource requirements.

#!/bin/bash
# find ts files and convert to h265 with 120 second limit for testing
# Location of source video
sourcelocation="/media/embymedia/tvshows/"
# Extension of source video
sourceext=".ts"
# Location of convert log
logfile="/media/embymedia/tvshows/convert.log"

tsprocess()
{
 # Location of Convert Log file.
 logfile="/media/embymedia/tvshows/convert.log"
 # Location of FFMPEG static binary
 ffmpgpath="/media/embymedia/utils/ffmpeg-git-20180111-64bit-static"
 
 mkvfile="${1%.ts}.mkv"
 srtfile="${1%.ts}.english.srt"

 echo -e "Processing starting for $1 at $(date)" >> "$logfile"
 echo -e "Processing starting for $1 at $(date)"
 
 # Determine if subs are needed.. does srt already exist?
 if [ ! -e "$srtfile" ]; then
  # No SRT file, try to create it.
  echo -e "Extracting SRT: $1 at $(date)" >> "$logfile"
  echo -e "Extracting SRT: $1 at $(date)\n"
  $ffmpgpath/ffmpeg -f lavfi -i movie="$1"[out0+subcc] -map s "$srtfile"
  sed 's#\\h#''#g' "$srtfile" > "$srtfile.temp"
  sed 's#{\\an7}#''#g' "$srtfile.temp" > "$srtfile.temp2"
  rm -f "$srtfile"
  rm -f "$srtfile.temp"
  mv "$srtfile.temp2" "$srtfile"
 else
  echo -e "SRT already exists for $1" >> "$logfile"
  echo -e "SRT already exists for $1"
 fi
 
 # Determine if conversion is needed.. does mkv already exist?
 if [ ! -e "$mkvfile" ]; then
  echo -e "Converting: $1 to $mkvfile at $(date)" >> "$logfile"
  echo -e "Converting: $1 to $mkvfile at $(date)"
  # Run FFMPEG to convert the file
#  $ffmpgpath/ffmpeg -ss 0 -i "$1" -map_metadata 0 -map_chapters 0 \
#  -map 0:0 -metadata:s:v:0 language=eng -map 0:1 -metadata:s:a:0 language=eng -metadata:s:a:0 title="Stereo" \
#  -map 0:2 -metadata:s:s:0 language=eng -metadata:s:s:0 title="English" -s hd720 -c:v libx265 -preset ultrafast \
#  -x265-params crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 \
#  -c:a copy -c:s copy -t 120 "$mkvfile.pending"

  $ffmpgpath/ffmpeg -i "$1" -s hd720 -c:v libx265 -crf 22 -preset ultrafast \
  -ac 2 -c:a aac -map_chapters 0 "inprocess.mkv"

  # removed this: -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR"
  # removed this -x265-params crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 
  if [ -e "inprocess.mkv" ]; then
   mv "inprocess.mkv" "$mkvfile"
  else
   echo -e "? Cant find temp MKV. Encoding may have FAILED: $1" >> "$logfile"
   echo -e "? Cant find temp MKV. Encoding may have FAILED: $1"
  fi
 else
  echo -e "MKV Already Exists: $1" >> "$logfile"
  echo -e "MKV Already Exists: $1"
 fi
 
 # Now if the MKV was created, delete the TS
 if [ -e "$1" ] && [ -e "$mkvfile" ]; then
   # Delete TS video
   echo -e "rm $1" >> "$logfile"
   echo -e "rm $1"
 else
   echo -e "Encoding FAILED: $1" >> "$logfile"
   echo -e "Encoding FAILED: $1"
 fi
}

export -f tsprocess

echo
echo
echo "Script Starting at $(date)"
echo -e "Script Starting at $(date)\n" > "$logfile"

cd $sourcelocation
# find and convert any TS files
find ${sourcelocation} -iname "*${sourceext}" -exec bash -c 'tsprocess "$0"' {} \;

echo -e "Script Ending at $(date)" >> "$logfile"
echo -e "Script Ending at $(date)\n"
echo
exit

My tvshows folder is my recording folder for emby. I share it out with samba and i can easily attach from my windows boxes (cause its just easier, for me) to open the convert log or see whats going on. And yeah, i haven't decided to remove those TS files just yet.. you can un-remark that out if you are braver than me.

 

Oh - one nice tweak - i put an inprogress.jpg in the root of my tvshows folder. While most of my encoding happens from 1130-3am, if i happened to open a client against emby i would see a nice "encoding in progress" image for that show in process. Its just a simple jpg with a black background and the text "in progress" on it.. simple enough. Once encoded the MKV is moved out so that video isnt shown any longer, and the jpg and nfo can just sit there until the next night's processing.

 

At 5am, my thumb generation script runs and media updates scripts.. i don't watch TV in the morning.. 

 

I have found some weird glitches.. of course. and I don't try to watch TV files while they are being converted (or while emby records them, as its painful to not have ff/rewind).  And roku was showing \h and {\an4} positioning text in the subtitles so i removed those in the script also.

 

But i have achieved direct play and subtitles for all the shows that last overnight (as in i dont watch and delete them before they are processed) now, with some space savings (once I start deleting ts files) to boot.

 

Anyhow... enjoy it if you want.. I am by no means a linux expert. I probably cant help tell you why some of that script works like it does.. i have to run off to Google a lot. But i think i got something useful enough to share. 

Nice script man!!! Have been using it for the last couple days to record my sports shows TY!

 

I have a few questions,  In the top of the code can I add multiple source locations?  ( sourcelocation=" /xxxxx/xxxxxx " )  The reason I am asking is because in Emby DVR settings you can set three different paths here is a screenshot of my current setting I have now for the paths.

 

5cd554d7af9c9_emby.png

 

Right now I am recording my sports games and the script is processing it perfectly,    I wanted to set two more recording paths for Movie and TV Shows so I was wondering if I can add multiple locations

in the script to process other directories as well? right now i have  xxx/recordings/other for my sports events,   I wonder if I added a custom directory for tv shows would the sports events record get put in there because its a "tv show" ?    I was hoping to have 3 seperate folders (sports, tv shows, movies)

 

Another question,  I was amazed on how well the subtitles worked  I recorded the basketball game last night and after it was done I was testing the playback and I was not expecting subtitles on the recording of the live event? how is this possible.. I dont see subtitles watching live iptv?   Does it use voice to text conversion or something?

 

hope you can answer my questions, TY

Edited by Westiewill
Link to comment
Share on other sites

RBRBRB

The script is a tsprocess "subroutine" definition first, then at the bottom, you see where it calls (exec bash) the subroutine for every file it finds in the sourcelocation:

cd $sourcelocation
# find and convert any TS files
find ${sourcelocation} -iname "*${sourceext}" -exec bash -c 'tsprocess "$0"' {} \;
 
I would think if you have multiple source locations, just run the 'find' line for each of them (and hardcode your $sourcelocation variable in each line, or change the variable, or.. however you want to do it).
 
I had issues with embedded subtitles. So I knew the roku would use SRT files, and the process will run thru the video file first and pull the subtitles out into a SRT file with the same name as the video file. But then i ran into weird issues - the subtitle formatting tags played thru on the roku, so i added a sed step to strip them out of the SRT file.
 
I do occasionally have issues with the subtitles being too fast. Not sure why, haven't bothered to research it. Maybe there's an ffmpeg option to 'shift' subtitle timings by x amount.. or maybe i need to go grab the newer version of ffmpeg.
 
I went thru a ton of ffmpeg options (as seen in the script, as i left them there but commented them out a lot), but found this worked best for me. Honestly, its probably up to each person to tweak it to perfection on their system (isn't that the "linux" way of doing things? you always get 80% of what you need in someone else's solution, and have to do the rest yourself!)
 
Also, sometimes if the conversion takes a really long time I've gotten into this weird state - maybe if the server reboots in the middle - where the converted show is for something else but the names are applied wrong (like the TS is for Supernatural, but the MKV is actually the video for 911 or something). Since I don't delete the TS successfully, in those cases i just watch the original TS and take the trans-coding hit.. To help prevent this i think the tsprocess code now actually checks the time of day before it starts a new process loop.. if its past 2PM, it bails. 2 hours is usually enough to squash a 1 hour video so it always ends before 4pm.  Thats something i haven't posted however.. and maybe unique to my situation.. 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...