Project

General

Profile

Feature #1638

post-process / converting files

Added by Kristofer Karlsson over 11 years ago. Updated almost 11 years ago.

Status:
Accepted
Priority:
Normal
Assignee:
-
Category:
PVR / DVR
Target version:
-
Start date:
2013-02-23
Due date:
% Done:

0%

Estimated time:

Description

This is sort of two issues in one:

I use xbmc/tvheadend, and use a postprocess script to convert finished recordings.
My recordings are written as TS, and then I convert them to h.264 / mkv.
The conversion itself works fine, but I tvheadend doesn't acknowledge that the filename has changed from foo.ts to foo.mkv.
I am not sure if I'm doing something wrong or if inotify is not working for me for some reason. (It is enabled at least.)

Second issue:
If I manually modify the entry in /dvr/log to have the correct file ending and restart tvheadend, I can find the file in the recordings list, and I can play it, but when I start seeking I get "htsp seek error".

Note that I don't get this when playing the file as a regular file in xbmc, so this problem seems to be in either tvheadend or the tvheadend pvr plugin for xbmc.

For reference, here is my post process script:

#!/bin/bash

SOURCE="$1" 
if [ "x$SOURCE" == "x" ]; then
  echo "Usage: $0 <input file>" 
  exit 1
fi

if [ ! -e "$SOURCE" ]; then
  echo $SOURCE does not exist
  exit 1
fi

SOURCE_NO_EXT="${SOURCE%.*}" 
SOURCE_EXT="${SOURCE##*.}" 
if [ $SOURCE_EXT == $SOURCE ]; then
  echo No file ending found in $SOURCE
  exit 1
fi

if [ $SOURCE_EXT == "mkv" ]; then
  mkvinfo "$SOURCE" | grep h.264 > /dev/null
  if [ $? -eq 0 ]; then
    echo $SOURCE is already converted
    exit 1
  fi
elif [ $SOURCE_EXT != "ts" ]; then
  echo Unsupported file ending \"$SOURCE_EXT\" 
fi

TARGET="${SOURCE_NO_EXT}.mkv" 
DEST="$SOURCE".inprogress.mkv

if [ -e "$DEST" ]; then
  echo "$DEST" "already exists - transcoding already in progress?" 
  exit 1
fi

echo "Input:           " "$SOURCE" 
echo "Temporary output:" "$DEST" 
echo "Output:          " "$TARGET" 
sleep 3

nice -n19 HandBrakeCLI -i "$SOURCE" -o "$DEST" -e x264 -E ffac3 < /dev/null
if [ $? -ne 0 ]; then
  echo "transcoding failed - aborting" 
  rm -f "$DEST" 
  exit 1
fi

mkvinfo -q "$DEST" 
if [ $? -ne 0 ]; then
  echo "transcoding output is not a valid mkv - aborting" 
  rm -f "$DEST" 
  exit 1
fi

sleep 3

# Always move it to SOURCE first, so that tvh can pick up the filename change through inotify
mv "$DEST" "$SOURCE" 
if [ $? -ne 0 ]; then
  echo Could not move $DEST to $SOURCE
  exit 1
fi

if [ "$SOURCE" != "$TARGET" ]; then
  sleep 3
  mv "$SOURCE" "$TARGET" 
  if [ $? -ne 0 ]; then
    echo Could not move $SOURCE to $TARGET
    exit 1
  fi
fi

chmod 777 $TARGET

echo All done converting $TARGET

History

#1

Updated by Adam Sutton over 11 years ago

  • Tracker changed from Bug to Feature

Not a bug, TVH doesn't currently handle file moves. I'll try and look at this for 4.0.

Adam

#2

Updated by Adam Sutton almost 11 years ago

  • Category changed from General to PVR / DVR
  • Status changed from New to Accepted

TVH will detect simple renames, but not moves, now.

But some better integration with external scripts would be good.

Adam

Also available in: Atom PDF