Ok, I seem to have found the issue. On my Mac, I have ffmpeg 0.7.11 and thus I can't debug properly as I can't get it to play nicely with rtmp streams. On my NAS, it only works if I enclose the stream parameters with quotes " ". E.g:
- Code:
/root/.serviio/opt/bin/ffmpeg -i "rtmp://s6.webport.tv/live/z020503.stream pageUrl=http://www.tvsector.com/ swfVfy=0 live=1" -y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts pipe:
Why isn't this done by default? Can I force it somehow? Feels like a workaround if I start messing with sed to do it.
EDIT: Here's my fix.
- Code:
#!/bin/bash
# Replace default ac3 codec with fixed-point one and enclose rtmp:// streams
ARGS=$(echo $@ | sed -E -e s,\(-acodec\ ac3\),\\1_fixed, -e s,\(rtmp.*live=1\),\"\\1\",)
# Call ffmpeg from wrapper script
echo /root/.serviio/opt/bin/ffmpeg $ARGS
/root/.serviio/opt/bin/ffmpeg $ARGS
# Return ffmpeg status
exit $?
There's one issue though. Calling on ffmpeg through the terminal totally works. Calling on it via the script only yields
- Code:
# /share/MD0_DATA/.qpkg/Serviio/ffmpeg.sh -i rtmp://s7.webport.tv/live/z010001.stream pageUrl=http://www.tvsector.com/ swfVfy=0 live=1 -y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts pipe:
/root/.serviio/opt/bin/ffmpeg -i "rtmp://s7.webport.tv/live/z010001.stream pageUrl=http://www.tvsector.com/ swfVfy=0 live=1" -y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3_fixed -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts pipe:
ffmpeg version 0.9-Serviio_Qnap, Copyright (c) 2000-2011 the FFmpeg developers
built on Feb 25 2012 08:20:00 with gcc 4.2.3
configuration: --arch=arm --enable-armv5te --prefix=/root/.serviio/opt --extra-cflags=-I/opt/include --extra-ldflags=-L/tmp/lib --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-pthreads --enable-libmp3lame --enable-librtmp --extra-version=Serviio_Qnap
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
"rtmp://s7.webport.tv/live/z010001.stream: No such file or directory
Calling ffmpeg directly (with parsed output) works.
- Code:
# /root/.serviio/opt/bin/ffmpeg -i "rtmp://s7.webport.tv/live/z010001.stream pageUrl=http://www.tvsector.com/ swfVfy=0 live=1" -y -async 1 -vcodec copy -vbsf h264_mp4toannexb -copyts -acodec ac3_fixed -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts pipe:
EDIT 2: Ok, fixed it. It was all in the script. A simple 'eval' prevented it from inserting ' ' around my parsed " ".
- Code:
#!/bin/bash
# Replace default ac3 codec with fixed-point one and enclose rtmp:// streams
ARGS=$(echo $@ | sed -E -e s,\(-acodec\ ac3\),\\1_fixed, -e s,\(rtmp.*live=1\),\"\\1\",)
# Call ffmpeg from wrapper script
echo /root/.serviio/opt/bin/ffmpeg $ARGS
eval /root/.serviio/opt/bin/ffmpeg $ARGS
# Return ffmpeg status
exit $?
ac3_fixed definately improves performance. I'm down from 30 % to a mere 15 % decoding HD streams.