Post-Processing with FFMPEG [Ubuntu shell script]

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
mahjohn
Newbie
Newbie
Posts: 4
Joined: February 10th, 2016, 7:38 pm

Post-Processing with FFMPEG [Ubuntu shell script]

Post by mahjohn »

SAB on Ubuntu 64.

I have a script that I use to change the container from MKV to MP4, remove subs, and convert audio to AC3. It does this using AVCONV (ffmpeg), and when finished deposits the new mp4 in a different directory. All of this works fine. However, when I call the script in SAB post-processing, it errors out. So what's going on? It looks like it is looking for a specific file called "*.mkv" instead of using "*" as a wildcard.

I chown/chmod as plex and sab and couchpotato use the same account...and want to ensure no permissions issues. Is there a better way, probably but I'm pushing the extent of my Linux abilities with this script as is... running manually this works well

Code: Select all

#!/bin/sh
#Change .MKV container to .MP4 and convert audio to AC3
for f in /videos/movies/_pending/*.mkv; do avconv -i "$f" -format mp4 -vcodec copy -acodec ac3 -strict -2 -sn -threads 3 -movflags +faststart "${f%.*}.mp4";$.mp4"; done
mv /videos/movies/_pending/*.mp4 /videos/movies/incoming
mv /videos/movies/_pending/*.mkv /videos/movies/completed
chown -R plex:media /videos/movies/incoming
chmod -R 777 /videos/movies/incoming
exit

calling from SAB post-processing..it errors out.

Code: Select all

           ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
/videos/movies/_pending/*.mkv: No such file or directory
mv: cannot stat ‘/videos/movies/_pending/*.mp4’: No such file or directory
mv: cannot stat ‘/videos/movies/_pending/*.mkv’: No such file or directory
chown: changing ownership of ‘/videos/movies/incoming’: Operation not permitted
chmod: changing permissions of ‘/videos/movies/incoming’: Operation not permitted
Thanks!!!
User avatar
sander
Release Testers
Release Testers
Posts: 9429
Joined: January 22nd, 2008, 2:22 pm

Re: Post-Processing with FFMPEG [Ubuntu shell script]

Post by sander »

I would put this before and after "for f ..." line:

Code: Select all

ls -al /videos/movies/_pending/
ls -al /videos/movies/_pending/*.mkv
... and then check in the output what you get.
mahjohn
Newbie
Newbie
Posts: 4
Joined: February 10th, 2016, 7:38 pm

Re: Post-Processing with FFMPEG [Ubuntu shell script]

Post by mahjohn »

That worked much better...failed on the permissions mod though. In the /etc/init.d/sabnzbdplus file I have USER=plex, which is correct, as I keep Plex, SAB, Couch Potato, and Sonarr with the same user account. However, when the script runs it errors on the chown/chmod and i see

Code: Select all

sabnzbd media
For the movie submitted from sab and being processed. "media" is the group. I don't want to disable the sabnzbd user on the server, as it looks like sab is using it...

1. Where is the sab user coming from if the etc/init.d/sabnzbdplus specifies USER=plex?
2. Is it possible to call the script as the plex user from within sab or inside the script? (i have no idea on this one).

thanks for the help, i'm getting closer.
Post Reply