SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Linux
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Linux Discussion related to the SageTV Media Center for Linux. Questions, issues, problems, suggestions, etc. relating to the SageTV Linux should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-13-2011, 09:14 PM
Korny Korny is offline
Sage Advanced User
 
Join Date: Nov 2010
Location: Minnesota
Posts: 87
Comcut + encoding for linux, a start to a linux mediastrink

Please fix my title to Media Shrink


First of all, I'm not a programmer so the following bash script is really quite ugly but it works and I'm using ALL free utilities. This is just a start to the script any input is greatly appreciated I'm basically planning on using this in SJQ It currently uses 1 argument but I'm thinking about adding a second as a bitrate so it would basically be process.sh filename.mpg 2000
As for required software

Project-x - if your using ubuntu I installed it using package manager

Wine via package manager

Comskip I've learned that installing things in "home" directories can be a bad thing for permissions, since SJQ4 client does NOT run as my user account it couldn't access comskip when installed in the ~/.wine directory instead I've installed it in a non restricted folder.

ffmpeg I used a newer version as noted http://ubuntuforums.org/showthread.php?t=786095

HandbrakeCLI https://edge.launchpad.net/~stebbins...brake-releases

I'm currently running Ubuntu 10.10 32bit if you are running another distro you'll have to figure out how to get the required programs yourself.
Anyhow the start of my simple file. I haven't made it start cleaning up after itself so I apologize. Also the copy command and CD command at the start are not needed and can be removed. I use them because Sagetv locks the recording directory.
This thing keeps getting ugglier and uglier


#!/bin/bash
renice 19 -p $$
filename=$1
mapvara="wronga"
mapvarV="wrongv"

cp /var/media/tv/$filename /media/Array1/TVprocess/$filename
cd /media/Array1/TVprocess
ffmpegout=$(ffmpeg -i $1 2>&1)

#Defining audio streams
#rem Audio streams
echo THIS IS THE OUTPUT OF $ffmpegout AND THE END OF THE OUTPUT
case $ffmpegout in
*"0.0[0x80]"*) mapvara="0.0" ;;
*"0.1[0x80]"*) mapvara="0.1" ;;
*"0.2[0x80]"*) mapvara="0.2" ;;
*) echo no audio ;;
esac
case $ffmpegout in
*"0.0[0x1e0]"*) mapvarv="0.0";;
*"0.1[0x1e0]"*) mapvarv="0.1" ;;
*"0.2[0x1e0]"*) mapvarv="0.2" ;;
*) echo no video ;;
esac
case $ffmpegout in
*"ac3"*) audiovar="ac3" ;;
*"mp2"*) mapvarv="mp2" ;;
*) echo no container ;;
esac

echo $mapvarv video
echo $mapvara audio
echo $audiovar container


#ffmpeg to remove unwanted audio stream
ffmpeg -i $filename -map $mapvarv -map $mapvara -vcodec copy -acodec copy -f vob ${filename%.*}maped.mpg
rm $filename
mv ${filename%.*}maped.mpg $filename
#rem comskip ensure
wine /media/Array1/TVprocess/comskip/comskip.exe /media/Array1/TVprocess/$filename

# ProjectX cutting
java -jar /usr/share/java/ProjectX.jar $filename -cut ${filename%.*}.mpg.Xcl

# FFmpeg remuxing PJX results
ffmpeg -i ${filename%.*}.m2v -i ${filename%.*}.$audiovar -vcodec copy -acodec copy -f vob ${filename%.*}muxed.mpg
# Encode
HandBrakeCLI -i ${filename%.*}muxed.mpg -e x264 -T -2 -b 2500 -r 29.97 -E copy -o ${filename%.*}.mkv

#clean up

mv ${filename%.*}.mkv ${filename%.*}dnd.mkv
rm ${filename%.*}.*
rm ${filename%.*}muxed.*
mv ${filename%.*}dnd.mkv ${filename%.*}.mkv

Also to get this script running in SJQ4
in executable /path/to/file/bash.sh
in arguments "$SJQ4_LAST_SEGMENT"
Make sure the file is executable

Last edited by Korny; 03-17-2011 at 04:28 PM. Reason: code clean up and setting lower priority
Reply With Quote
  #2  
Old 03-13-2011, 09:57 PM
Korny Korny is offline
Sage Advanced User
 
Join Date: Nov 2010
Location: Minnesota
Posts: 87
IF anyone has any other input it would be appreciated

Last edited by Korny; 03-17-2011 at 04:28 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Close to building a Linux SageTV Computer, which Linux distribution is best? davephan SageTV Linux 8 02-24-2011 06:57 PM
Dummies Guide for Conversion to Linux (a start) hanki SageTV Linux 4 11-12-2009 05:23 PM


All times are GMT -6. The time now is 01:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.