[Solved]Post processing with ffmpeg for roku direct play

Come up with a useful post-processing script? Share it here!
Post Reply
philhachey
Newbie
Newbie
Posts: 6
Joined: July 26th, 2012, 6:31 pm

[Solved]Post processing with ffmpeg for roku direct play

Post by philhachey »

I'm trying to get this post script working in lubuntu
### Transcode mp4 files for the roku

if [ -z $1 ]; then
echo "Usage: `basename $0` filename"
exit 0
fi

Wait while any other ffmpeg processes are running
while [ -n "$(ps -ef | egrep "ffmpeg" | grep -v grep)" ];
do
echo -e "\n[$(date +%b\ %d\ %Y:\ %H:%M:%S)]\nFound another instance of ffmpeg running, pausing 5 minutes..."
sleep 300
done

# ffmpeg cmd
ffmpeg -y -i $1 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1 -acodec libfaac -ab 192k -ac 2 -threads 0 $1.mp4

exit 0
For some reason it keeps giving the error: "ffmpeg: command not found"

I have ffmpeg built from source with h246 and the command was copied (after running and working) directly from a terminal.

Any help would be appreciated.

-phil
Last edited by philhachey on August 1st, 2012, 10:29 pm, edited 1 time in total.
philhachey
Newbie
Newbie
Posts: 6
Joined: July 26th, 2012, 6:31 pm

Re: Post processing with ffmpeg for roku direct play

Post by philhachey »

Ok, new problem.

Here is the script and how it has been modified so far
#!/bin/bash

### Transcode mp4 files for the roku

if [ -z $3 ]; then
echo "Usage: `basename $0` filename"
exit 0
fi

#Wait while any other ffmpeg processes are running
while [ -n "$(ps -ef | egrep "ffmpeg" | grep -v grep)" ];
do
echo -e "\n[$(date +%b\ %d\ %Y:\ %H:%M:%S)]\nFound another instance of ffmpeg running, pausing 5 minutes..."
sleep 300
done

# ffmpeg cmd
/home/phil/ffmpeg/ffmpeg -i /media/Media/tv/$3.* -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1 -acodec libfaac -ab 192k -ac 2 -threads 0 /media/Media/tv/$3.mp4

exit 0
As you can see I just needed to point to the installation path of ffmpeg as well as the full file input and output paths and change the $1(folder) to a $3(clean job name).*

So the problem now is it starts up ffmpeg but closes with this:
ffmpeg version git-2012-06-22-15bde06 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 22 2012 16:30:44 with gcc 4.6.3
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
libavutil 51. 60.100 / 51. 60.100
libavcodec 54. 29.100 / 54. 29.100
libavformat 54. 11.100 / 54. 11.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 82.100 / 2. 82.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, avi, from '/media/Media/tv/Weeds.S07E02.BDRip.XviD-CLUE.avi':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2540/release)
Duration: 00:27:56.47, start: 0.000000, bitrate: 1169 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16, 32 kb/s
[buffer @ 0x3283440] w:624 h:352 pixfmt:yuv420p tb:125/2997 fr:2997/125 sar:1/1 sws_param:flags=2
[ffmpeg_buffersink @ 0x32605a0] No opaque field provided
[libx264 @ 0x325c500] using SAR=1/1
[libx264 @ 0x325c500] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x325c500] ratecontrol_init: can't open stats file
Output #0, mp4, to '/media/Media/tv/Weeds.S07E02.BDRip.XviD-CLUE.mp4':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2540/release)
Stream #0:0: Video: h264 (hq), yuv420p, 624x352 [SAR 1:1 DAR 39:22], q=-1--1, pass 1, 90k tbn, 23.98 tbc
Stream #0:1: Audio: none, 48000 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> libx264)
Stream #0:1 -> #0:1 (mp3 -> libfaac)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
I am trying to work through this on my own the best I can but would appreciate any help.

-phil
fins
Newbie
Newbie
Posts: 1
Joined: August 1st, 2012, 12:44 am

Re: Post processing with ffmpeg for roku direct play

Post by fins »

Stream #0:1: Audio: none, 48000 Hz, stereo, s16, 128 kb/s

That seems like it cannot find the libfaac codec, or some other issue with the uadio related parameters.
philhachey
Newbie
Newbie
Posts: 6
Joined: July 26th, 2012, 6:31 pm

Re: Post processing with ffmpeg for roku direct play

Post by philhachey »

I just tried it with the perameters: -acodec copy and -vcodec copy. separately.

the audio codec worked but the video codec gave me the same error.
philhachey
Newbie
Newbie
Posts: 6
Joined: July 26th, 2012, 6:31 pm

Re: Post processing with ffmpeg for roku direct play

Post by philhachey »

Since the command works in terminal I have compared the outputs line for line:

"ratecontrol_init: can't open stats file"

Is where it seems to be going wrong.

Now I'm wondering if this is a permissions issue or maybe it cant find the stats file???

I guess the real question is why does it work in terminal but not as a post script?
philhachey
Newbie
Newbie
Posts: 6
Joined: July 26th, 2012, 6:31 pm

Re: Post processing with ffmpeg for roku direct play

Post by philhachey »

Got it!

The problem was with the "-pass 1" command.
Post Reply