Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Synology VideoStation ffmpeg wrapper with DTS, EAC3 and TrueHD support (Installation instructions in 1st comment)
#!/bin/bash
rev="12"
_log(){
echo "$(date '+%Y-%m-%d %H:%M:%S') - ${streamid} - $1" >> /tmp/ffmpeg.log
}
_log_para(){
echo "$1" | fold -w 120 | sed "s/^.*$/$(date '+%Y-%m-%d %H:%M:%S') - ${streamid} - = &/" >> /tmp/ffmpeg.log
}
_term(){
rm /tmp/ffmpeg-${streamid}.stderr
_log "*** KILLCHILD ***"
kill -TERM "$childpid" 2>/dev/null
}
trap _term SIGTERM
arch=`uname -a | sed 's/.*synology_//' | cut -d '_' -f 1`
nas=`uname -a | sed 's/.*synology_//' | cut -d '_' -f 2`
pid=$$
paramvs=$@
stream="${@: -1}"
streamid="FFM$pid"
bin1=/var/packages/ffmpeg/target/bin/ffmpeg
bin2=/var/packages/VideoStation/target/bin/ffmpeg.orig
args=()
vcodec="KO"
while [[ $# -gt 0 ]]
do
case "$1" in
-i)
shift
movie="$1"
args+=("-i" "$1")
;;
-hwaccel)
shift
hwaccel="$1"
args+=("-hwaccel" "$1")
;;
-scodec)
shift
scodec="$1"
args+=("-scodec" "$1")
;;
-f)
shift
fcodec="$1"
args+=("-f" "$1")
;;
-map)
shift
args+=("-map" "$1")
idmap=`echo $1 | cut -d : -f 2`
if [ "$vcodec" = "KO" ]; then
vcodec=`/var/packages/ffmpeg/target/bin/ffprobe -v error -select_streams $idmap -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$movie" | head -n 1`
vcodecprofile=`/var/packages/ffmpeg/target/bin/ffprobe -v error -select_streams $idmap -show_entries stream=profile -of default=noprint_wrappers=1:nokey=1 "$movie" | head -n 1`
else
acodec=`/var/packages/ffmpeg/target/bin/ffprobe -v error -select_streams $idmap -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$movie" | head -n 1`
fi
;;
*)
args+=("$1")
;;
esac
shift
done
_log "*** PROCESS START REV $rev DS$nas ($arch) PID $pid ***"
streamdir=`dirname "$stream"`
device=`cat ${streamdir}/video_metadata | jq -r '.device'`
_log "DEVICE = $device"
_log "MOVIE = $movie"
set -- "${args[@]}"
argsnew=()
args1sv=()
args2sv=()
args1vs=()
args2vs=()
while [[ $# -gt 0 ]]
do
case "$1" in
-ss)
shift
argsnew+=("-ss" "$1")
args1sv+=("-ss" "$1")
args1sv+=("-noaccurate_seek")
args1vs+=("-ss" "$1")
args1vs+=("-noaccurate_seek")
args2sv+=("-analyzeduration" "10000000")
args2vs+=("-analyzeduration" "10000000")
;;
-i)
shift
argsnew+=("-i" "$1")
args1sv+=("-i" "$1")
args2sv+=("-i" "pipe:0" "-map" "0")
args1vs+=("-i" "$1")
args2vs+=("-i" "pipe:0" "-map" "0")
;;
-vf)
shift
if [ "$hwaccel" = "vaapi" ] && [ "$vcodecprofile" = "Main 10" ]; then
scale_w=`echo "${1}" | sed -e 's/.*=w=//g' | sed -e 's/:h=.*//g'`
scale_h=`echo "${1}" | sed -e 's/.*:h=//g'`
if let ${scale_w} AND let ${scale_h}; then
argsnew+=("-vf" "scale_vaapi=w=${scale_w}:h=${scale_h}:format=nv12,hwupload,setsar=sar=1")
else
argsnew+=("-vf" "scale_vaapi=format=nv12,hwupload,setsar=sar=1")
fi
else
argsnew+=("-vf" "$1")
fi
args2sv+=("-vf" "$1")
args1vs+=("-vf" "$1")
;;
-vcodec)
shift
argsnew+=("-vcodec" "$1")
args1sv+=("-vcodec" "copy")
args2sv+=("-vcodec" "$1")
args1vs+=("-vcodec" "$1")
args2vs+=("-vcodec" "copy")
;;
-acodec)
shift
if [ "$1" = "libfaac" ]; then
argsnew+=("-acodec" "aac")
args1sv+=("-acodec" "aac")
args2vs+=("-acodec" "aac")
else
argsnew+=("-acodec" "$1")
args1sv+=("-acodec" "$1")
args2vs+=("-acodec" "$1")
fi
args2sv+=("-acodec" "copy")
args1vs+=("-acodec" "copy")
;;
-ab)
shift
argsnew+=("-ab" "$1")
args1sv+=("-ab" "$1")
args2vs+=("-ab" "$1")
;;
-ac)
shift
argsnew+=("-ac" "$1")
args1sv+=("-ac" "$1")
args2vs+=("-ac" "$1")
;;
-f)
shift
argsnew+=("-f" "$1")
args1sv+=("-f" "mpegts")
args2sv+=("-f" "$1")
args1vs+=("-f" "mpegts")
args2vs+=("-f" "$1")
;;
-segment_format)
shift
argsnew+=("-segment_format" "$1")
args2vs+=("-segment_format" "$1")
args2sv+=("-segment_format" "$1")
;;
-segment_list_type)
shift
argsnew+=("-segment_list_type" "$1")
args2vs+=("-segment_list_type" "$1")
args2sv+=("-segment_list_type" "$1")
;;
-hls_seek_time)
shift
argsnew+=("-hls_seek_time" "$1")
args2vs+=("-hls_seek_time" "$1")
args2sv+=("-hls_seek_time" "$1")
;;
-segment_time)
shift
argsnew+=("-segment_time" "$1")
args2vs+=("-segment_time" "$1")
args2sv+=("-segment_time" "$1")
;;
-segment_time_delta)
shift
argsnew+=("-segment_time_delta" "$1")
args2vs+=("-segment_time_delta" "$1")
args2sv+=("-segment_time_delta" "$1")
;;
-segment_start_number)
shift
argsnew+=("-segment_start_number" "$1")
args2vs+=("-segment_start_number" "$1")
args2sv+=("-segment_start_number" "$1")
;;
-individual_header_trailer)
shift
argsnew+=("-individual_header_trailer" "$1")
args2vs+=("-individual_header_trailer" "$1")
args2sv+=("-individual_header_trailer" "$1")
;;
-avoid_negative_ts)
shift
argsnew+=("-avoid_negative_ts" "$1")
args2vs+=("-avoid_negative_ts" "$1")
args2sv+=("-avoid_negative_ts" "$1")
;;
-break_non_keyframes)
shift
argsnew+=("-break_non_keyframes" "$1")
args2vs+=("-break_non_keyframes" "$1")
args2sv+=("-break_non_keyframes" "$1")
;;
-max_muxing_queue_size)
shift
args2vs+=("-max_muxing_queue_size" "$1")
args2sv+=("-max_muxing_queue_size" "$1")
;;
-map)
shift
argsnew+=("-map" "$1")
args1sv+=("-map" "$1")
args1vs+=("-map" "$1")
;;
*)
argsnew+=("$1")
if [ "$stream" = "$1" ]; then
args1sv+=("-bufsize" "1024k" "pipe:1")
args2sv+=("$1")
args1vs+=("-bufsize" "1024k" "pipe:1")
args2vs+=("$1")
else
args2sv+=("$1")
args1vs+=("$1")
fi
;;
esac
shift
done
sed -i -e "s/{\"PID\":${pid},\"hardware_transcode\":true,/{\"PID\":${pid},\"hardware_transcode\":false,/" /tmp/VideoStation/enabled
startexectime=`date +%s`
if [ "$scodec" = "subrip" ]; then
_log "FFMPEG = $bin2"
_log "CODEC = $scodec"
_log "PARAMVS ="
_log_para "$paramvs"
$bin2 "${args[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
elif [ "$fcodec" = "mjpeg" ]; then
_log "FFMPEG = $bin2"
_log "CODEC = $fcodec"
_log "PARAMVS ="
_log_para "$paramvs"
$bin2 "${args[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
else
_log "VCODEC = $vcodec ($vcodecprofile)"
_log "ACODEC = $acodec"
_log "PARAMVS ="
_log_para "$paramvs"
_log "MODE = WRAP"
_log "FFMPEG = $bin1"
_log "PARAMWP ="
param1=${argsnew[@]}
_log_para "$param1"
$bin1 "${argsnew[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
fi
childpid=$!
_log "CHILDPID = $childpid"
wait $childpid
if grep "Conversion failed!" /tmp/ffmpeg-${streamid}.stderr || grep "Error opening filters!" /tmp/ffmpeg-${streamid}.stderr || grep "Unrecognized option" /tmp/ffmpeg-${streamid}.stderr || grep "Invalid data found when processing input" /tmp/ffmpeg-${streamid}.stderr; then
_log "*** CHILD END ***"
startexectime=`date +%s`
_log "STDOUT ="
_log_para "`tail -n 15 /tmp/ffmpeg-${streamid}.stderr`"
_log "MODE = PIPE SV"
_log "FFMPEG1 = $bin1"
_log "FFMPEG2 = $bin2"
_log "PARAM1 ="
param1=${args1sv[@]}
_log_para "$param1"
_log "PARAM2 ="
param2=${args2sv[@]}
_log_para "$param2"
$bin1 "${args1sv[@]}" | $bin2 "${args2sv[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
childpid=$!
_log "CHILDPID = $childpid"
wait $childpid
fi
if grep "Conversion failed!" /tmp/ffmpeg-${streamid}.stderr || grep "Error opening filters!" /tmp/ffmpeg-${streamid}.stderr || grep "Unrecognized option" /tmp/ffmpeg-${streamid}.stderr || grep "Invalid data found when processing input" /tmp/ffmpeg-${streamid}.stderr; then
_log "*** CHILD END ***"
startexectime=`date +%s`
_log "STDOUT ="
_log_para "`tail -n 15 /tmp/ffmpeg-${streamid}.stderr`"
_log "MODE = PIPE VS"
_log "FFMPEG1 = $bin2"
_log "FFMPEG2 = $bin1"
_log "PARAM1 ="
param1=${args1vs[@]}
_log_para "$param1"
_log "PARAM2 ="
param2=${args2vs[@]}
_log_para "$param2"
$bin2 "${args1vs[@]}" | $bin1 "${args2vs[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
childpid=$!
_log "CHILDPID = $childpid"
wait $childpid
fi
if grep "Conversion failed!" /tmp/ffmpeg-${streamid}.stderr || grep "Error opening filters!" /tmp/ffmpeg-${streamid}.stderr || grep "Unrecognized option" /tmp/ffmpeg-${streamid}.stderr || grep "Invalid data found when processing input" /tmp/ffmpeg-${streamid}.stderr; then
_log "*** CHILD END ***"
startexectime=`date +%s`
_log "STDOUT ="
_log_para "`tail -n 15 /tmp/ffmpeg-${streamid}.stderr`"
_log "MODE = ORIG"
_log "FFMPEG = $bin2"
$bin2 "${args[@]}" &> /tmp/ffmpeg-${streamid}.stderr &
childpid=$!
_log "CHILDPID = $childpid"
wait $childpid
fi
stopexectime=`date +%s`
if test $((stopexectime-startexectime)) -lt 10; then
_log "STDOUT ="
_log_para "`tail -n 15 /tmp/ffmpeg-${streamid}.stderr`"
fi
_log "*** CHILD END ***"
_log "*** PROCESS END ***"
rm /tmp/ffmpeg-${streamid}.stderr
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 23, 2019

Original link of this gist: https://gist.github.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e

Installation instructions

The purpose of this script is to replace Synology VideoStation's ffmpeg by SynoCommunity's ffmpeg in order to increase Synology VideoStation's codec support such as DTS, EAC3 and TrueHD as well as various optimizations.
This wrapper script and these instructions are a kind of compilation of 278 comments on more than 2 years of exchanges on the following issue SynoCommunity/spksrc#2952

Dependencies

Installation (for rtd1296 armv8)

On last ARM NAS, Synology uses gstreamer to transcode video instead of ffmpeg. So that wrapper only partially works.
On the other hand, it's possible to get libs supporting DTS, EAC3 and TrueHD on VideoStation version 2.3.4 to use them on VideoStation version 2.4.6.
Here is how to proceed:

  • Uninstall VideoStation (you can keep the database, it will be recognized by version 2.3.4)
  • Download version 2.3.4 here
  • Install the SPK via the "Manual installation" of the "Package Center".
  • Connecting to the NAS via SSH with "admin" user (some help here)
  • Use the command sudo -i to switch to root user (same password as for "admin")
  • Copy / paste the following commands:
# Copy VideoStation's ffmpeg libs
cp -a /var/packages/VideoStation/target/lib/ffmpeg /tmp/
  • Update VideoStation in "Package Center"
  • Copy / paste the following commands:
# Save VideoStation's ffmpeg libs
mv -n /var/packages/VideoStation/target/lib/ffmpeg /var/packages/VideoStation/target/lib/ffmpeg.orig
# Replace by old VideoStation's ffmpeg libs
mv /tmp/ffmpeg /var/packages/VideoStation/target/lib/
# Save VideoStation's libsynovte.so
cp -n /var/packages/VideoStation/target/lib/libsynovte.so /var/packages/VideoStation/target/lib/libsynovte.so.orig
chown VideoStation:VideoStation /var/packages/VideoStation/target/lib/libsynovte.so.orig
# Patch libsynovte.so to authorize DTS, EAC3 and TrueHD
sed -i -e 's/eac3/3cae/' -e 's/dts/std/' -e 's/truehd/dheurt/' /var/packages/VideoStation/target/lib/libsynovte.so
  • Restart VideoStation (Stop/Start in "Package Center")

Uninstallation (for rtd1296 armv8)

  • Copy / paste the following commands:
# Restore VideoStation's ffmpeg libs, libsynovte.so
rm -f /var/packages/VideoStation/target/lib/ffmpeg
mv -f /var/packages/VideoStation/target/lib/ffmpeg.orig /var/packages/VideoStation/target/lib/ffmpeg
mv -f /var/packages/VideoStation/target/lib/libsynovte.so.orig /var/packages/VideoStation/target/lib/libsynovte.so
  • Or, more simply, uninstall and re-install VideoStation

Installation (for x64, x86 and old arm arch)

  • Connecting to the NAS via SSH with "admin" user (some help here)
  • Use the command sudo -i to switch to root user (same password as for "admin")
  • Copy / paste the following commands:
# Save VideoStation's ffmpeg
mv -n /var/packages/VideoStation/target/bin/ffmpeg /var/packages/VideoStation/target/bin/ffmpeg.orig
# Injecting the script (last revision aka 12)
wget -O - https://gist.githubusercontent.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e/raw/ffmpeg-wrapper > /var/packages/VideoStation/target/bin/ffmpeg
# Change ownership and mode of the script
chown root:VideoStation /var/packages/VideoStation/target/bin/ffmpeg
chmod 750 /var/packages/VideoStation/target/bin/ffmpeg
chmod u+s /var/packages/VideoStation/target/bin/ffmpeg
# Save VideoStation's libsynovte.so
cp -n /var/packages/VideoStation/target/lib/libsynovte.so /var/packages/VideoStation/target/lib/libsynovte.so.orig
chown VideoStation:VideoStation /var/packages/VideoStation/target/lib/libsynovte.so.orig
# Patch libsynovte.so to authorize DTS, EAC3 and TrueHD
sed -i -e 's/eac3/3cae/' -e 's/dts/std/' -e 's/truehd/dheurt/' /var/packages/VideoStation/target/lib/libsynovte.so
  • Restart VideoStation (Stop/Start in "Package Center")

Update the wrapper (for x64, x86 and old arm arch)

  • Copy / paste the following commands:
# Injecting the script (last revision aka 12)
wget -O - https://gist.githubusercontent.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e/raw/ffmpeg-wrapper > /var/packages/VideoStation/target/bin/ffmpeg

Uninstallation (for x64, x86 and old arm arch)

  • Copy / paste the following commands:
# Restore VideoStation's ffmpeg, libsynovte.so
mv -f /var/packages/VideoStation/target/bin/ffmpeg.orig /var/packages/VideoStation/target/bin/ffmpeg
mv -f /var/packages/VideoStation/target/lib/libsynovte.so.orig /var/packages/VideoStation/target/lib/libsynovte.so
  • Or, more simply, uninstall and re-install VideoStation

Feedback

Leaving a feedback when there is a problem or a suggestion is very useful but leaving one when everything is going well is just as useful.
If the wapper works well for you, please leave a comment with the following information (e.g.):

Synology DS718+ / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19 / ffmpeg wrapper (rev8):
Everything's working fine! But a high CPU load in h265 10bit 4k

Feel free to read the reviews already present in the Compatibility section, you will surely find useful information.

Compatibility

The wrapper is supposed to work with the latest versions of DSM / VideoStation for all Synology NAS.
Here below the list of the tests performed so far according to softwares different versions:

DSM 6.2.2 / Video Station 2.4.6 / ffmpeg 4.2.1-23

  • ffmpeg wrapper rev8-11
    • Synology DS918+: Test OK (Review) (Review)
    • Synology DS718+: Test OK (Review)
    • Synology DS218+: Test OK (Review)
    • Synology DS218: Test KO (Review)
    • Synology DS916+: Test OK (Review)
    • Synology DS216+II: Test OK (Review)
    • Synology DS414: Test OK (Review)
    • Synology DS214play: Test KO (Review)

Alternative

If you are uncomfortable with this procedure, if your NAS is not yet compatible with ffmpeg pre-release or if you can't get the desired result, you can also downgrade VideoStation to version 2.3.4 which is the latest version compatible with DTS, EAC3 and TrueHD by simply installing SynoCommunity ffmpeg and without any command line.

Here is the procedure to follow:

  • Uninstall VideoStation (you can keep the database, it will be recognized by version 2.3.4)
  • Download version 2.3.4 here
  • Install the SPK via the "Manual installation" of the "Package Center".
  • Install the latest ffmpeg version of SynoCommunity: https://synocommunity.com (with VideoStation version 2.3.4 the official ffmpeg version of SynoCommunity works)

Current issues

Changelog

TODO

Todo

TODO

Credits

@th0ma7 for the great job on ffmpeg
@neves-0 for the original idea of the script (SynoCommunity/spksrc#2952 (comment))
SynoCommunity and Contributors (https://synocommunity.com)
@kc6108 and people on (SynoCommunity/spksrc#2952)

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 26, 2019

@kc6108, you never stop!!!!
The rev6 is not bad at all.
I've simplified the parent/child logic of the processes: The parent waits for the child to die to stop and I catch the parent's SIG TERM to kill the child.
I also fixed the built-in subtitle problem in vobsub format. I am forced to use VideoStation's ffmpeg to do the sub to srt conversion because I get a permission denied with SynoCommunity's one.
I haven't tested yet if there is the same issue with the symlink or the exec command. It's not obvious to test because VideoStation stores all the conversions, so you have to take a video that has never been played.
Otherwise, I just noticed that I have the same error as @malhal on the offline conversion of DTS, EAC3 and TrueHD videos (via the browser) I feel like it's another blockage, I'm surprised you don't have this bug.
Finally, I saw that you made a symbolic link on vainfo, is there a particular reason?

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Dec 26, 2019

Good work guys!
BTW, the -vprofile change to -x264profile shouldn't be needed anymore as I've included @kc6106 patch in my -19 version.
Also, I've noticed that tne ,hwupload,setsar=sar=1 parameters can be kept (at least on my apollolake/J3455 processor).
I suggest you keep theses parameters as well in your logic part of -vp section, could even processor based if it pose problems to other CPU types.

@Denton22

This comment has been minimized.

Copy link

@Denton22 Denton22 commented Dec 26, 2019

I have tested Release FFmpeg -19 with one of the older scripts and with the current one. The new Script seems to performe worse then the older revision, sometimes the video freezes while audio continous to play and i even got a full freeze in Video Station after trying the high bitrate mode. With the older revision i do not have any of those problems, i do not even see any orphan processes.

Here is the revision i mean:

#!/bin/bash

paramvs=$@
args=()
while [[ $# -gt 0 ]]
do
case "$1" in
	#-hls_seek_time)
			#shift
			#hls_seek_time="$1"
    #;;
	-i)
		shift
		movie="$1"
		args+=("-i" "$1")
    ;;
	-vaapi_device)
		shift
		args+=("-vaapi_device" "$1")
    ;;
	-hwaccel)
		shift
		args+=("-hwaccel" "$1")
    ;;
	-hwaccel_output_format)
		shift
		args+=("-hwaccel_output_format" "$1")
    ;;
	-vcodec)
		shift
		args+=("-vcodec" "$1")
		#args+=("-vcodec" "libx264")
    ;;
	-vf)
		shift
		#args+=("-vf" "scale_vaapi=w=320:h=240:format=nv12")
		args+=("-vf" "$1")
		#args+=("-filter:v" "scale=720:-1")
    ;;
	-vb)
		shift
		args+=("-vb" "$1")
		#args+=("-preset" "ultrafast")
    ;;
	*)
		args+=("$1")
		stream="$1"
    ;;
esac
shift
done

streamhash=`echo $stream | cut -d / -f 5`
echo "MOVIE    = $movie" >> /tmp/ffmpeg.log
echo "STREAM   = $streamhash" >> /tmp/ffmpeg.log
echo "PARAM_VS = $paramvs" >> /tmp/ffmpeg.log

#args+=("-hls_seek_time" "$hls_seek_time")
bin=/var/packages/ffmpeg/target/bin/ffmpeg

set -- "${args[@]}"
echo "PARAM_RW = $@" >> /tmp/ffmpeg.log
echo "FFMPEG   = $bin" >> /tmp/ffmpeg.log

pkill -F /tmp/ffmpeg-${streamhash}.lastpid

$bin "$@" 2> /tmp/ffmpeg-${streamhash}.stdout &
childpid=$!

echo $childpid > /tmp/ffmpeg-${streamhash}.lastpid
echo "CHILDPID = $childpid" >> /tmp/ffmpeg.log

wait $childpid

if grep "Conversion failed!" /tmp/ffmpeg-${streamhash}.stdout; then
	echo "ERROR   = Conversion failed!" >> /tmp/ffmpeg.log
	args=()
	while [[ $# -gt 0 ]]
	do
	case "$1" in
		-vf)
			shift
			scale_w=`echo "${1}" | sed -e 's/.*=w=//g' | sed -e 's/:h=.*//g'`
			scale_h=`echo "${1}" | sed -e 's/.*:h=//g'`
			args+=("-vf" "scale_vaapi=w=${scale_w}:h=${scale_h}:format=nv12")
		;;
		*)
			args+=("$1")
		;;
	esac
	shift
	done
	set -- "${args[@]}"
	echo "PARAM_RW = $@" >> /tmp/ffmpeg.log
	echo "FFMPEG   = $bin" >> /tmp/ffmpeg.log
	
	$bin "$@" &
	childpid=$!
	
	echo $childpid > /tmp/ffmpeg-${streamhash}.lastpid
	echo "CHILDPID = $childpid" >> /tmp/ffmpeg.log

	wait $childpid
fi

echo >> /tmp/ffmpeg.log
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 26, 2019

@th0ma7

Many thanks to you! Without your work our scripts wouldn't do much.
I made the changes you suggest in rev 8.

@Denton22

Thanks for the feedback,
Could you tell me your NAS model and the type of video that is problematic h264, h265, h265 10bit?
Otherwise, I just posted a new revision of the script (rev 8) with some adaptations corresponding to ffmpeg -19, maybe it will fix your bugs. (I've added an Update section in the installation instructions)
You can also look at the log in /tmp/ffmpeg.log
If you have tested a lot of scripts and methods you can also start from a fresh installation (VideoStation allows to keep the database) and follow the procedure of the first comment.

@Denton22

This comment has been minimized.

Copy link

@Denton22 Denton22 commented Dec 27, 2019

@th0ma7

Many thanks to you! Without your work our scripts wouldn't do much.
I made the changes you suggest in rev 8.

@Denton22

Thanks for the feedback,
Could you tell me your NAS model and the type of video that is problematic h264, h265, h265 10bit?
Otherwise, I just posted a new revision of the script (rev 8) with some adaptations corresponding to ffmpeg -19, maybe it will fix your bugs. (I've added an Update section in the installation instructions)
You can also look at the log in /tmp/ffmpeg.log
If you have tested a lot of scripts and methods you can also start from a fresh installation (VideoStation allows to keep the database) and follow the procedure of the first comment.

I have a Ds918+ . like i said, with the older script for me everthing is working flawlessly! I will try your new revision and give feedback later

All Files were problematic. I played a 4k HEVC Truehd File and a 1080P h246 DTS File both had visual freezes und stutters (also loading times in videostation)

I can rule out Performance problems duo to external factors, reverting back did fix the Problem.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 27, 2019

@kc6108

I stumbled a bit by chance on this subtitle problem.
In fact, before playing the video or at the time of a subtitle selection, VideoStation extracts the subtitles in text format into an .srt file in order to display them.
They are stored in the @eaDir directory where the video is located.

Here is a procedure to reproduce the error:

  1. Delete subtitles from the video in the @eaDir directory.

  2. Edit the shell script (rev 11) by removing the workaround I set up:

[...]

if echo $stream | grep "/tmp/SYNOVIDEO_ffmpeg_.*\.srt"; then
	streamhash=`echo $stream | cut -d _ -f 3 | sed -e 's/.srt//g'`
	#bin=/var/packages/VideoStation/target/bin/ffmpeg.orig
	bin=/var/packages/ffmpeg/target/bin/ffmpeg
fi

[...]
  1. Run the video: subtitles are not displayed and they are not re-created in "@eadir", there are only empty lock files.

  2. Error output can be found in /tmp/ffmpeg.log and in /var/log/apparmor.log

I've tested it with the symbolic link method and it doesn't work either.

BTW

Otherwise, I just noticed that I have the same error as @malhal on the offline conversion of DTS, EAC3 and TrueHD videos (via the browser) I feel like it's another blockage, I'm surprised you don't have this bug.

I solved this problem simply by restarting VideoStation after applying the patch. I added this indication in the installation instructions

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 28, 2019

My bad !!!
So sorry, the problem I'm describing comes with an mkv with internal SRT subtitles. I was misled because the option used by ffmpeg is called subrip like the software. I foolishly thought ffmpeg was doing automatic SUB to SRT conversation. I've already done SUB to SRT with various softwares: it's very hard. I thought ffmpeg did it extremely easily and well !!!
I confirm that VideoStation does not read and has never read SUB and PGS subtitles like many software.
Thank you anyway for all your tests

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 30, 2019

For any volunteer, I have created a Feedback section (see here). I think it would be interesting for the wrapper as well as for the new ffmpeg to be released to collect positive feedbacks as well.

@felix-m-p

This comment has been minimized.

Copy link

@felix-m-p felix-m-p commented Dec 30, 2019

Synology DS218+ / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1600 / ffmpeg 4.2.1-19 / ffmpeg wrapper (rev8):
Working fine, tested with TrueHD and DTS, but also high CPU load, 2 Streams 4k h265 works well.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 30, 2019

Thank you, @felix-m-p!
Could you please tell me if the high CPU load only occurs when the wrapper is in RW mode or not ?
With the rev8, you can see it in the log /tmp/ffmpeg.log with the line: "ERROR = Conversion failed!"

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 30, 2019

Synology DS718+ / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19 / ffmpeg wrapper (rev8):
Just amazing! Slightly high CPU load with the h265 10bit

@felix-m-p

This comment has been minimized.

Copy link

@felix-m-p felix-m-p commented Dec 30, 2019

Could you please tell me if the high CPU load only occurs when the wrapper is in RW mode or not ?
With the rev8, you can see it in the log /tmp/ffmpeg.log with the line: "ERROR = Conversion failed!"

Yes the line "ERROR = Conversion failed!" is there, after that is "PARAM_RW = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_o" .

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 30, 2019

Yes the line "ERROR = Conversion failed!" is there, after that is "PARAM_RW = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_o" .

When this line is present it's normal to have a higher CPU load, it only happens with h265 10bit videos because hardware acceleration is only pariel with apollolake processors. I'm hopeful that with Intel Quick Sync support we can get better results (see: SynoCommunity/spksrc#3830).

If you notice high CPU loads with other types of videos, I'm interested.

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Dec 31, 2019

Synology DS214play / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19 / video: 4502 Kbps H264; audio: 1509 Kbps DTS; subs: Eng, Esp, Fre, prg

ffmpeg wrapper (rev8, @kc6108's, @th0ma7's latest) and symlinking:

Playing through VideoStation's web UI works fine but Chromecast fails to load

Synology DS214play / DSM 6.2.2-24922 Update 4 / Video Station 2.3.4-1468 / video: 4502 Kbps H264; audio: 1509 Kbps DTS; subs: Eng, Esp, Fre, prg

Playing through VideoStation's web UI and Chromecast works

Synology DS214play / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / video: 2300 Kbps H264; audio: AC3

Playing through VideoStation's web UI and Chromecast works

Synology DS214play / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19 / video: 2300 Kbps H264; audio: AC3

Playing through VideoStation's web UI and Chromecast works

ffmpeg wrapper (rev8):

Playing through VideoStation's web UI works fine with the following output

MOVIE    = /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv
HASH     = 9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK
PARAM_VS = -ss 0.000 -i /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv -threads 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK/slice-%05d.ts
FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
CHILDPID = 20434
---KILLCHILD---

---CHILD END---
---PROCESS END---

MOVIE    = /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv
HASH     = 9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK
PARAM_VS = -ss 721.471 -i /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv -threads 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 721471 -segment_time 8 -segment_time_delta 1.471 -segment_start_number 00090 -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK/slice-%05d.ts
FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
CHILDPID = 20672
---KILLCHILD---

---CHILD END---
---PROCESS END---

MOVIE    = /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv
HASH     = 9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK
PARAM_VS = -ss 1176.634 -i /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv -threads 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 1176634 -segment_time 8 -segment_time_delta 0.634 -segment_start_number 00147 -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_zUVxvUNK/slice-%05d.ts
FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
CHILDPID = 20701
---KILLCHILD---

---CHILD END---
---PROCESS END---

Playing through Chromecast fails with the following output:

MOVIE    = /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv
HASH     = 9027301ddc12e0e29dbe1c9462a376c4_BNcGcv5q
PARAM_VS = -ss 1195.000 -prefer_smd -i /volume1/video/series/A.Video.720p.x264/A.Video.720p.x264.mkv -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 1000000 -acodec libfaac -ab 128K -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 1195000 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00239 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_BNcGcv5q/slice-%05d.ts
FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
CHILDPID = 23311
---CHILD END---
---PROCESS END---
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Dec 31, 2019

@c-b-h, thanks for the feedback.
We can say that the diffusion via the chromecast does not work :)
Personally, I've never tested it: Do you do it via DS Video ?
Have you tested the chromecast streaming with VideoStation 2.4.6 without the SynoCommunity ffmpeg and without the wrapper (via a clean install and on an AC3 video of course)? I think it should work but it's just to be sure.
And does the chromecast broadcast work with an AC3 video + the wrapper ?
Could you copy and paste the logs of the wrapper (/tmp/ffmpeg.log) corresponding to the launch via chromecast. If no new line appears on the chromecast launch, maybe this broadcast is not using the wrapper.
Finally did you test with and without the Passthrough AC3 option?

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Dec 31, 2019

2019-12-31 15 55 40

The DS Video app allows casting video to Chromecast as the screenshot entails.

Please re-visit my response that now includes logs from my attempts to cast video containing AC3.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 1, 2020

@c-b-h,

I noticed that the playback in the Web interface was in Original quality (so without transcoding h264) while in the Chomecast broadcast was in High quality (so with transcoding h264).
To confirm, what @kc6108 says, could you test the playback in the web interface in High (or Medium) quality which will force transcoding and should not work.
Finally, could you install the rev11 (see section Update): I have completely rewritten the log management, including adding a timeline and the STDERRs of ffmpeg that will allow us to see if VideoStation tries to use parameters not supported by the SynoCommunity ffmpeg.

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 1, 2020

Finally did you test with and without the Passthrough AC3 option?

I am not passing through AC3 but have also tried passing it through. Neither option enables the movie to be cast.

To confirm, what @kc6108 says, could you test the playback in the web interface in High (or Medium) quality which will force transcoding and should not work.

True to @BenjaminPoncet's claim, forcing transcoding prevented also the web interface from playing the stream. See logs below for details.

2020-01-01 19:17:00 - 1Y8ohfVP - *** PROCESS START ***
2020-01-01 19:17:00 - 1Y8ohfVP - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-01 19:17:00 - 1Y8ohfVP - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-01 19:17:00 - 1Y8ohfVP -          = -ss 0.000 -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv -threads 
2020-01-01 19:17:00 - 1Y8ohfVP -          = 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_forma
2020-01-01 19:17:00 - 1Y8ohfVP -          = t mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 
2020-01-01 19:17:00 - 1Y8ohfVP -          = -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_1Y8
2020-01-01 19:17:00 - 1Y8ohfVP -          = ohfVP/slice-%05d.ts
2020-01-01 19:17:00 - 1Y8ohfVP - CHILDPID = 21172
2020-01-01 19:17:17 - 1Y8ohfVP - *** KILLCHILD ***
2020-01-01 19:17:17 - 1Y8ohfVP - *** CHILD END ***
2020-01-01 19:17:17 - 1Y8ohfVP - *** PROCESS END ***
2020-01-01 19:17:23 - nekoqSSy - *** PROCESS START ***
2020-01-01 19:17:23 - nekoqSSy - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-01 19:17:23 - nekoqSSy - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-01 19:17:23 - nekoqSSy -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-01 19:17:23 - nekoqSSy -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 2374232 -acodec libmp3lame -ab 128K -ac 2 -
2020-01-01 19:17:23 - nekoqSSy -          = f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -se
2020-01-01 19:17:23 - nekoqSSy -          = gment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc1
2020-01-01 19:17:23 - nekoqSSy -          = 2e0e29dbe1c9462a376c4_nekoqSSy/slice-%05d.ts
2020-01-01 19:17:23 - nekoqSSy - CHILDPID = 21506
2020-01-01 19:17:24 - nekoqSSy - STDERR   =
2020-01-01 19:17:24 - nekoqSSy -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-01 19:17:24 - nekoqSSy -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-01 19:17:24 - nekoqSSy -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-01 19:17:24 - nekoqSSy -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-01 19:17:24 - nekoqSSy -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-01 19:17:24 - nekoqSSy -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-01 19:17:24 - nekoqSSy -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-01 19:17:24 - nekoqSSy -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-01 19:17:24 - nekoqSSy -          = Unrecognized option 'prefer_smd'.
2020-01-01 19:17:24 - nekoqSSy -          = Error splitting the argument list: Option not found
2020-01-01 19:17:24 - nekoqSSy - *** CHILD END ***
2020-01-01 19:17:24 - nekoqSSy - *** PROCESS END ***

The logs from rev 11 from attempting cast on Chromecast show:

2020-01-01 19:28:43 - 38IavJrg - *** PROCESS START ***
2020-01-01 19:28:43 - 38IavJrg - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-01 19:28:43 - 38IavJrg - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-01 19:28:43 - 38IavJrg -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-01 19:28:43 - 38IavJrg -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 1000000 -acodec libfaac -ab 128K -ac 2 -f s
2020-01-01 19:28:43 - 38IavJrg -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-01 19:28:43 - 38IavJrg -          = nt_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/Vi
2020-01-01 19:28:43 - 38IavJrg -          = deoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_38IavJrg/slice-%05d.ts
2020-01-01 19:28:43 - 38IavJrg - CHILDPID = 31023
2020-01-01 19:28:44 - 38IavJrg - STDERR   =
2020-01-01 19:28:44 - 38IavJrg -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-01 19:28:44 - 38IavJrg -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-01 19:28:44 - 38IavJrg -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-01 19:28:44 - 38IavJrg -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-01 19:28:44 - 38IavJrg -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-01 19:28:44 - 38IavJrg -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-01 19:28:44 - 38IavJrg -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-01 19:28:44 - 38IavJrg -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-01 19:28:44 - 38IavJrg -          = Unrecognized option 'prefer_smd'.
2020-01-01 19:28:44 - 38IavJrg -          = Error splitting the argument list: Option not found
2020-01-01 19:28:44 - 38IavJrg - *** CHILD END ***
2020-01-01 19:28:44 - 38IavJrg - *** PROCESS END ***
@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 2, 2020

Do we have a list of what's not working exactly with current ffmpeg 4.2.1 ?
Or is some of it relates to videostation not being compatible with v4.x of ffmpeg, thus needing translation?

Also, currently building packages using Intel iHD driver instead of the classic/legacy vaapi driver.
I should be able to provide x64 package tomorrow if interested at testing that.
BTW, package for apollolake specific arch already available and working really well.
Noticed that pixelation issue with h.265 during the first few mins is now gone :)

Pull request SynoCommunity/spksrc#3842

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 2, 2020

I installed (although not started the service after installation) Serviio 1.10.1 and picked ffmpeg 2.7.1 SMD support in the installation wizard and started using the new script but noticed that Serviio's ffmpeg is not being called.

Through ssh calling /volume1/@appstore/Serviio/bin/ffmpeg expectedly yields:

ffmpeg version 2.7.1-SMD_enabled-compiled_by_patters_for_Serviio Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/evansport-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/evansport-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libspeex --enable-libvorbis --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled-compiled_by_patters_for_Serviio
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

However when running the movie, the following logs are produced:

2020-01-02 09:12:12 - EvMQzWoW - *** PROCESS START ***
2020-01-02 09:12:12 - EvMQzWoW - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-02 09:12:12 - EvMQzWoW - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-02 09:12:12 - EvMQzWoW -          = -ss 0.000 -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv -threads 
2020-01-02 09:12:12 - EvMQzWoW -          = 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_forma
2020-01-02 09:12:12 - EvMQzWoW -          = t mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 
2020-01-02 09:12:12 - EvMQzWoW -          = -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_EvM
2020-01-02 09:12:12 - EvMQzWoW -          = QzWoW/slice-%05d.ts
2020-01-02 09:12:12 - EvMQzWoW - CHILDPID = 4064
2020-01-02 09:13:10 - EvMQzWoW - *** KILLCHILD ***
2020-01-02 09:13:10 - EvMQzWoW - *** CHILD END ***
2020-01-02 09:13:10 - EvMQzWoW - *** PROCESS END ***
2020-01-02 09:13:17 - JTgFlAgy - *** PROCESS START ***
2020-01-02 09:13:17 - JTgFlAgy - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-02 09:13:17 - JTgFlAgy - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-02 09:13:17 - JTgFlAgy -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-02 09:13:17 - JTgFlAgy -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 1000000 -acodec libmp3lame -ab 128K -ac 2 -
2020-01-02 09:13:17 - JTgFlAgy -          = f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -se
2020-01-02 09:13:17 - JTgFlAgy -          = gment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc1
2020-01-02 09:13:17 - JTgFlAgy -          = 2e0e29dbe1c9462a376c4_JTgFlAgy/slice-%05d.ts
2020-01-02 09:13:17 - JTgFlAgy - CHILDPID = 5285
2020-01-02 09:13:18 - JTgFlAgy - STDERR   =
2020-01-02 09:13:18 - JTgFlAgy -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-02 09:13:18 - JTgFlAgy -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-02 09:13:18 - JTgFlAgy -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-02 09:13:18 - JTgFlAgy -          = Unrecognized option 'prefer_smd'.
2020-01-02 09:13:18 - JTgFlAgy -          = Error splitting the argument list: Option not found
2020-01-02 09:13:18 - JTgFlAgy - *** CHILD END ***
2020-01-02 09:13:18 - JTgFlAgy - *** PROCESS END ***

Note that EvMQzWoW refers to the movie being started without forced transcoding while JTgFlAgy is the result of forcing quality to Medium. Not an expert in bash script but it's seems obvious that the else if should have been picked correctly given prefer_smd is being passed.

elif echo $paramvs | grep "-prefer_smd"; then
	bin=/volume1/@appstore/Serviio/bin/ffmpeg
fi
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 2, 2020

@kc6108 You rock !!!
With the Serviio ffmpeg it is not necessary to remove the hls_seek_time parameter ?
However, I'm really not sure if it works because I tried with Emby's ffmpeg and I got the same error as with the subtitles : Permission denied, even if you change the rights...
You know Emby well, don't they have a newer version with Intel SMD (Evansport) support? During your research, you didn't find any source code for the Intel SMD plugin? I searched on Synology's sourceforge in the latest version of VideoStation, there are references to this plugin but no source code...

@intothevoid

This comment has been minimized.

Copy link

@intothevoid intothevoid commented Jan 2, 2020

@BenjaminPoncet Thank you for the clear instructions and your effort. I tested ffmpeg_x64-6.1_4.2.1-20.spk with my DS918+ and DTS is now working via VideoStation in my browser.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 2, 2020

@c-b-h,
There's good news for you here: SynoCommunity/spksrc#3842
If we can count on you to test the new versions of SynoCommunity ffmpeg it would be great!
On my side, I have 2 new features in preparation for the wrapper that will allow you to have everything working:

  • The ability to use Synology ffmpeg automatically when the audio is not DTS etc...
  • And the ability to use transcoding without hardware acceleration, when the support is not or not yet available on the SynoCommunity ffmpeg. It's not great for the CPU but it would make DTS work.

Finally if you can test the @kc6108 script with the ffmpeg Serviio it would be useful for future workarounds.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 2, 2020

@BenjaminPoncet Thank you for the clear instructions and your effort. I tested ffmpeg_x64-6.1_4.2.1-20.spk with my DS918+ and DTS is now working via VideoStation in my browser.

@intothevoid, thanks for your feedback!
The -20 version at less than 24 hours. It contains important changes compared to the previous versions. Do not hesitate to report any abnormal behavior.
Did you use the wrapper rev 11?

@ChrWinde

This comment has been minimized.

Copy link

@ChrWinde ChrWinde commented Jan 2, 2020

Hi

I've got no skills in programming what so ever. I can't get DTS sound to work on a DS414, and I guess the ffmpeg version 4.2.1-19 (beta) isn't realeased for the armadaxp processor yet. Any idea when it will be released?

For the record, DS Video actually plays DTS sound using the combination above, but the screen is black and there's no sound. Also, the processor seems to be at 20 %, so I'm guessing it doesn't do a lot of transcoding ;-)

I'm getting pretty sick not being able to play movies with DTS.

EDIT:
Nevermind. It actually works on DS Video directly on my Samsung TV. However, on the Apple TV everything is fucked. I guess it requires a reinstall.

//Winde

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 3, 2020

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 3, 2020

@ChrWinde

You've earned the right to give us a little feedback for your DS414 !!! (see feedback section of the installation instructions)

Thank you.

@ChrWinde

This comment has been minimized.

Copy link

@ChrWinde ChrWinde commented Jan 3, 2020

@ChrWinde

This comment has been minimized.

Copy link

@ChrWinde ChrWinde commented Jan 4, 2020

Synology DS414 / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19:

Tested on:

  • Apple TV (DS Video): The "movie" starts playing, but there's no image nor sound. I'm not sure if it's correlated to ffmpeg 4.2.1-19.
  • Samsung TV (DS Video): Works like a charm
  • Apple iPhone (DS Video): Works like a charm
@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 5, 2020

@ChrWinde
I just made a build for you with latest fixes.
https://github.com/th0ma7/synology/blob/master/packages/ffmpeg_armadaxp-6.1_4.2.1-20.spk

I'm somewhat confused. Is the prefer_smd embedded in the new ffmpeg version for Evansport? Do we still need to keep around the Serviio's 2.7 implementation of ffmpeg for @kc6108's wrapper?

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 5, 2020

Evansport with rev11:

2020-01-05 20:55:30 - v1JwH4oE - *** PROCESS START ***
2020-01-05 20:55:30 - v1JwH4oE - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-05 20:55:30 - v1JwH4oE - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-05 20:55:30 - v1JwH4oE -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-05 20:55:30 - v1JwH4oE -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-05 20:55:30 - v1JwH4oE -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-05 20:55:30 - v1JwH4oE -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-05 20:55:30 - v1JwH4oE -          = e29dbe1c9462a376c4_v1JwH4oE/slice-%05d.ts
2020-01-05 20:55:30 - v1JwH4oE - CHILDPID = 9880
2020-01-05 20:55:31 - v1JwH4oE - STDERR   =
2020-01-05 20:55:31 - v1JwH4oE -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-05 20:55:31 - v1JwH4oE -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-05 20:55:31 - v1JwH4oE -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-05 20:55:31 - v1JwH4oE -          = Unrecognized option 'prefer_smd'.
2020-01-05 20:55:31 - v1JwH4oE -          = Error splitting the argument list: Option not found
2020-01-05 20:55:31 - v1JwH4oE - *** CHILD END ***
2020-01-05 20:55:31 - v1JwH4oE - *** PROCESS END ***

Evansport with @kc0108's prefer_smd-fix:

2020-01-05 21:08:08 - PRWxkbtx - *** PROCESS START ***
2020-01-05 21:08:08 - PRWxkbtx - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-05 21:08:08 - PRWxkbtx - FFMPEG   = /volume1/@appstore/Serviio/bin/ffmpeg
2020-01-05 21:08:08 - PRWxkbtx -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-05 21:08:08 - PRWxkbtx -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-05 21:08:08 - PRWxkbtx -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-05 21:08:08 - PRWxkbtx -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-05 21:08:08 - PRWxkbtx -          = e29dbe1c9462a376c4_PRWxkbtx/slice-%05d.ts
2020-01-05 21:08:09 - PRWxkbtx - CHILDPID = 21859
2020-01-05 21:08:09 - PRWxkbtx - STDERR   =
2020-01-05 21:08:09 - PRWxkbtx -          = /volume1/@appstore/Serviio/bin/ffmpeg: error while loading shared libraries: libavdevice.so.56: failed to map segment fr
2020-01-05 21:08:09 - PRWxkbtx -          = om shared object
2020-01-05 21:08:09 - PRWxkbtx - *** CHILD END ***
2020-01-05 21:08:09 - PRWxkbtx - *** PROCESS END ***
@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 6, 2020

My understanding is that Atom processor of evansport arch such as Intel Atom CE5335 are using a GPU based on PowerVR SGX545.
For more info see https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors
That means that Intel vaapi is not compatible at all.
Therefore vainfo neither.
I'm not even sure the userspace device file are similar (e.g. renderD128 type-thing).

I am currently working onto porting the synology code for _smd from ffmpeg 2.7 to 4.2.1...
But that is a hell of a long shot and it ain't working yet (and i don't have the nas to test it onto IF I make it to compile).

Work currently sits here:
https://github.com/th0ma7/spksrc/commits/ffmpeg-evansport

@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 8, 2020

First of all, a HUGE thanks to all who worked on this!
Synology DS918+ / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-21 / ffmpeg wrapper (rev11):

  1. From a web browser (Chrome and Firefox - latest versions)
    DTS and EAC3 seems to be working fine
  2. From DS Video installed on a Nvidia Shield
    DTS OK
    EAC3 KO (no sound)
    EAC3 and DTS working fine using MxPlayer + plugins as an external reader

I haven't looked in the logs yet. I will test on my Mi Box 3 as well

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 9, 2020

@kc6108, Bravo !

2020-01-09T01:12:36+01:00 SERVER kernel: [ 6814.937957] audit: type=1400 audit(1578528756.439:6): apparmor="DENIED" operation="exec" profile="/usr/syno/sbin/synoscgi//SYNO.VideoStation2.Subtitle" name="/volume1/@appstore/ffmpeg/bin/ffprobe" pid=28008 comm="ffmpeg" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
2020-01-09T01:12:36+01:00 SERVER kernel: [ 6814.975249] audit: type=1400 audit(1578528756.476:7): apparmor="DENIED" operation="exec" profile="/usr/syno/sbin/synoscgi//SYNO.VideoStation2.Subtitle" name="/volume1/@appstore/ffmpeg/bin/ffprobe" pid=28017 comm="ffmpeg" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
2020-01-09T01:12:36+01:00 SERVER kernel: [ 6815.007062] audit: type=1400 audit(1578528756.508:8): apparmor="DENIED" operation="exec" profile="/usr/syno/sbin/synoscgi//SYNO.VideoStation2.Subtitle" name="/volume1/@appstore/ffmpeg/bin/ffmpeg" pid=28041 comm="ffmpeg" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
2020-01-09T01:12:36+01:00 SERVER kernel: [ 6815.048095] audit: type=1400 audit(1578528756.549:9): apparmor="DENIED" operation="exec" profile="/usr/syno/sbin/synoscgi//SYNO.VideoStation2.Subtitle" name="/volume1/@appstore/ffmpeg/bin/ffmpeg" pid=28071 comm="ffmpeg" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 9, 2020

@kc6108, @c-b-h,

I'm starting to hate apparmor !!!
For all tests (e.g. Serviio), apparmor can be disabled with the following command:

/usr/syno/etc.defaults/rc.sysv/apparmor.sh stop

Then restarted with the following command:

/usr/syno/etc.defaults/rc.sysv/apparmor.sh start
@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 9, 2020

Tracking of issue related to apparmor for srt here SynoCommunity/spksrc#3847

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 9, 2020

@ChrWinde, @fildar,

Thank you for your feedback
Regarding problems with DS Video, usually it is due to the fact that the NAS sends a passthrough stream that DS Video cannot read.
There are 2 solutions:

  • Use an external player like MX Player or VLC.
  • Enable transcoding and remuxing options and disable passthrough in DS Vidéo config.

Personally I use the second solution, it always works.

If your problems persist, I'm interested in getting a log return. Normally it's quite easy to find the session corresponding to the video launch with the following command:

tail -n 100 /tmp/ffmpeg.log
@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 10, 2020

@ChrWinde, @fildar,

Thank you for your feedback
Regarding problems with DS Video, usually it is due to the fact that the NAS sends a passthrough stream that DS Video cannot read.
There are 2 solutions:

  • Use an external player like MX Player or VLC.
  • Enable transcoding and remuxing options and disable passthrough in DS Vidéo config.

Personally I use the second solution, it always works.

If your problems persist, I'm interested in getting a log return. Normally it's quite easy to find the session corresponding to the video launch with the following command:

tail -n 100 /tmp/ffmpeg.log

Hi and thanks for your reply,

If I remember correctly, passthrough was disabled in the settings. I tried enabling it but it didn't make a difference (I wanted to test if the nVidia Shield was able to play EAC3 audio but it doesn't seem so).
I will have to take another look in the settings to locate the transcoding and remuxing options.
I will make some more tests shortly and get back to you (and try to be more specific)

Another test I just made from VideoStation on Chrome is playing a MKV file with EAC3 audio and (a lot of) subtitles already present in the file.
When I play the video without subtitles at all, it plays fine.
With external .srt subs, it plays fine as well.
With the "embedded" subs it never loads and the NAS CPU and RAM (12Go!) are saturated.

I had a look to the processes running with a ps -eaf and I saw a lot (a lot !) of bash processes launched. Ex :
bin/bash /var/packages/VideoStation/target/bin/ffmpeg.orig -y -timelimit 300 -i /volume1/video/Series/The Mandalorian/Saison 1/The.Mandalorian
I just launched a reboot and am waiting to regain control (I am not at home)...

@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 10, 2020

@fildar,

I uninstalled/re-installed DS Video on my iPhone, and DS Video is now allowing playback of all codecs. Sorry about the misinformation above. I corrected my post.

I don't know why DS Video won't play EAC3 on your Nvidia Shield. I'd take @BenjaminPoncet's advice and provide the logs.

Hi @kc6108,

I will try uninstalling and reinstalling it as you suggested.

Thanks

@DragonSkyMine

This comment has been minimized.

Copy link

@DragonSkyMine DragonSkyMine commented Jan 10, 2020

Synology DS218 / DSM 6.2.2-24922 Update 4 / Video Station 2.4.6-1594 / ffmpeg 4.2.1-19 / ffmpeg wrapper (rev11):
it's working great in the original quality, but when I choose other quality profile, it fail

There the output log:

2020-01-10 09:59:12 - 78jaZsrk - *** PROCESS START ***
2020-01-10 09:59:12 - 78jaZsrk - MOVIE    = /volume1/video/x/x/x/Test.mkv
2020-01-10 09:59:12 - 78jaZsrk - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-10 09:59:12 - 78jaZsrk -          = -ss 672.000 -i //volume1/video/x/x/x/Test.mkv -threads 0 -vcodec copy -vsync 2 -vbsf
2020-01-10 09:59:12 - 78jaZsrk -          = h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3
2020-01-10 09:59:12 - 78jaZsrk -          = u8 -hls_seek_time 672000 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00084 -avoid_negative_ts 0 -bre
2020-01-10 09:59:12 - 78jaZsrk -          = ak_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/b66df7a7f02eb15d0356ad0cdcf8cf68_78jaZsrk/slice-%05d.ts
2020-01-10 09:59:12 - 78jaZsrk - CHILDPID = 12613
2020-01-10 09:59:27 - 78jaZsrk - *** KILLCHILD ***
2020-01-10 09:59:27 - 78jaZsrk - *** CHILD END ***
2020-01-10 09:59:27 - 78jaZsrk - *** PROCESS END ***
2020-01-10 09:59:50 - F4fb9GeN - *** PROCESS START ***
2020-01-10 09:59:50 - F4fb9GeN - MOVIE    = -
2020-01-10 09:59:50 - F4fb9GeN - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-10 09:59:50 - F4fb9GeN -          = -i - -map 0 -codec copy -f segment -segment_time 5 -segment_start_number 0 -hls_seek_time 0 /tmp/VideoStation/HLS/b66df7
2020-01-10 09:59:50 - F4fb9GeN -          = a7f02eb15d0356ad0cdcf8cf68_F4fb9GeN/slice-%05d.ts
2020-01-10 09:59:50 - F4fb9GeN - CHILDPID = 12779
2020-01-10 09:59:50 - F4fb9GeN - STDERR   =
2020-01-10 09:59:50 - F4fb9GeN -          =   libavutil      56. 31.100 / 56. 31.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-10 09:59:50 - F4fb9GeN -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-10 09:59:50 - F4fb9GeN -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-10 09:59:50 - F4fb9GeN -          = pipe:: Invalid data found when processing input
2020-01-10 09:59:50 - F4fb9GeN - *** CHILD END ***
2020-01-10 09:59:50 - F4fb9GeN - *** PROCESS END ***

78jaZsrk is when it work (original quality) and F4fb9GeN is when it fail (other profile)

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 10, 2020

@DragonSkyMine,

Thanks for your feedback.
Really strange logs!
It looks like ffmpeg doesn't transcode the stream directly but uses the stream from another software.

Could you uninstall the wrapper (see installation instructions), run the same test again and execute the following command:

ps afx | grep VideoStation
@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 10, 2020

Damn !
Now, each time I play a MKV with EAC3 audio and a lot of subtitles from DSVideo on my Android phone (MXPlayer), I have an infinity of bash processes that launches and I must restart the NAS to kill them... (I don't know how to proceed otherwise).

And I made a mistake during the installation and called the ffmpeg save command twice... So I lost my original file... (and of course I didn't save it elsewhere...). So I can't uninsta
Does someone know where I can find the original ffmpeg file please ?

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 10, 2020

@fildar,

The safest way for you is to uninstall and re-install VideoStation.
When uninstalling, VideoStation allows you to keep the database, so you won't lose anything.

Edit

And for the subtitle problem, indeed, if you executed the installation commands twice, the ffmpeg.orig should no longer be the original VideoStation ffmpeg but the wrapper.
So, when extracting subtitles, the script must run the loop...
Makes a clean installation and everything should work fine.
I'll see how I can avoid that

Edit 2

Currently the SynCommunity ffmpeg cannot extract subtitles so the wrapper uses ffmpeg.orig (see: SynoCommunity/spksrc#3847).

@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 10, 2020

Thanks for the explanation about the subtitles, it seems clearer now !
I reinstalled VideoStation (saw you recommanded it as an uninstallation method after posting) and will make tests

Edit : Thanks again, reinstalling VideoStation + wrapper did the trick.

@DragonSkyMine

This comment has been minimized.

Copy link

@DragonSkyMine DragonSkyMine commented Jan 10, 2020

@DragonSkyMine,

Thanks for your feedback.
Really strange logs!
It looks like ffmpeg doesn't transcode the stream directly but uses the stream from another software.

Could you uninstall the wrapper (see installation instructions), run the same test again and execute the following command:

ps afx | grep VideoStation

Thanks for your reply. this is the output of the command:

0:00  \_ synoscgi_SYNO.VideoStation2.Streaming_1_stream
 7125 ?        D<     0:00      \_ /var/packages/VideoStation/target/bin/syno-gst -s 0 -i /volume1/VideoStation/xx/xxx.mkv -f mpegts --width 1280 --height 720 --vb 1000000 --acodec mp3 -o fd:1 --aidx 0
 7126 ?        S<     0:00      \_ /var/packages/VideoStation/target/bin/ffmpeg -i - -map 0 -codec copy -f segment -segment_time 5 -segment_start_number 0 -hls_seek_time 0 /tmp/VideoStation/HLS/ce275f98e868429d3369b964f2ed0777_iwWi8Mhv/slice-%05d.ts
 7123 ?        S      0:00 synoscgi_SYNO.Core.System.Utilization_1_get
@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 10, 2020

Sorry for late response @kc6108, holiday's over and work and family life calls.
I tried out synogear install and got

Failed to install DiagnosisTool ... synopkg error code: 1
no temp profile folder found! exit. dir path: /var/packages/DiagnosisTool/etc/

Disabling apparmor per @BenjaminPoncet's instructions resulted in the following output:

2020-01-10 20:35:37 - HhCpvTjE - *** PROCESS START ***
2020-01-10 20:35:37 - HhCpvTjE - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-10 20:35:37 - HhCpvTjE - FFMPEG   = /volume1/@appstore/Serviio/bin/ffmpeg
2020-01-10 20:35:37 - HhCpvTjE -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-10 20:35:37 - HhCpvTjE -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-10 20:35:37 - HhCpvTjE -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-10 20:35:37 - HhCpvTjE -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-10 20:35:37 - HhCpvTjE -          = e29dbe1c9462a376c4_HhCpvTjE/slice-%05d.ts
2020-01-10 20:35:37 - HhCpvTjE - CHILDPID = 25457
2020-01-10 20:35:37 - HhCpvTjE - STDERR   =
2020-01-10 20:35:37 - HhCpvTjE -          =   libavutil      54. 27.100 / 54. 27.100
2020-01-10 20:35:37 - HhCpvTjE -          =   libavcodec     56. 41.100 / 56. 41.100
2020-01-10 20:35:37 - HhCpvTjE -          =   libavformat    56. 36.100 / 56. 36.100
2020-01-10 20:35:37 - HhCpvTjE -          =   libavdevice    56.  4.100 / 56.  4.100
2020-01-10 20:35:37 - HhCpvTjE -          =   libavfilter     5. 16.101 /  5. 16.101
2020-01-10 20:35:37 - HhCpvTjE -          =   libswscale      3.  1.101 /  3.  1.101
2020-01-10 20:35:37 - HhCpvTjE -          =   libswresample   1.  2.100 /  1.  2.100
2020-01-10 20:35:37 - HhCpvTjE -          =   libpostproc    53.  3.100 / 53.  3.100
2020-01-10 20:35:37 - HhCpvTjE -          = Unrecognized option 'hls_seek_time'.
2020-01-10 20:35:37 - HhCpvTjE -          = Error splitting the argument list: Option not found
2020-01-10 20:35:37 - HhCpvTjE - *** CHILD END ***
2020-01-10 20:35:37 - HhCpvTjE - *** PROCESS END ***

Trying again after updating to Serviio 2.0 via Package Center results in:

2020-01-10 20:47:47 - DgSuUZys - *** PROCESS START ***
2020-01-10 20:47:47 - DgSuUZys - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-10 20:47:47 - DgSuUZys - FFMPEG   = /volume1/@appstore/Serviio/bin/ffmpeg
2020-01-10 20:47:47 - DgSuUZys -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-10 20:47:47 - DgSuUZys -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-10 20:47:47 - DgSuUZys -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-10 20:47:47 - DgSuUZys -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-10 20:47:47 - DgSuUZys -          = e29dbe1c9462a376c4_DgSuUZys/slice-%05d.ts
2020-01-10 20:47:47 - DgSuUZys - CHILDPID = 9418
2020-01-10 20:47:47 - DgSuUZys - STDERR   =
2020-01-10 20:47:47 - DgSuUZys -          =   libavutil      54. 27.100 / 54. 27.100
2020-01-10 20:47:47 - DgSuUZys -          =   libavcodec     56. 41.100 / 56. 41.100
2020-01-10 20:47:47 - DgSuUZys -          =   libavformat    56. 36.100 / 56. 36.100
2020-01-10 20:47:47 - DgSuUZys -          =   libavdevice    56.  4.100 / 56.  4.100
2020-01-10 20:47:47 - DgSuUZys -          =   libavfilter     5. 16.101 /  5. 16.101
2020-01-10 20:47:47 - DgSuUZys -          =   libswscale      3.  1.101 /  3.  1.101
2020-01-10 20:47:47 - DgSuUZys -          =   libswresample   1.  2.100 /  1.  2.100
2020-01-10 20:47:47 - DgSuUZys -          =   libpostproc    53.  3.100 / 53.  3.100
2020-01-10 20:47:47 - DgSuUZys -          = Unrecognized option 'hls_seek_time'.
2020-01-10 20:47:47 - DgSuUZys -          = Error splitting the argument list: Option not found
2020-01-10 20:47:47 - DgSuUZys - *** CHILD END ***
2020-01-10 20:47:47 - DgSuUZys - *** PROCESS END ***
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 11, 2020

@DragonSkyMine,
Thanks for your feedback.
Really strange logs!
It looks like ffmpeg doesn't transcode the stream directly but uses the stream from another software.
Could you uninstall the wrapper (see installation instructions), run the same test again and execute the following command:

ps afx | grep VideoStation

Thanks for your reply. this is the output of the command:

0:00  \_ synoscgi_SYNO.VideoStation2.Streaming_1_stream
 7125 ?        D<     0:00      \_ /var/packages/VideoStation/target/bin/syno-gst -s 0 -i /volume1/VideoStation/xx/xxx.mkv -f mpegts --width 1280 --height 720 --vb 1000000 --acodec mp3 -o fd:1 --aidx 0
 7126 ?        S<     0:00      \_ /var/packages/VideoStation/target/bin/ffmpeg -i - -map 0 -codec copy -f segment -segment_time 5 -segment_start_number 0 -hls_seek_time 0 /tmp/VideoStation/HLS/ce275f98e868429d3369b964f2ed0777_iwWi8Mhv/slice-%05d.ts
 7123 ?        S      0:00 synoscgi_SYNO.Core.System.Utilization_1_get

Oh my god !

VideoStation uses gstreamer for arch arm! And as usual, a modified version...
After the ffmpeg wrapper, are we good to create a gstreamer wrapper ?
I'm tired...

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 11, 2020

@c-b-h

Welcome back!

Good news and bad news:
It was a problem with the apparmor but obviously Serviio's ffmpeg does not support hls_seek_time.
This setting is a specific Synology evolution used by VideoStation to move forward in the video.
So unfortunately, the Serviio solution is a bit compromised. We can remove this setting with the wrapper but it limits VideoStation too much.

Can you execute the following command, it will tell us the version of ffmpeg and if version 2.0 has the SMD:

/volume1/@appstore/Serviio/bin/ffmpeg
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 11, 2020

@fildar

I just updated the installation instructions to prevent your loop problem.
Thanks for being the first to experiment this bad bug. 😉

@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 11, 2020

@BenjaminPoncet
Nice way to put the fact that you made it "noob proof" ;)
Sorry about that ^^

I took time to make tests and everything is working fine !
The only problem remaining is on the Nvidia Shield with DS Video : I have no sound with EAC3 videos...
It works fine with the same videos on DS Video on my Mi Box.

I tried with or without AC3 passthrough => NOK
I tried uninstalling / reinstalling DS Video => NOK
But it works if I use an external player (MxPlayer) as I added the proper codecs in it.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 11, 2020

@fildar

Almost perfect!
Have you tried with and without the video transcoding option? On DS Video IOS there is also a Remuxe Audio option but I think it doesn't exist yet on Android.

Otherwise, if you can paste me the logs from that test:

I tried with or without AC3 passthrough => NOK

I'd like to see if VideoStation transmits different parameters with the EAC3.

@ANTO76700

This comment has been minimized.

Copy link

@ANTO76700 ANTO76700 commented Jan 11, 2020

@BenjaminPoncet

I have an issue.
I followed the instructions for the installation.
I have the good versions of FFmpeg and Video Station, but when i paste the commands i get this :

root@DiskStation:~# # Save VideoStation's ffmpeg
root@DiskStation:~# mv -n /var/packages/VideoStation/target/bin/ffmpeg /var/packages/VideoStation/targ                                et/bin/ffmpeg.orig
root@DiskStation:~# # Injecting the script (last revision aka 11)
root@DiskStation:~# wget -O - https://gist.githubusercontent.com/BenjaminPoncet/bbef9edc1d0800528813e7                                5c1669e57e/raw/ffmpeg-wrapper > /var/packages/VideoStation/target/bin/ffmpeg
--2020-01-11 16:09:17--  https://gist.githubusercontent.com/BenjaminPoncet/bbef9edc1d0800528813e75c166                                9e57e/raw/ffmpeg-wrapper
Resolving gist.githubusercontent.com... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to gist.githubusercontent.com|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2273 (2.2K) [text/plain]
Saving to: 'STDOUT'

-                         100%[===================================>]   2.22K  --.-KB/s    in 0s

2020-01-11 16:09:17 (10.8 MB/s) - written to stdout [2273/2273]

root@DiskStation:~# # Change ownership and mode of the script
root@DiskStation:~# chown root:VideoStation /var/packages/VideoStation/target/bin/ffmpeg
root@DiskStation:~# chmod 750 /var/packages/VideoStation/target/bin/ffmpeg
root@DiskStation:~# chmod u+s /var/packages/VideoStation/target/bin/ffmpeg
root@DiskStation:~# # Save VideoStation's libsynovte.so
root@DiskStation:~# mv -n /var/packages/VideoStation/target/lib/libsynovte.so /var/packages/VideoStati                                on/target/lib/libsynovte.so.orig
mv: cannot stat ‘/var/packages/VideoStation/target/lib/libsynovte.so’: No such file or directory
root@DiskStation:~# # Patch libsynovte.so to authorize DTS, EAC3 and TrueHD
root@DiskStation:~# sed -i -e 's/eac3/3cae/' -e 's/dts/std/' -e 's/truehd/dheurt/' /var/packages/VideoStation/target/lib/libsynovte.sosed: can't read /var/packages/VideoStation/target/lib/libsynovte.so: No such file or directory
root@DiskStation:~#

And i can't launch Video Station anymore...
What's wrong ?

PS : I have a DS218play, i chose ffmpeg_aarch64-6.1_4.2.1-19.spk

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 11, 2020

@ANTO76700

I changed the installation commands today but I made a mistake. It is now corrected.
You can execute the uninstall commands.
And re-run the new installation commands.
If VideoStation still doesn't launch, you can also uninstall it in the package center and re-install it. VideoStation allows you to keep the database so you won't lose anything.

However, it doesn't look like everything will work on your DS218play (see: https://gist.github.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e#gistcomment-3133567)
We don't have a solution to this problem yet.

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 11, 2020

@BenjaminPoncet

Running /volume1/@appstore/Serviio/bin/ffmpeg yields:

ffmpeg version 2.7.1-SMD_enabled-compiled_by_patters_for_Serviio Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
  configuration: --arch=x86 --cpu=atom --enable-cross-compile --cross-prefix=/usr/local/evansport-pc-linux-gnu/bin/i686-pc-linux-gnu- --target-os=linux --prefix=/usr/local/evansport-pc-linux-gnu --enable-shared --disable-static --enable-pic --disable-ffplay --disable-ffserver --disable-debug --enable-pthreads --enable-libmp3lame --enable-librtmp --enable-libass --enable-libspeex --enable-libvorbis --enable-libx264 --enable-libh264_smd --enable-smd --enable-gpl --enable-gnutls --pkg-config=pkg-config --extra-version=SMD_enabled-compiled_by_patters_for_Serviio
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Note that Serviio specifically prompts for the version to install and I have assumed SMD is what I should be aiming for. I have not tried the 3.2.2 version yet.
Screenshot 2020-01-11 at 21 45 40

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 12, 2020

@c-b-h

I may have some very good news for you!
I just finished a new script concept.

The idea is to use VideoStation ffmpeg for video and SynCommunity ffmpeg for audio via PIPE protocol.

This allows to have all the hardware optimizations of Synology (so SMD) with DTS, TrueHD, EAC3 from SynCommunity. In short, the best of both worlds.

I've been testing this new script for 2 hours and it works pretty well.

If you're interested, here's how to proceed:

  • First of all, I advise you to start from a clean install of VideoStation (Uninstall / Install). VideoStation allows you to keep the base so it's safe.
  • Then, install the classic wrapper by following the installation instructions.
  • Finally, execute the following command to get the PIPE version:
wget -O - https://gist.githubusercontent.com/BenjaminPoncet/46bf16481d1ae89732ba713a028d5ebb/raw/ffmpeg-wrapper-pipe > /var/packages/VideoStation/target/bin/ffmpeg
@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 12, 2020

Hi,
Using the custom ffmpeg only for audio is a pretty impressive idea 🔥🔥🔥
I installed it on my DS718+ and it seems to do what it shall (although the audio conversion still peaks to 100% of a core about half the time). The only thing I recognized: offline transcoding does not update the status in the web interface. It just shows -1: -1: -1 and 0%.

Out of curiosity: Is there a reason why you first use the VideoStation's ffmpeg and then the custom one in your pipe? (I would first have fixed the audio and then piped it through the VideoStation's ffmpeg)

Thanks for all your efforts.

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 12, 2020

Thank you @BenjaminPoncet for your dedication.

Unfortunately though, something seems to occur when switching down the quality and forcing transcoding (as seen in 6fYtHO7y)

2020-01-12 20:35:46 - 3UcBdiqu - *** PROCESS START ***
2020-01-12 20:35:46 - 3UcBdiqu - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-12 20:35:46 - 3UcBdiqu - CODEC    = h264
2020-01-12 20:35:46 - 3UcBdiqu - FFMPEG1  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-12 20:35:46 - 3UcBdiqu - FFMPEG2  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-12 20:35:46 - 3UcBdiqu - PARAMVS  =
2020-01-12 20:35:47 - 3UcBdiqu -          = -ss 0.000 -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv -threads 
2020-01-12 20:35:47 - 3UcBdiqu -          = 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_forma
2020-01-12 20:35:47 - 3UcBdiqu -          = t mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 
2020-01-12 20:35:47 - 3UcBdiqu -          = -avoid_negative_ts 0 -break_non_keyframes 0 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_3Uc
2020-01-12 20:35:47 - 3UcBdiqu -          = Bdiqu/slice-%05d.ts
2020-01-12 20:35:47 - 3UcBdiqu - PARAM1   =
2020-01-12 20:35:47 - 3UcBdiqu -          = -ss 0.000 -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv -threads 
2020-01-12 20:35:47 - 3UcBdiqu -          = 0 -vcodec copy -vsync 2 -vbsf h264_mp4toannexb=repeatheader -acodec copy -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-12 20:35:47 - 3UcBdiqu - PARAM2   =
2020-01-12 20:35:47 - 3UcBdiqu -          = -i pipe:0 -map 0 -vcodec copy -acodec libmp3lame -ab 256k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3
2020-01-12 20:35:47 - 3UcBdiqu -          = u8 -hls_seek_time 0 -segment_time 8 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_no
2020-01-12 20:35:47 - 3UcBdiqu -          = n_keyframes 0 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_3UcBdiqu/slice-%05d.ts
2020-01-12 20:35:47 - 3UcBdiqu - CHILDPID = 15054
2020-01-12 20:36:10 - 3UcBdiqu - *** KILLCHILD ***
2020-01-12 20:36:10 - 3UcBdiqu - *** CHILD END ***
2020-01-12 20:36:10 - 3UcBdiqu - *** PROCESS END ***
2020-01-12 20:36:16 - 6fYtHO7y - *** PROCESS START ***
2020-01-12 20:36:16 - 6fYtHO7y - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-12 20:36:16 - 6fYtHO7y - CODEC    = h264
2020-01-12 20:36:16 - 6fYtHO7y - FFMPEG1  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-12 20:36:16 - 6fYtHO7y - FFMPEG2  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-12 20:36:16 - 6fYtHO7y - PARAMVS  =
2020-01-12 20:36:16 - 6fYtHO7y -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-12 20:36:16 - 6fYtHO7y -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-12 20:36:16 - 6fYtHO7y -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-12 20:36:16 - 6fYtHO7y -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-12 20:36:16 - 6fYtHO7y -          = e29dbe1c9462a376c4_6fYtHO7y/slice-%05d.ts
2020-01-12 20:36:16 - 6fYtHO7y - PARAM1   =
2020-01-12 20:36:16 - 6fYtHO7y -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-12 20:36:16 - 6fYtHO7y -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec copy -f mpegts -map 0:0 -map 
2020-01-12 20:36:16 - 6fYtHO7y -          = 0:1 pipe:1
2020-01-12 20:36:16 - 6fYtHO7y - PARAM2   =
2020-01-12 20:36:16 - 6fYtHO7y -          = -i pipe:0 -map 0 -vcodec copy -acodec libmp3lame -ab 96k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u
2020-01-12 20:36:16 - 6fYtHO7y -          = 8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -avoid_negative_ts 0 -break_non
2020-01-12 20:36:16 - 6fYtHO7y -          = _keyframes 1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_6fYtHO7y/slice-%05d.ts
2020-01-12 20:36:16 - 6fYtHO7y - CHILDPID = 15355
2020-01-12 20:36:16 - 6fYtHO7y - STDERR   =
2020-01-12 20:36:16 - 6fYtHO7y -          = ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
2020-01-12 20:36:16 - 6fYtHO7y -          =   built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
2020-01-12 20:36:16 - 6fYtHO7y -          =   configuration: --target-os=linux --cross-prefix=/home/th0ma7/git-ffmpeg-QS-master/spksrc/toolchains/syno-evansport-6.1
2020-01-12 20:36:16 - 6fYtHO7y -          = /work/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --prefix=/var/packages/ffmpeg/target --extra-cflags=-I/home/th0ma7/git-ff
2020-01-12 20:36:16 - 6fYtHO7y -          = mpeg-QS-master/spksrc/spk/ffmpeg/work-evansport-6.1/install/var/packages/ffmpeg/target/include --extra-ldflags=-L/home/t
2020-01-12 20:36:16 - 6fYtHO7y -          = h0ma7/git-ffmpeg-QS-master/spksrc/spk/ffmpeg/work-evansport-6.1/install/var/packages/ffmpeg/target/lib --extra-libs='-lx
2020-01-12 20:36:16 - 6fYtHO7y -          = ml2 -ldl' --pkg-config=/usr/bin/pkg-config --ranlib=/home/th0ma7/git-ffmpeg-QS-master/spksrc/toolchains/syno-evansport-6
2020-01-12 20:36:16 - 6fYtHO7y -          = .1/work/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ranlib --enable-cross-compile --enable-rpath --enable-pic --enable-share
2020-01-12 20:36:16 - 6fYtHO7y -          = d --enable-gpl --enable-fontconfig --enable-libass --enable-libbluray --enable-avresample --enable-libfreetype --enable-
2020-01-12 20:36:16 - 6fYtHO7y -          = libfribidi --enable-libmp3lame --enable-libopus --enable-libsoxr --enable-libvorbis --enable-libvpx --enable-libx264 --e
2020-01-12 20:36:16 - 6fYtHO7y -          = nable-libx265 --enable-gnutls --disable-debug --disable-doc --disable-static --enable-libfdk-aac --enable-nonfree --extr
2020-01-12 20:36:16 - 6fYtHO7y -          = a-cflags='-DSYNO_VIDEOSTATION -DSYNO_AUDIOSTATION -DSYNO_MEDIASERVER -DSYNO_DSM' --extra-cflags=-fno-if-conversion --ena
2020-01-12 20:36:16 - 6fYtHO7y -          = ble-libaom --arch=x86 --cpu=atom --enable-vaapi
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavutil      56. 31.100 / 56. 31.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-12 20:36:16 - 6fYtHO7y -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-12 20:36:16 - 6fYtHO7y -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-12 20:36:16 - 6fYtHO7y -          = pipe:0: Invalid data found when processing input
2020-01-12 20:36:16 - 6fYtHO7y - *** CHILD END ***
2020-01-12 20:36:16 - 6fYtHO7y - *** PROCESS END ***
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 12, 2020

@richterd

Hi,
Using the custom ffmpeg only for audio is a pretty impressive idea 🔥🔥🔥

Thank you. I know I'm a genius. 🤓

I installed it on my DS718+ and it seems to do what it shall (although the audio conversion still peaks to 100% of a core about half the time). The only thing I recognized: offline transcoding does not update the status in the web interface. It just shows -1: -1: -1 and 0%.

I noticed the same thing with the offline transcoding, but it's working fine.
For the CPU load, don't you have the same load without the wrapper? I haven't noticed any noticeable change...

Out of curiosity: Is there a reason why you first use the VideoStation's ffmpeg and then the custom one in your pipe? (I would first have fixed the audio and then piped it through the VideoStation's ffmpeg)

Any reason? Yes! The idea just popped into my head and I coded it straight out during a nerd night. 😅
But you're absolutely right! I thought about it today, it would be easier to decode the audio first (only 3 parameters to catch) and maybe it would work better.
And I think the wrapper could work with the official SynoCommunity ffmpeg version that doesn't support the -hls_seek_time parameter.

Thanks for all your efforts.

BTW, I've got a much better wrapper for you (I've got a DS718+ too): stay tuned

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 12, 2020

@c-b-h

I'll re-code the wrapper as suggested by @richterd. It might work better for you.
I'm sure we're close.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 13, 2020

@c-b-h

Can you start a manual conversion with the following command:

/var/packages/VideoStation/target/bin/ffmpeg.orig -ss 0.000 -prefer_smd -i "/volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv" -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec copy -f mpegts -map 0:0 -map 0:1 test.ts

I'd just like to make sure the ffmpeg.orig doesn't generate an error.
With this wapper, we can' t see the error returns of the first execution.

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 13, 2020

/var/packages/VideoStation/target/bin/ffmpeg.orig -ss 0.000 -prefer_smd -i "/volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv" -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec copy -f mpegts -map 0:0 -map 0:1 test.ts
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
  configuration: --prefix=/usr/pkg --incdir='${prefix}/include/ffmpeg' --arch=i686 --target-os=linux --cross-prefix=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --enable-cross-compile --enable-optimizations --enable-pic --enable-gpl --enable-version3 --enable-nonfree --enable-libfaac --enable-encoders --enable-pthreads --disable-muxer=image2 --disable-muxer=image2pipe --disable-swscale-alpha --disable-ffplay --disable-ffserver --disable-doc --disable-devices --disable-bzlib --disable-altivec --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --disable-decoder=amrnb --disable-encoder=zmbv --disable-encoder=dca --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-decoder=eac3 --disable-encoder=truehd --disable-decoder=truehd --cc=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ccache-gcc --enable-shared --disable-static --enable-yasm --enable-libx264 --enable-encoder=libx264 --enable-libh264_smd --enable-smd --disable-filter=hqdn3d --extra-libs='-ljson-c -lgdl -losal -lpal -lsven -lismd_core -lismd_audio -lismd_viddec -lismd_videnc -lismd_vidpproc -lplatform_config -lffmpeg_plugin'
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '/volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.1
    creation_time   : 2016-06-25 04:17:04
  Duration: 01:18:35.78, start: 0.000000, bitrate: 2374 kb/s
    Stream #0:0: Video: h264_smd (High), yuv420p(tv, bt709/unknown/unknown), 1280x720, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
[h264_smd @ 0x82bbe60] using SAR=464/477
[h264_smd @ 0x82bbe60] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[h264_smd @ 0x82bbe60] profile Main, level 3.0

*********Using Hardware H.264 Encoder **************
[h264_smd @ 0x82ba340] 
******************Using H.264 Hardware video decoder**************
Output #0, mpegts, to 'test.ts':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: h264 (h264_smd), yuv420p, 848x464 [SAR 464:477 DAR 16:9], q=-1--1, 500 kb/s, 23.98 fps, 90k tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 h264_smd
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), 384 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264_smd (native) -> h264 (h264_smd))
  Stream #0:1 -> #0:1 (copy)
****** Using SMD H/W H.264 Decoder and H/W H.264 Encoder(Pipelined Mode)*******
Press [q] to stop, [?] for help
frame= 1298 fps=196 q=0.0 Lsize=    7802kB time=00:00:54.27 bitrate=1177.7kbits/s dup=0 drop=1296    
video:4350kB audio:2544kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 13.171711%
[h264_smd @ 0x82bbe60] final ratefactor: 30.32
@0SkillAllLuck

This comment has been minimized.

Copy link

@0SkillAllLuck 0SkillAllLuck commented Jan 13, 2020

pipe wrapper tested on DS 918+ / ffmpeg_x64-6.1_4.2.1-22.spk.
Havent noticed any abnormal behaviour and works with every Movie I tested.
Thank you for your great work and making 4K Movies on my DiskStation a thing.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 13, 2020

@c-b-h,

The new version of the wrapper (pipe) is out!

I think Synology's ffmpeg SMD may not support PIPE in output.
So by reversing the execution I'm pretty sure (well I hope) it will work for you.

The second thing is that by running Synology's ffmpeg last, the first one doesn't need hls_seek_time support anymore so the official SynoCommunity ffmpeg version (v4.1) works too.

To install it:

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/46bf16481d1ae89732ba713a028d5ebb/raw/ffmpeg-wrapper-pipe > /var/packages/VideoStation/target/bin/ffmpeg
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 13, 2020

@QuByte-Zer0

Thanks for your feedback.

On the other hand, the DS918+ is on an arch apollolake, so I'll rather recommend the classic version (rev11) of the wrapper and even another special version that I plan to propose very soon !!

Stay tuned!

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 13, 2020

Hi, everybody,

After a hard work you can relive here: SynoCommunity/spksrc#3842 @th0ma7 managed to add Intel Quick Sync support to the SynoCommunity ffmpeg (-22).

And so, for the occasion, I couldn't resist to code a special wrapper to replace VAAPI (used by VideoStation) by Quick Sync
In two words, Quick Sync is a slight gain in image quality with a real gain in GPU performance (+15/20%).
More info here: https://trac.ffmpeg.org/wiki/Hardware/QuickSync

This wrapper is only for the x64 arch (Broadwell, Braswell, Apollo Lake).

To install it (Warning this wrapper depends on the version -22 or higher of ffmpeg)

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/4f7b635e993a8de1105a3f3bc361dea7/raw/ffmpeg-wrapper-qsv > /var/packages/VideoStation/target/bin/ffmpeg

Some more info here: SynoCommunity/spksrc#3842 (comment)

As usual, all your feedback are welcome.

PS: All these special versions of the wrapper are intended to integrate the next version of the main wrapper in the form of options
PS2: Next job: armv8 support

cc @QuByte-Zer0, @richterd, @fildar, @intothevoid, @felix-m-p, @Denton22

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 13, 2020

@BenjaminPoncet
Keep up the good work 👍

Here is what I got using the latest version of ffmpeg-wrapper-pipe. Is the video being passed to the correct decoder?

2020-01-14 00:04:59 - HcJeUyqo - *** PROCESS START ***
2020-01-14 00:04:59 - HcJeUyqo - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-14 00:04:59 - HcJeUyqo - CODEC    = h264
2020-01-14 00:04:59 - HcJeUyqo - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-14 00:04:59 - HcJeUyqo - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-14 00:04:59 - HcJeUyqo - PARAMVS  =
2020-01-14 00:04:59 - HcJeUyqo -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-14 00:04:59 - HcJeUyqo -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-14 00:04:59 - HcJeUyqo -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-14 00:04:59 - HcJeUyqo -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-14 00:04:59 - HcJeUyqo -          = e29dbe1c9462a376c4_HcJeUyqo/slice-%05d.ts
2020-01-14 00:04:59 - HcJeUyqo - PARAM1   =
2020-01-14 00:04:59 - HcJeUyqo -          = -ss 0.000 -noaccurate_seek -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-14 00:04:59 - HcJeUyqo -          = -vcodec copy -acodec libmp3lame -ab 96k -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-14 00:04:59 - HcJeUyqo - PARAM2   =
2020-01-14 00:04:59 - HcJeUyqo -          = -prefer_smd -i pipe:0 -map 0 -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec cop
2020-01-14 00:04:59 - HcJeUyqo -          = y -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 
2020-01-14 00:04:59 - HcJeUyqo -          = -segment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462
2020-01-14 00:04:59 - HcJeUyqo -          = a376c4_HcJeUyqo/slice-%05d.ts
2020-01-14 00:04:59 - HcJeUyqo - CHILDPID = 24574
2020-01-14 00:05:01 - HcJeUyqo - STDERR   =
2020-01-14 00:05:01 - HcJeUyqo -          =     Stream #0:0[0x100]: Video: h264_smd (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709/unknown/unknown), 1280x720, 2
2020-01-14 00:05:01 - HcJeUyqo -          = 3.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
2020-01-14 00:05:01 - HcJeUyqo -          =     Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 96 kb/s
2020-01-14 00:05:01 - HcJeUyqo -          = [h264_smd @ 0x87f0a60] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
2020-01-14 00:05:01 - HcJeUyqo -          = [h264_smd @ 0x87f0a60] profile Main, level 3.0
2020-01-14 00:05:01 - HcJeUyqo -          = Hardware transcoding is busy!!
2020-01-14 00:05:01 - HcJeUyqo -          = [h264_smd @ 0x87f0a60] Syno check hardware transcode falied
2020-01-14 00:05:01 - HcJeUyqo -          = Output #0, stream_segment,ssegment, to '/tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_HcJeUyqo/slice-%05d.ts':
2020-01-14 00:05:01 - HcJeUyqo -          =     Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 23.98 fps
2020-01-14 00:05:01 - HcJeUyqo -          =     Metadata:
2020-01-14 00:05:01 - HcJeUyqo -          =       encoder         : Lavc56.41.100 h264_smd
2020-01-14 00:05:01 - HcJeUyqo -          =     Stream #0:1: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 96 kb/s
2020-01-14 00:05:01 - HcJeUyqo -          = Stream mapping:
2020-01-14 00:05:01 - HcJeUyqo -          =   Stream #0:0 -> #0:0 (h264_smd (native) -> h264 (h264_smd))
2020-01-14 00:05:01 - HcJeUyqo -          =   Stream #0:1 -> #0:1 (copy)
2020-01-14 00:05:01 - HcJeUyqo -          = Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2020-01-14 00:05:01 - HcJeUyqo - *** CHILD END ***
2020-01-14 00:05:01 - HcJeUyqo - *** PROCESS END ***
@0SkillAllLuck

This comment has been minimized.

Copy link

@0SkillAllLuck 0SkillAllLuck commented Jan 13, 2020

Quickly tested the QuickSync Version on my DS918+ seems to be working fine. 4K, 1080P with different Codecs. So nice work. Keep it up

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 14, 2020

@BenjaminPoncet you are a beast! wow, keep up the amazing work!

Now I'll try to take some mileage from there, currently working on porting _smd to ffmpeg 4.2.1...
This question is intended to people who own a NAS which needs this extension (e.g. arch evansport):

  1. Do you have a directory named /usr/local/evansport-pc-linux-gnu
  2. Somewhere on your nas do you have a directory called intelce-utilities, if so what is the full path?

I need this in order to pre-assume share library path and adjust the -rpath-link at linking time post-build (if I ever reach that point).

Thnx in advance!

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 14, 2020

@th0ma7
I didn't find /usr/local/evansport-pc-linux-gnu but the path to intelce-utilities on my device is /usr/syno/intelce-utilities.

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 14, 2020

Thnx @c-b-h
Would you mind also providing me with the listing of the .so files in there as well as the kernel and DSM versions of your NAS?

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 14, 2020

@c-b-h

Keep up the good work 👍

Here is what I got using the latest version of ffmpeg-wrapper-pipe. Is the video being passed to the correct decoder?

Thanks, but I'm so frustrated that it's not working out for you !
Yes, all goes as expected.
2 interesting lines:

2020-01-14 00:05:01 - HcJeUyqo -          = Hardware transcoding is busy!!
2020-01-14 00:05:01 - HcJeUyqo -          = [h264_smd @ 0x87f0a60] Syno check hardware transcode falied

Could you try two new things:

  • The same test by turning off apparmor.
  • The same test using the official SynoCommunity ffmpeg v4.1-11
  • Can you send me the result of the ls -al /var/packages/VideoStation/target/bin/ command?

On my side make some modifications to the wrapper to highlight some points that can help explain these error messages.

It's progressing!

Anyway thank you very much for your contribution, we're working a little blind.

@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 15, 2020

The new version of the wrapper (pipe) is out!

I think Synology's ffmpeg SMD may not support PIPE in output.
So by reversing the execution I'm pretty sure (well I hope) it will work for you.

Cool, now offline transcoding also shows the right progress 👍

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 15, 2020

@kc6108
Can't really tell but by the look of the code I'm not too surprised neither.
Synology code really isn't optimal to say the least, it's actually really hack'ish...
Latest patchset available here:
https://github.com/th0ma7/spksrc/commits/ffmpeg-evansport

I'm still fighting at getting it to fully compile and hit new roadblocks everyday.
Once I'm done (if I get there) I fear someone with higher C skills may need to have a second look at the code...

Perhaps from there ffmpeg coders could be interested at reimplementing the functionally right this time based from syno's work?

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 16, 2020

@kc6108

What I'd like to see happen is Synology allowing the SynoCommunity ffmpeg to be side-loaded again.

Indeed I really hope side-loading is re-enabled. But as it stands the default version of ffmpeg is so old that calls are not compatibile with v4.x and must be adapted (thnx to Benjamin's work).

BTW, I got it to compile. I've been fixing up build issue to migrate the code to the v4 API of ffmpeg. My hope is to be able to complete porting of the raw code so it compile entirely. Once that's done (if ever) the next thing is to split the patches into subsets to have smaller and leaner patches for each sub-functionalities. Then my hope is to reach out to ffmpeg dev and ask them if they "some" or "all" of the identified functionalities can be brought upstream..

So still a long road ahead as this takes a lot of time...

@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 17, 2020

@th0ma7

Thnx @c-b-h
Would you mind also providing me with the listing of the .so files in there as well as the kernel and DSM versions of your NAS?

find /usr/syno/intelce-utilities -iname *.so returns nothing but perhaps you are referring to .so-files in another folder?

…as well as the kernel and DSM versions of your NAS?

Linux My-DSM 3.2.40 #24922 SMP PREEMPT Mon Aug 19 12:08:52 CST 2019 i686 GNU/Linux synology_evansport_214play
DSM 6.2.2-24922 Update 4

@BenjaminPoncet

  • The same test by turning off apparmor.
2020-01-17 22:21:33 - X7ypyrL3 - *** PROCESS START ***
2020-01-17 22:21:33 - X7ypyrL3 - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-17 22:21:33 - X7ypyrL3 - CODEC    = h264
2020-01-17 22:21:33 - X7ypyrL3 - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-17 22:21:33 - X7ypyrL3 - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-17 22:21:33 - X7ypyrL3 - PARAMVS  =
2020-01-17 22:21:33 - X7ypyrL3 -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-17 22:21:33 - X7ypyrL3 -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-17 22:21:33 - X7ypyrL3 -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-17 22:21:33 - X7ypyrL3 -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-17 22:21:33 - X7ypyrL3 -          = e29dbe1c9462a376c4_X7ypyrL3/slice-%05d.ts
2020-01-17 22:21:33 - X7ypyrL3 - PARAM1   =
2020-01-17 22:21:33 - X7ypyrL3 -          = -ss 0.000 -noaccurate_seek -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264
2020-01-17 22:21:33 - X7ypyrL3 -          = .mkv -vcodec copy -acodec libmp3lame -ab 96k -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-17 22:21:33 - X7ypyrL3 - PARAM2   =
2020-01-17 22:21:33 - X7ypyrL3 -          = -prefer_smd -i pipe:0 -map 0 -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec cop
2020-01-17 22:21:33 - X7ypyrL3 -          = y -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 
2020-01-17 22:21:33 - X7ypyrL3 -          = -segment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462
2020-01-17 22:21:33 - X7ypyrL3 -          = a376c4_X7ypyrL3/slice-%05d.ts
2020-01-17 22:21:33 - X7ypyrL3 - CHILDPID = 18614
2020-01-17 22:21:35 - X7ypyrL3 - STDERR   =
2020-01-17 22:21:35 - X7ypyrL3 -          =     Stream #0:0[0x100]: Video: h264_smd (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709/unknown/unknown), 1280x720, 2
2020-01-17 22:21:35 - X7ypyrL3 -          = 3.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
2020-01-17 22:21:35 - X7ypyrL3 -          =     Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 96 kb/s
2020-01-17 22:21:35 - X7ypyrL3 -          = [h264_smd @ 0x9922b20] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
2020-01-17 22:21:35 - X7ypyrL3 -          = [h264_smd @ 0x9922b20] profile Main, level 3.0
2020-01-17 22:21:35 - X7ypyrL3 -          = Hardware transcoding is busy!!
2020-01-17 22:21:35 - X7ypyrL3 -          = [h264_smd @ 0x9922b20] Syno check hardware transcode falied
2020-01-17 22:21:35 - X7ypyrL3 -          = Output #0, stream_segment,ssegment, to '/tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_X7ypyrL3/slice-%05d.ts':
2020-01-17 22:21:35 - X7ypyrL3 -          =     Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 23.98 fps
2020-01-17 22:21:35 - X7ypyrL3 -          =     Metadata:
2020-01-17 22:21:35 - X7ypyrL3 -          =       encoder         : Lavc56.41.100 h264_smd
2020-01-17 22:21:35 - X7ypyrL3 -          =     Stream #0:1: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 96 kb/s
2020-01-17 22:21:35 - X7ypyrL3 -          = Stream mapping:
2020-01-17 22:21:35 - X7ypyrL3 -          =   Stream #0:0 -> #0:0 (h264_smd (native) -> h264 (h264_smd))
2020-01-17 22:21:35 - X7ypyrL3 -          =   Stream #0:1 -> #0:1 (copy)
2020-01-17 22:21:35 - X7ypyrL3 -          = Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2020-01-17 22:21:35 - X7ypyrL3 - *** CHILD END ***
2020-01-17 22:21:35 - X7ypyrL3 - *** PROCESS END ***
  • The same test using the official SynoCommunity ffmpeg v4.1-11
2020-01-17 22:35:22 - aPjswwuG - *** PROCESS START ***
2020-01-17 22:35:22 - aPjswwuG - MOVIE    = /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.mkv
2020-01-17 22:35:22 - aPjswwuG - CODEC    = h264
2020-01-17 22:35:22 - aPjswwuG - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-17 22:35:22 - aPjswwuG - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-17 22:35:22 - aPjswwuG - PARAMVS  =
2020-01-17 22:35:22 - aPjswwuG -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264.m
2020-01-17 22:35:22 - aPjswwuG -          = kv -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec libmp3lame -ab 96k -ac 2 -f s
2020-01-17 22:35:22 - aPjswwuG -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-17 22:35:22 - aPjswwuG -          = nt_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9027301ddc12e0
2020-01-17 22:35:22 - aPjswwuG -          = e29dbe1c9462a376c4_aPjswwuG/slice-%05d.ts
2020-01-17 22:35:22 - aPjswwuG - PARAM1   =
2020-01-17 22:35:22 - aPjswwuG -          = -ss 0.000 -noaccurate_seek -i /volume1/video/series/A.Movie.720p.x264/A.Movie.720p.x264
2020-01-17 22:35:22 - aPjswwuG -          = .mkv -vcodec copy -acodec libmp3lame -ab 96k -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-17 22:35:22 - aPjswwuG - PARAM2   =
2020-01-17 22:35:22 - aPjswwuG -          = -prefer_smd -i pipe:0 -map 0 -threads 0 -vcodec h264_smd -vsync 2 -vprofile main -s 848x464 -bf 0 -vb 500000 -acodec cop
2020-01-17 22:35:22 - aPjswwuG -          = y -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 
2020-01-17 22:35:22 - aPjswwuG -          = -segment_start_number 00000 -avoid_negative_ts 0 -break_non_keyframes 1 /tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462
2020-01-17 22:35:22 - aPjswwuG -          = a376c4_aPjswwuG/slice-%05d.ts
2020-01-17 22:35:23 - aPjswwuG - CHILDPID = 30063
2020-01-17 22:35:25 - aPjswwuG - STDERR   =
2020-01-17 22:35:25 - aPjswwuG -          =     Stream #0:0[0x100]: Video: h264_smd (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709/unknown/unknown), 1280x720, 2
2020-01-17 22:35:25 - aPjswwuG -          = 3.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
2020-01-17 22:35:25 - aPjswwuG -          =     Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 96 kb/s
2020-01-17 22:35:25 - aPjswwuG -          = [h264_smd @ 0x8ac5a60] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
2020-01-17 22:35:25 - aPjswwuG -          = [h264_smd @ 0x8ac5a60] profile Main, level 3.0
2020-01-17 22:35:25 - aPjswwuG -          = Hardware transcoding is busy!!
2020-01-17 22:35:25 - aPjswwuG -          = [h264_smd @ 0x8ac5a60] Syno check hardware transcode falied
2020-01-17 22:35:25 - aPjswwuG -          = Output #0, stream_segment,ssegment, to '/tmp/VideoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_aPjswwuG/slice-%05d.ts':
2020-01-17 22:35:25 - aPjswwuG -          =     Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 23.98 fps
2020-01-17 22:35:25 - aPjswwuG -          =     Metadata:
2020-01-17 22:35:25 - aPjswwuG -          =       encoder         : Lavc56.41.100 h264_smd
2020-01-17 22:35:25 - aPjswwuG -          =     Stream #0:1: Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 96 kb/s
2020-01-17 22:35:25 - aPjswwuG -          = Stream mapping:
2020-01-17 22:35:25 - aPjswwuG -          =   Stream #0:0 -> #0:0 (h264_smd (native) -> h264 (h264_smd))
2020-01-17 22:35:25 - aPjswwuG -          =   Stream #0:1 -> #0:1 (copy)
2020-01-17 22:35:25 - aPjswwuG -          = Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2020-01-17 22:35:25 - aPjswwuG - *** CHILD END ***
2020-01-17 22:35:25 - aPjswwuG - *** PROCESS END ***

Can you send me the result of the ls -al /var/packages/VideoStation/target/bin/ command?

drwxr-xr-x  2 VideoStation VideoStation   4096 Jan 12 20:32 .
drwxr-xr-x 16 VideoStation VideoStation   4096 Jan 12 20:30 ..
-rwxr-xr-x  1 VideoStation VideoStation  49616 Jun  4  2019 cffmpeg
-rwxr-xr-x  1 VideoStation VideoStation  33088 Jun  4  2019 check_folder_conf
-rwsr-x---  1 root         VideoStation  24892 Jun  4  2019 db_setup_handler
-rwxr-xr-x  1 VideoStation VideoStation  12460 Jun  4  2019 dtvstreamserver
-rwxr-xr-x  1 VideoStation VideoStation 253740 Jun  4  2019 dvblast
-rwxr-xr-x  1 VideoStation VideoStation 116732 Jun  4  2019 dvblastctl
-rwsr-x---  1 root         VideoStation   2938 Jan 14 00:00 ffmpeg
-rwsr-x---  1 root         VideoStation 256924 Jun  4  2019 ffmpeg.orig
-rwxr-xr-x  1 VideoStation VideoStation 156812 Jun  4  2019 ffprobe
-rwxr-xr-x  1 VideoStation VideoStation  67056 Jun  4  2019 hdhomerun_config
-rwxr-xr-x  1 VideoStation VideoStation  20784 Jun  4  2019 hdhomerunscan
-rwxr-xr-x  1 VideoStation VideoStation   9536 Jun  4  2019 lsdvb
-rwxr-xr-x  1 VideoStation VideoStation  57584 Jun  4  2019 scan
-rwsr-x---  1 root         VideoStation  33437 Jun  4  2019 synocodectool
-rwxr-xr-x  1 VideoStation VideoStation   8288 Jun  4  2019 synodtvd_ffmpeg_record
-rwxr-xr-x  1 VideoStation VideoStation  68158 Jun  4  2019 synodvbepg
-rwsr-x---  1 root         VideoStation  90736 Jun  4  2019 synovideoconversion
-rwsr-x---  1 root         VideoStation 148180 Jun  4  2019 synovideoindex
-rwsr-x---  1 root         VideoStation 156452 Jun  4  2019 synovideopreprocess
-rwsr-x---  1 root         VideoStation   8304 Jun  4  2019 synovideostation
-rwsr-x---  1 root         VideoStation  24760 Jun  4  2019 synovideostation_update_conf
-rwsr-x---  1 root         VideoStation   8288 Jun  4  2019 synovideostation_user_check
-rwsr-x---  1 root         VideoStation   8272 Jun  4  2019 synovideostation_user_del
-rwsr-x---  1 root         VideoStation 148168 Jun  4  2019 synovideosubtitleextraction
-rwxr-xr-x  1 VideoStation VideoStation  17996 Jun  4  2019 szap
-rwxr-xr-x  1 VideoStation VideoStation  19264 Jun  4  2019 szap-s2
-rwxr-xr-x  1 VideoStation VideoStation  18060 Jun  4  2019 tzap
-rwsr-x---  1 root         VideoStation 152372 Jun  4  2019 video_hash
-rwxr-xr-x  1 VideoStation VideoStation 286300 Jun  4  2019 w_scan
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 18, 2020

Thank you @c-b-h
So we agree, no miracle!

However, with a little work on this code: https://gist.github.com/tmm1/280f11b9c252cec87167c4bd406b508c
I think I've figured out what's blocking it: As @kc6108 suggested, SMD transcoding can only be used once. The problem is that for VideoStation it's the wrapper that uses SMD and when ffmpeg.orig is launched, the child thinks SMD is already used. So I simply hacked the file that allows the communication between VideoStation and the ffmpeg.orig. Easy isn't it? 🤔

To install the new version:

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/46bf16481d1ae89732ba713a028d5ebb/raw/ffmpeg-wrapper-pipe > /var/packages/VideoStation/target/bin/ffmpeg

It's not sure if it works at first try because I've done some hypothetical code, but I've added the logs that will give me the right information.

@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 18, 2020

Hi there,
today I got the following error with the piped version (# TEST VERSION PIPE CONCEPT V2) while streaming with live transcoding to Chromecast through the iOS app.

2020-01-18 12:11:39 - - = /var/packages/VideoStation/target/bin/ffmpeg: line 68: -timelimit: command not found

Does anyone have an idea?

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 18, 2020

@richterd,

Can you paste me the entire session logs: from the *** PROCESS START *** to the *** PROCESS END ***.

The - - reminds me of an ffmpeg call not yet processed by the wrapper.

Maybe a good find!

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 18, 2020

All I'm asking for is Synology to make the minor change above and then uncomment the line of code disabling side-loading ffmpeg ;)

@kc6108, what you call "slide-loading ffmpeg" is what VideoStation did before version 2.3.5, right?
From what I've read about it, Synology had coded an illegal hack and that's why they removed it...

@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 18, 2020

@richterd,

Can you paste me the entire session logs: from the *** PROCESS START *** to the *** PROCESS END ***.

The - - reminds me of an ffmpeg call not yet processed by the wrapper.

Maybe a good find!

Hi,
I just updated to v3 of the pipe version, to see if it changes things. This specific error is gone (video froze and log showed mentioned error). But unfortunately instead of crashing, the video now freezes every now and then (1-4 times per minute) for about a second or two. Not sure how to debug that. When the film runs fine, CPU usage is around 20%. When it freezes, CPU spikes to 30%. Attached the log, but it seems to look fine.

2020-01-18 15:17:29 - LUxhM6Vh - *** PROCESS START PID 23592 ***
2020-01-18 15:17:29 - LUxhM6Vh - MOVIE    = /volume1/video/movies/Movie.mkv
2020-01-18 15:17:29 - LUxhM6Vh - CODEC    = hevc
2020-01-18 15:17:29 - LUxhM6Vh - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-18 15:17:29 - LUxhM6Vh - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-18 15:17:29 - LUxhM6Vh - PARAMVS  =
2020-01-18 15:17:29 - LUxhM6Vh -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volume1/video/
2020-01-18 15:17:29 - LUxhM6Vh -          = movies/Movie.mkv -r 24 -vcodec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_va
2020-01-18 15:17:29 - LUxhM6Vh -          = api=w=1920:h=800 -vsync 2 -bf 0 -vb 15000000 -acodec aac -ab 128K -ac 2 -f ssegment -pix_fmt yuv420p -segment_format mpe
2020-01-18 15:17:29 - LUxhM6Vh -          = gts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -indi
2020-01-18 15:17:29 - LUxhM6Vh -          = vidual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/V
2020-01-18 15:17:29 - LUxhM6Vh -          = ideoStation/HLS/85fd3d2dbf1fe1116e3293911da2068f_LUxhM6Vh/slice-%05d.ts
2020-01-18 15:17:29 - LUxhM6Vh - PARAM1   =
2020-01-18 15:17:29 - LUxhM6Vh -          = -ss 0.000 -noaccurate_seek -i /volume1/video/movies/Movie.mkv -vcodec copy -acodec aac -ab 128
2020-01-18 15:17:29 - LUxhM6Vh -          = K -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-18 15:17:29 - LUxhM6Vh - PARAM2   =
2020-01-18 15:17:29 - LUxhM6Vh -          = -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i pipe:0 -map 0 -r 24 -vcod
2020-01-18 15:17:29 - LUxhM6Vh -          = ec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=1920:h=800 -vsync 2 -bf 0 -vb 15000000 -acodec c
2020-01-18 15:17:29 - LUxhM6Vh -          = opy -f ssegment -pix_fmt yuv420p -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segmen
2020-01-18 15:17:29 - LUxhM6Vh -          = t_time_delta 0.000 -segment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 
2020-01-18 15:17:29 - LUxhM6Vh -          = -max_muxing_queue_size 1024 /tmp/VideoStation/HLS/85fd3d2dbf1fe1116e3293911da2068f_LUxhM6Vh/slice-%05d.ts
2020-01-18 15:17:29 - LUxhM6Vh - ENABLED  =
2020-01-18 15:17:29 - LUxhM6Vh -          = [{"PID":23592,"hardware_transcode":false,"offline_conversion":false}]
2020-01-18 15:17:29 - LUxhM6Vh - CHILDPID = 23635
2020-01-18 15:17:29 - LUxhM6Vh - ENABLED  =
2020-01-18 15:17:29 - LUxhM6Vh -          = [{"PID":23592,"hardware_transcode":false,"offline_conversion":false}]

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 19, 2020

Thank you @kc6108 for all this very interesting information.

Since the beginning I've had in mind to look for a cleaner way to modify libsynovte.so but if indeed it's as simple as you make it sound with a tool like IDA, I think I'll have a lot of fun! As soon as I have some time, I'll test it.

However, I don't agree with you on why Synology would stop slide load the ffmpeg custom. In fact, with version 2.3.4, the one where everything works by itself the hls_seek_time parameter already exists and the ffmpeg custom is never loaded directly. I think in this version it's just some lib that was loaded. That's why some people call it an illegal hack: Synology distributes VideoStation without the DTS drivers but on the other hand allows to load the community drivers.

Concerning apparmor, I agree, we shouldn't disable it except to do some tests but I think we shouldn't disable the VideoStation one either. I didn't have time yet but I'd rather add rules to apparmor rather than remove some, it should be possible. In the meantime I prefer to add workarounds with ffmpeg.orig in the wrapper.

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 19, 2020

Hello everyone!

ffmpeg 4.2.1 is finally available in the official SynoCommunity channel so I invite you to uninstall the pre-version you have installed and install the -23 version available directly in the Package Center (if you don't have the SynoCommunity packages in your Package Center yet, follow the instructions here: https://synocommunity.com/)

Thanks again @th0ma7 for all the great work.

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 19, 2020

@BenjaminPoncet Thnx, but also thnx a lot to @ymartin59 for package release and @m4tt075 for all previous work he did and everyone who tested this all the way to get there (too many to name, you know who you are).

All in all, it's been a great community effort and let's hope this continue a bit further!

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 19, 2020

Since the beginning I've had in mind to look for a cleaner way to modify libsynovte.so but if indeed it's as simple as you make it sound with a tool like IDA, I think I'll have a lot of fun! As soon as I have some time, I'll test it.

I spoke a little too fast, IDA is a disassembler, it's not for me.

@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 19, 2020

@richterd,
Can you paste me the entire session logs: from the *** PROCESS START *** to the *** PROCESS END ***.
The - - reminds me of an ffmpeg call not yet processed by the wrapper.
Maybe a good find!

Hi,
I just updated to v3 of the pipe version, to see if it changes things. This specific error is gone (video froze and log showed mentioned error). But unfortunately instead of crashing, the video now freezes every now and then (1-4 times per minute) for about a second or two. Not sure how to debug that. When the film runs fine, CPU usage is around 20%. When it freezes, CPU spikes to 30%. Attached the log, but it seems to look fine.

2020-01-18 15:17:29 - LUxhM6Vh - *** PROCESS START PID 23592 ***
2020-01-18 15:17:29 - LUxhM6Vh - MOVIE    = /volume1/video/movies/Movie.mkv
2020-01-18 15:17:29 - LUxhM6Vh - CODEC    = hevc
2020-01-18 15:17:29 - LUxhM6Vh - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-18 15:17:29 - LUxhM6Vh - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-18 15:17:29 - LUxhM6Vh - PARAMVS  =
2020-01-18 15:17:29 - LUxhM6Vh -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volume1/video/
2020-01-18 15:17:29 - LUxhM6Vh -          = movies/Movie.mkv -r 24 -vcodec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_va
2020-01-18 15:17:29 - LUxhM6Vh -          = api=w=1920:h=800 -vsync 2 -bf 0 -vb 15000000 -acodec aac -ab 128K -ac 2 -f ssegment -pix_fmt yuv420p -segment_format mpe
2020-01-18 15:17:29 - LUxhM6Vh -          = gts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -indi
2020-01-18 15:17:29 - LUxhM6Vh -          = vidual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/V
2020-01-18 15:17:29 - LUxhM6Vh -          = ideoStation/HLS/85fd3d2dbf1fe1116e3293911da2068f_LUxhM6Vh/slice-%05d.ts
2020-01-18 15:17:29 - LUxhM6Vh - PARAM1   =
2020-01-18 15:17:29 - LUxhM6Vh -          = -ss 0.000 -noaccurate_seek -i /volume1/video/movies/Movie.mkv -vcodec copy -acodec aac -ab 128
2020-01-18 15:17:29 - LUxhM6Vh -          = K -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-18 15:17:29 - LUxhM6Vh - PARAM2   =
2020-01-18 15:17:29 - LUxhM6Vh -          = -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i pipe:0 -map 0 -r 24 -vcod
2020-01-18 15:17:29 - LUxhM6Vh -          = ec h264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=1920:h=800 -vsync 2 -bf 0 -vb 15000000 -acodec c
2020-01-18 15:17:29 - LUxhM6Vh -          = opy -f ssegment -pix_fmt yuv420p -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segmen
2020-01-18 15:17:29 - LUxhM6Vh -          = t_time_delta 0.000 -segment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 
2020-01-18 15:17:29 - LUxhM6Vh -          = -max_muxing_queue_size 1024 /tmp/VideoStation/HLS/85fd3d2dbf1fe1116e3293911da2068f_LUxhM6Vh/slice-%05d.ts
2020-01-18 15:17:29 - LUxhM6Vh - ENABLED  =
2020-01-18 15:17:29 - LUxhM6Vh -          = [{"PID":23592,"hardware_transcode":false,"offline_conversion":false}]
2020-01-18 15:17:29 - LUxhM6Vh - CHILDPID = 23635
2020-01-18 15:17:29 - LUxhM6Vh - ENABLED  =
2020-01-18 15:17:29 - LUxhM6Vh -          = [{"PID":23592,"hardware_transcode":false,"offline_conversion":false}]

Hi @BenjaminPoncet
I now tried to understand the issue. The same movie that stutters on Chromecast works fine when streamed through Apple TV. The only difference between both streams seems to be the audio stream (AAC in case of Chromecast and MP3 in case of Apple TV). Can I force ffmpeg to use mp3 somehow for Chromecast, to see if that is the reason for the stuttering?

Thanks,
Daniel

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 19, 2020

@richterd,

If you have not restarted your NAS, you should be able to retrieve the logs I am interested in with the following command:

cat /tmp/ffmpeg.log | grep "2020-01-18 12:11"

For your freeze problem, I don't think it comes from the v3 because the only change is the rewriting of the VideoStation working file for the "Hardware transcoding is busy" problem on EvanSport NAS.

Usually this kind of problem comes either from the transcoding which is too slow (<25 fps) or from a too slow connection between the NAS and the browser (or DS Video).

But you may have found something.
To force mp3 transcoding it's quite simple, just modify the script like this:

# Code to find
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "copy")
;;
# Replace with
-acodec)
	shift
	args1+=("-acodec" "libmp3lame")
	args2+=("-acodec" "copy")
;;

I also have another hypothesis: in the logs you transmit there is -r 24 which means 24 fps. This parameter may not be compatible with audio passthrough if the source is not in 24 fps. I suggest you try the following modification:

# Code to find
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "copy")
;;
# Replace with
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "$1")
;;
@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 19, 2020

@kc6108,

You could write a book!!!
But more seriously I think I'm going to create a tips section :)

I tried this on VideoStation 2.3.4 (when the SynoCommunity ffmpeg is installed):

# ldd /var/packages/VideoStation/target/bin/ffmpeg
	linux-vdso.so.1 (0x00007ffea89dc000)
	libavdevice.so.56 => /var/packages/VideoStation/target/lib/ffmpeg/libavdevice.so.56 (0x00007f1acb8af000)
	libavfilter.so.5 => /var/packages/VideoStation/target/lib/ffmpeg/libavfilter.so.5 (0x00007f1acb55f000)
	libavformat.so.56 => /var/packages/VideoStation/target/lib/ffmpeg/libavformat.so.56 (0x00007f1acb180000)
	libavcodec.so.56 => /var/packages/VideoStation/target/lib/ffmpeg/libavcodec.so.56 (0x00007f1ac9d16000)
	libpostproc.so.53 => /var/packages/VideoStation/target/lib/ffmpeg/libpostproc.so.53 (0x00007f1ac9af1000)
	libswresample.so.1 => /var/packages/VideoStation/target/lib/ffmpeg/libswresample.so.1 (0x00007f1ac98d6000)
	libswscale.so.3 => /var/packages/VideoStation/target/lib/ffmpeg/libswscale.so.3 (0x00007f1ac9669000)
	libavutil.so.54 => /var/packages/VideoStation/target/lib/ffmpeg/libavutil.so.54 (0x00007f1ac93ff000)
	libm.so.6 => /lib/libm.so.6 (0x00007f1ac90fa000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00007f1ac8ede000)
	libc.so.6 => /lib/libc.so.6 (0x00007f1ac8b38000)
	libz.so.1 => /lib/libz.so.1 (0x00007f1ac8922000)
	libopencore-amrwb.so.0 => /lib/libopencore-amrwb.so.0 (0x00007f1ac870b000)
	libopencore-amrnb.so.0 => /lib/libopencore-amrnb.so.0 (0x00007f1ac84dc000)
	libmp3lame.so.0 => /lib/libmp3lame.so.0 (0x00007f1ac8265000)
	libfaac.so.0 => /lib/libfaac.so.0 (0x00007f1ac8052000)
	liblzma.so.5 => /lib/liblzma.so.5 (0x00007f1ac7e2c000)
	/lib64/ld-linux-x86-64.so.2 (0x000055df6601d000)
	libstdc++.so.6 => /lib/libstdc++.so.6 (0x00007f1ac7b3a000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f1ac7929000)
@fildar

This comment has been minimized.

Copy link

@fildar fildar commented Jan 20, 2020

Hi, everybody,

After a hard work you can relive here: SynoCommunity/spksrc#3842 @th0ma7 managed to add Intel Quick Sync support to the SynoCommunity ffmpeg (-22).

And so, for the occasion, I couldn't resist to code a special wrapper to replace VAAPI (used by VideoStation) by Quick Sync
In two words, Quick Sync is a slight gain in image quality with a real gain in GPU performance (+15/20%).
More info here: https://trac.ffmpeg.org/wiki/Hardware/QuickSync

This wrapper is only for the x64 arch (Broadwell, Braswell, Apollo Lake).

To install it (Warning this wrapper depends on the version -22 or higher of ffmpeg)

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/4f7b635e993a8de1105a3f3bc361dea7/raw/ffmpeg-wrapper-qsv > /var/packages/VideoStation/target/bin/ffmpeg

Some more info here: SynoCommunity/spksrc#3842 (comment)

As usual, all your feedback are welcome.

PS: All these special versions of the wrapper are intended to integrate the next version of the main wrapper in the form of options
PS2: Next job: armv8 support

cc @QuByte-Zer0, @richterd, @fildar, @intothevoid, @felix-m-p, @Denton22

Hi @BenjaminPoncet,

Thanks again for all your work, I'll never be be tired of saying it ! 🥇

Just a quick feedback as I am using this "special wrapper" for a few days now :

  • I am under the impression that it consumes a little more CPU than before (rev11). But I can be mistaken! (I know the wrapper isn't consuming the resources itself - the use of IQS instead of VAAPI to be more accurate)
    I saw last week that the NAS CPU was under high usage. 3 or 4 family/friends were watching videos on my NAS using DSVideo or VideoStation at this time. I was too lazy to have a precise look at the logs but I saw - running a top command through SSH - that the decoding tasks were the ones consuming all the resources.
    I made no comparison whatsoever between the impact of the 2 wrappers so again, I can be mistaken. I'll tell you more if I encounter this high usage again.
  • In the logs, I see the same movie played several times with only a few seconds between the timestamps. I think it happens when someone does a fastforward (or rewind) in the video. Only a few parameters are different i.e.: -ss / -hls_seek_time / -segment_time_delta / -segment_start_number. But the ChildPID is also different.
    Can you confirm it is due to the navigation in the video file ?
  • I had an issue reading an old file (.avi / mpeg4 / mp3) and had a "Unknown decoder 'mpeg4_qsv'" error in the logs. Here are the logs (if useful to something) :
2020-01-17 21:46:34 - U8po2JKj - *** PROCESS START ***
2020-01-17 21:46:34 - U8po2JKj - MOVIE    = /volume1/video/video.avi
2020-01-17 21:46:34 - U8po2JKj - CODEC    = mpeg4
2020-01-17 21:46:34 - U8po2JKj - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-17 21:46:34 - U8po2JKj - PARAMVS  =
2020-01-17 21:46:34 - U8po2JKj -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volume1/video/
2020-01-17 21:46:34 - U8po2JKj -          = video.avi -vcodec h264_vaapi -vf form
2020-01-17 21:46:34 - U8po2JKj -          = at=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=848:h=464 -vsync 2 -bf 0 -vb 1718392 -acodec libmp3lame -ab 96k -ac 2 
2020-01-17 21:46:34 - U8po2JKj -          = -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -s
2020-01-17 21:46:34 - U8po2JKj -          = egment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -max_muxing_queue_siz
2020-01-17 21:46:34 - U8po2JKj -          = e 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9edae9f37e8cd1a8a2e5c169f3a574ae_U8po2JKj/slice-%05d.ts
2020-01-17 21:46:34 - U8po2JKj - PARAMQVS =
2020-01-17 21:46:34 - U8po2JKj -          = -ss 0.000 -hwaccel qsv -c:v mpeg4_qsv -noautorotate -i /volume1/video/video.avi
2020-01-17 21:46:34 - U8po2JKj -          = -c:v h264_qsv -vf scale_qsv=w=848:h=464:format=nv12 -vsync 2 -bf 0 -vb 171839
2020-01-17 21:46:34 - U8po2JKj -          = 2 -acodec libmp3lame -ab 96k -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_
2020-01-17 21:46:34 - U8po2JKj -          = time 5 -segment_time_delta 0.000 -segment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_no
2020-01-17 21:46:34 - U8po2JKj -          = n_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:1 /tmp/VideoStation/HLS/9edae9f37e8cd1a8a2e5c169f3a574ae_U8po2
2020-01-17 21:46:34 - U8po2JKj -          = JKj/slice-%05d.ts
2020-01-17 21:46:34 - U8po2JKj - CHILDPID = 23933
2020-01-17 21:46:34 - U8po2JKj - STDERR   =
2020-01-17 21:46:34 - U8po2JKj -          = ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
2020-01-17 21:46:34 - U8po2JKj -          =   built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
2020-01-17 21:46:34 - U8po2JKj -          =   configuration: --target-os=linux --cross-prefix=/home/th0ma7/git-ffmpeg-QS-master/spksrc/toolchains/syno-apollolake-6.
2020-01-17 21:46:34 - U8po2JKj -          = 1/work/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- --prefix=/var/packages/ffmpeg/target --extra-cflags=-I/home/th0ma7/g
2020-01-17 21:46:34 - U8po2JKj -          = it-ffmpeg-QS-master/spksrc/spk/ffmpeg/work-apollolake-6.1/install/var/packages/ffmpeg/target/include --extra-ldflags=-L/
2020-01-17 21:46:34 - U8po2JKj -          = home/th0ma7/git-ffmpeg-QS-master/spksrc/spk/ffmpeg/work-apollolake-6.1/install/var/packages/ffmpeg/target/lib --extra-li
2020-01-17 21:46:34 - U8po2JKj -          = bs='-lxml2 -ldl' --pkg-config=/usr/bin/pkg-config --ranlib=/home/th0ma7/git-ffmpeg-QS-master/spksrc/toolchains/syno-apol
2020-01-17 21:46:34 - U8po2JKj -          = lolake-6.1/work/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ranlib --enable-cross-compile --enable-rpath --enable-pic --
2020-01-17 21:46:34 - U8po2JKj -          = enable-shared --enable-gpl --enable-fontconfig --enable-libass --enable-libbluray --enable-avresample --enable-libfreety
2020-01-17 21:46:34 - U8po2JKj -          = pe --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libsoxr --enable-libvorbis --enable-libvpx --enable
2020-01-17 21:46:34 - U8po2JKj -          = -libx264 --enable-libx265 --enable-gnutls --disable-debug --disable-doc --disable-static --enable-libfdk-aac --enable-no
2020-01-17 21:46:34 - U8po2JKj -          = nfree --extra-cflags='-DSYNO_VIDEOSTATION -DSYNO_AUDIOSTATION -DSYNO_MEDIASERVER -DSYNO_DSM' --extra-cflags=-fno-if-conv
2020-01-17 21:46:34 - U8po2JKj -          = ersion --enable-libaom --arch=x86_64 --enable-vaapi --enable-libmfx
2020-01-17 21:46:34 - U8po2JKj -          =   libavutil      56. 31.100 / 56. 31.100
2020-01-17 21:46:34 - U8po2JKj -          =   libavcodec     58. 54.100 / 58. 54.100
2020-01-17 21:46:34 - U8po2JKj -          =   libavformat    58. 29.100 / 58. 29.100
2020-01-17 21:46:34 - U8po2JKj -          =   libavdevice    58.  8.100 / 58.  8.100
2020-01-17 21:46:34 - U8po2JKj -          =   libavfilter     7. 57.100 /  7. 57.100
2020-01-17 21:46:34 - U8po2JKj -          =   libavresample   4.  0.  0 /  4.  0.  0
2020-01-17 21:46:34 - U8po2JKj -          =   libswscale      5.  5.100 /  5.  5.100
2020-01-17 21:46:34 - U8po2JKj -          =   libswresample   3.  5.100 /  3.  5.100
2020-01-17 21:46:34 - U8po2JKj -          =   libpostproc    55.  5.100 / 55.  5.100
2020-01-17 21:46:34 - U8po2JKj -          = Unknown decoder 'mpeg4_qsv'
2020-01-17 21:46:34 - U8po2JKj - *** CHILD END ***
2020-01-17 21:46:34 - U8po2JKj - *** PROCESS END ***

Another error with a HEVC video :

2020-01-19 22:00:02 - ykrhOuWI - *** PROCESS START ***
2020-01-19 22:00:02 - ykrhOuWI - MOVIE    = /volume1/video/video.mkv
2020-01-19 22:00:02 - ykrhOuWI - CODEC    = hevc
2020-01-19 22:00:02 - ykrhOuWI - FFMPEG   = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-19 22:00:02 - ykrhOuWI - PARAMVS  =
2020-01-19 22:00:02 - ykrhOuWI -          = -ss 0.000 -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /volume1/video/
2020-01-19 22:00:02 - ykrhOuWI -          = video.mkv -vcodec h
2020-01-19 22:00:02 - ykrhOuWI -          = 264_vaapi -vf format=nv12|vaapi,hwupload,setsar=sar=1,scale_vaapi=w=1280:h=720 -vsync 2 -bf 0 -vb 1000000 -acodec libmp3
2020-01-19 22:00:02 - ykrhOuWI -          = lame -ab 128K -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment
2020-01-19 22:00:02 - ykrhOuWI -          = _time_delta 0.000 -segment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -
2020-01-19 22:00:02 - ykrhOuWI -          = max_muxing_queue_size 1024 -map 0:0 -map 0:2 /tmp/VideoStation/HLS/f91f8a5a9a61d9fee198d42febb0361b_ykrhOuWI/slice-%05d.
2020-01-19 22:00:02 - ykrhOuWI -          = ts
2020-01-19 22:00:02 - ykrhOuWI - PARAMQVS =
2020-01-19 22:00:02 - ykrhOuWI -          = -ss 0.000 -hwaccel qsv -c:v hevc_qsv -noautorotate -i /volume1/video/video.mkv
2020-01-19 22:00:02 - ykrhOuWI -          = -c:v h264_qsv -vf scale_qsv=w=1280:h=720:format=nv12 -vsync 
2020-01-19 22:00:02 - ykrhOuWI -          = 2 -bf 0 -vb 1000000 -acodec libmp3lame -ab 128K -ac 2 -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_se
2020-01-19 22:00:02 - ykrhOuWI -          = ek_time 0 -segment_time 5 -segment_time_delta 0.000 -segment_start_number 00000 -individual_header_trailer 0 -avoid_nega
2020-01-19 22:00:02 - ykrhOuWI -          = tive_ts 0 -break_non_keyframes 1 -max_muxing_queue_size 1024 -map 0:0 -map 0:2 /tmp/VideoStation/HLS/f91f8a5a9a61d9fee19
2020-01-19 22:00:02 - ykrhOuWI -          = 8d42febb0361b_ykrhOuWI/slice-%05d.ts
2020-01-19 22:00:02 - ykrhOuWI - CHILDPID = 12723
2020-01-19 22:00:07 - ykrhOuWI - STDERR   =
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not 
2020-01-19 22:00:07 - ykrhOuWI -          = found (-9)
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error loading plugins
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error initializing an MFX session
2020-01-19 22:00:07 - ykrhOuWI -          = Error while decoding stream #0:0: Function not implemented
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not 
2020-01-19 22:00:07 - ykrhOuWI -          = found (-9)
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error loading plugins
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error initializing an MFX session
2020-01-19 22:00:07 - ykrhOuWI -          = Error while decoding stream #0:0: Function not implemented
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Could not load the requested plugin '33a61c0b4c27454ca8d85dde757c6f8e': specified object was not 
2020-01-19 22:00:07 - ykrhOuWI -          = found (-9)
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error loading plugins
2020-01-19 22:00:07 - ykrhOuWI -          = [hevc_qsv @ 0x127ae40] Error initializing an MFX session
2020-01-19 22:00:07 - ykrhOuWI -          = Error while decoding stream #0:0: Function not implemented
2020-01-19 22:00:07 - ykrhOuWI -          = Too many packets buffered for output stream 0:1.
2020-01-19 22:00:07 - ykrhOuWI -          = [libmp3lame @ 0x1272f00] 4 frames left in the queue on closing
2020-01-19 22:00:07 - ykrhOuWI -          = Conversion failed!
2020-01-19 22:00:07 - ykrhOuWI - *** CHILD END ***
2020-01-19 22:00:07 - ykrhOuWI - *** PROCESS END ***
@0SkillAllLuck

This comment has been minimized.

Copy link

@0SkillAllLuck 0SkillAllLuck commented Jan 20, 2020

Usage with QuickSync
image

Usage with rev11
image

Both used a 4K Movie with EAC3 5.1 audio with 1 minute playback at the beginning and the scrubbing a bit.
DS918+ with 4GB memory was used for the tests.

I did however notice weird artefacts when using QuickSync from time to time that seem to be connected to srubbing through movies. Also resuming only works sometimes.

@th0ma7

This comment has been minimized.

Copy link

@th0ma7 th0ma7 commented Jan 22, 2020

@QuByte-Zer0 wow, thnx for the stats. Really interesting.
In theory you should be able to reproduce that as well using latest version of ffmpeg -23 by temporary renaming /var/packages/ffmpeg/target/lib/iHD_drv_video.so which would disable QuickSync driver (noticed through /var/packages/ffmpeg/target/bin/vainfo). This would tell if newer version of vaapi performs differently from the previous one using the same legacy driver i965_drv_video.so driver)

@Johan303

This comment has been minimized.

Copy link

@Johan303 Johan303 commented Jan 23, 2020

Just popping in to say that this worked like a charm on my DS916+. Massive thanks for putting this together.

@Beta1-Syno

This comment has been minimized.

Copy link

@Beta1-Syno Beta1-Syno commented Jan 24, 2020

hi Guys,

At first i would like to thanks you for your job making ffmpeg still working on our syno.

Unfortunatly my DS418play still not works after uninstalling both videostation an ffmpeg synocommunity package (4.2.1-23).
DS418play has an appololake processor. I've follow the tutorial an the whole instruction but vidéos still not work, (some of them works on my apple TV but nothing on my samsung TV with DS video embeded.

What could do better to solve this trouble ?

Many thanks

@richterd

This comment has been minimized.

Copy link

@richterd richterd commented Jan 26, 2020

@richterd,

If you have not restarted your NAS, you should be able to retrieve the logs I am interested in with the following command:

cat /tmp/ffmpeg.log | grep "2020-01-18 12:11"

For your freeze problem, I don't think it comes from the v3 because the only change is the rewriting of the VideoStation working file for the "Hardware transcoding is busy" problem on EvanSport NAS.

Usually this kind of problem comes either from the transcoding which is too slow (<25 fps) or from a too slow connection between the NAS and the browser (or DS Video).

But you may have found something.
To force mp3 transcoding it's quite simple, just modify the script like this:

# Code to find
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "copy")
;;
# Replace with
-acodec)
	shift
	args1+=("-acodec" "libmp3lame")
	args2+=("-acodec" "copy")
;;

I also have another hypothesis: in the logs you transmit there is -r 24 which means 24 fps. This parameter may not be compatible with audio passthrough if the source is not in 24 fps. I suggest you try the following modification:

# Code to find
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "copy")
;;
# Replace with
-acodec)
	shift
	args1+=("-acodec" "$1")
	args2+=("-acodec" "$1")
;;

Hi,
neither the audio codec, nor the passthrough was the problem. The bitrate was it. My poor Chromecast 1 just cannot handle bitrates above 8Mb/1080p. So adding the following line fixed it (PoC - should adapt to the selected quality (low, medium, high, automatic) in a final version):

-vb)
    shift
    args1+=("-vb" "5M")
    args2+=("-vb" "5M")
;;

Regarding the error message mentioned earlier please find it attached.

2020-01-18 12:11:37 - 1331637134 - *** CHILD END ***
2020-01-18 12:11:37 - 1331637134 - *** PROCESS END ***
2020-01-18 12:11:39 -  - *** PROCESS START ***
2020-01-18 12:11:39 -  - MOVIE    = /volume1/video/movies/Movie.mkv
2020-01-18 12:11:39 -  - CODEC    = hevc
2020-01-18 12:11:39 -  - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-18 12:11:39 -  - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-18 12:11:39 -  - CHILDPID = 5221
2020-01-18 12:11:39 -  - STDERR   =
2020-01-18 12:11:39 -  -          = /var/packages/VideoStation/target/bin/ffmpeg: line 68: -timelimit: command not found
2020-01-18 12:11:39 -  - *** CHILD END ***
2020-01-18 12:11:39 -  - *** PROCESS END ***
2020-01-18 12:11:39 -  - *** PROCESS START ***
2020-01-18 12:11:39 -  - MOVIE    = /volume1/video/movies/Movie.mkv
2020-01-18 12:11:39 -  - CODEC    = hevc
2020-01-18 12:11:39 -  - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-18 12:11:39 -  - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-18 12:11:39 -  - CHILDPID = 5250
2020-01-18 12:11:39 -  - STDERR   =
2020-01-18 12:11:39 -  -          = /var/packages/VideoStation/target/bin/ffmpeg: line 68: -timelimit: command not found
2020-01-18 12:11:39 -  - *** CHILD END ***
2020-01-18 12:11:39 -  - *** PROCESS END ***
@c-b-h

This comment has been minimized.

Copy link

@c-b-h c-b-h commented Jan 26, 2020

Thanks @BenjaminPoncet, @th0ma7, @kc6108 and all you out there who have contributed in improving the codec as well the wrappers that allow us DS Video users to use the NAS to the fullest extend.

With my current setup using the -23 version of ffmpeg togeether with @BenjaminPoncet's wrapper-pipe, I am able to enjoy videos with EAC3 also when enforcing transcoding. However for some reason, casting video on Chromecast – which has been my main primary method for accessing video – something seems to go 🍌s and I get the following log output:

2020-01-26 21:22:25 - Wg82kXTk - *** PROCESS START PID 16596 ***
2020-01-26 21:22:25 - Wg82kXTk - MOVIE    = /volume1/video/series/A.Movie.720p/A.Movie.720p.mkv
2020-01-26 21:22:25 - Wg82kXTk - CODEC    = h264
2020-01-26 21:22:25 - Wg82kXTk - FFMPEG1  = /var/packages/ffmpeg/target/bin/ffmpeg
2020-01-26 21:22:25 - Wg82kXTk - FFMPEG2  = /var/packages/VideoStation/target/bin/ffmpeg.orig
2020-01-26 21:22:25 - Wg82kXTk - PARAMVS  =
2020-01-26 21:22:25 - Wg82kXTk -          = -ss 0.000 -prefer_smd -i /volume1/video/series/A.Movie.720p/A.Movie.720p.mkv
2020-01-26 21:22:25 - Wg82kXTk -          = -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 1000000 -acodec libfaac -ab 128K -ac 2 -f s
2020-01-26 21:22:25 - Wg82kXTk -          = segment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.000 -segme
2020-01-26 21:22:25 - Wg82kXTk -          = nt_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 -map 0:0 -map 0:1 /tmp/Vi
2020-01-26 21:22:25 - Wg82kXTk -          = deoStation/HLS/9027301ddc12e0e29dbe1c9462a376c4_Wg82kXTk/slice-%05d.ts
2020-01-26 21:22:25 - Wg82kXTk - PARAM1   =
2020-01-26 21:22:25 - Wg82kXTk -          = -ss 0.000 -noaccurate_seek -i /volume1/video/series/A.Movie.720p/A.Movie.720p.mkv
2020-01-26 21:22:25 - Wg82kXTk -          = -vcodec copy -acodec libfaac -ab 128K -ac 2 -f mpegts -map 0:0 -map 0:1 pipe:1
2020-01-26 21:22:25 - Wg82kXTk - PARAM2   =
2020-01-26 21:22:25 - Wg82kXTk -          = -prefer_smd -i pipe:0 -map 0 -threads 0 -vcodec h264_smd -vsync 2 -vprofile high -s 1280x720 -bf 0 -vb 1000000 -acodec c
2020-01-26 21:22:25 - Wg82kXTk -          = opy -f ssegment -segment_format mpegts -segment_list_type m3u8 -hls_seek_time 0 -segment_time 5 -segment_time_delta 0.00
2020-01-26 21:22:25 - Wg82kXTk -          = 0 -segment_start_number 00000 -individual_header_trailer 0 -avoid_negative_ts 0 -break_non_keyframes 1 /tmp/VideoStation
2020-01-26 21:22:25 - Wg82kXTk -          = /HLS/9027301ddc12e0e29dbe1c9462a376c4_Wg82kXTk/slice-%05d.ts
2020-01-26 21:22:25 - Wg82kXTk - ENABLED  =
2020-01-26 21:22:25 - Wg82kXTk -          = [{"PID":16596,"hardware_transcode":false,"offline_conversion":false}]
2020-01-26 21:22:25 - Wg82kXTk - CHILDPID = 16636
2020-01-26 21:22:25 - Wg82kXTk - ENABLED  =
2020-01-26 21:22:25 - Wg82kXTk -          = [{"PID":16596,"hardware_transcode":false,"offline_conversion":false}]
2020-01-26 21:22:26 - Wg82kXTk - STDERR   =
2020-01-26 21:22:26 - Wg82kXTk -          = ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
2020-01-26 21:22:26 - Wg82kXTk -          =   built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
2020-01-26 21:22:26 - Wg82kXTk -          =   configuration: --prefix=/usr/pkg --incdir='${prefix}/include/ffmpeg' --arch=i686 --target-os=linux --cross-prefix=/usr
2020-01-26 21:22:26 - Wg82kXTk -          = /local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu- --enable-cross-compile --enable-optimizations --enable-pic --enable-gpl 
2020-01-26 21:22:26 - Wg82kXTk -          = --enable-version3 --enable-nonfree --enable-libfaac --enable-encoders --enable-pthreads --disable-muxer=image2 --disable
2020-01-26 21:22:26 - Wg82kXTk -          = -muxer=image2pipe --disable-swscale-alpha --disable-ffplay --disable-ffserver --disable-doc --disable-devices --disable-
2020-01-26 21:22:26 - Wg82kXTk -          = bzlib --disable-altivec --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --disable-decoder=amrn
2020-01-26 21:22:26 - Wg82kXTk -          = b --disable-encoder=zmbv --disable-encoder=dca --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 
2020-01-26 21:22:26 - Wg82kXTk -          = --disable-decoder=eac3 --disable-encoder=truehd --disable-decoder=truehd --cc=/usr/local/i686-pc-linux-gnu/bin/i686-pc-l
2020-01-26 21:22:26 - Wg82kXTk -          = inux-gnu-ccache-gcc --enable-shared --disable-static --enable-yasm --enable-libx264 --enable-encoder=libx264 --enable-li
2020-01-26 21:22:26 - Wg82kXTk -          = bh264_smd --enable-smd --disable-filter=hqdn3d --extra-libs='-ljson-c -lgdl -losal -lpal -lsven -lismd_core -lismd_audio
2020-01-26 21:22:26 - Wg82kXTk -          =  -lismd_viddec -lismd_videnc -lismd_vidpproc -lplatform_config -lffmpeg_plugin'
2020-01-26 21:22:26 - Wg82kXTk -          =   libavutil      54. 27.100 / 54. 27.100
2020-01-26 21:22:26 - Wg82kXTk -          =   libavcodec     56. 41.100 / 56. 41.100
2020-01-26 21:22:26 - Wg82kXTk -          =   libavformat    56. 36.100 / 56. 36.100
2020-01-26 21:22:26 - Wg82kXTk -          =   libavdevice    56.  4.100 / 56.  4.100
2020-01-26 21:22:26 - Wg82kXTk -          =   libavfilter     5. 16.101 /  5. 16.101
2020-01-26 21:22:26 - Wg82kXTk -          =   libswscale      3.  1.101 /  3.  1.101
2020-01-26 21:22:26 - Wg82kXTk -          =   libswresample   1.  2.100 /  1.  2.100
2020-01-26 21:22:26 - Wg82kXTk -          =   libpostproc    53.  3.100 / 53.  3.100
2020-01-26 21:22:26 - Wg82kXTk -          = pipe:0: Invalid data found when processing input
2020-01-26 21:22:26 - Wg82kXTk - *** CHILD END ***
2020-01-26 21:22:26 - Wg82kXTk - *** PROCESS END ***

It feels that you guys are very close in making this part work too…

@BenjaminPoncet

This comment has been minimized.

Copy link
Owner Author

@BenjaminPoncet BenjaminPoncet commented Jan 27, 2020

Hi @fildar,

Thank you for your feedback is always very helpful!

  • I am under the impression that it consumes a little more CPU than before (rev11). But I can be mistaken! (I know the wrapper isn't consuming the resources itself - the use of IQS instead of VAAPI to be more accurate)
    I saw last week that the NAS CPU was under high usage. 3 or 4 family/friends were watching videos on my NAS using DSVideo or VideoStation at this time. I was too lazy to have a precise look at the logs but I saw - running a top command through SSH - that the decoding tasks were the ones consuming all the resources.
    I made no comparison whatsoever between the impact of the 2 wrappers so again, I can be mistaken. I'll tell you more if I encounter this high usage again.

Totally agree, QSV seems to consume more CPU than VAAPI, @QuByte-Zer0 illustrated it very well.
I have a little doubt about the scale_qsv parameter I use. I'm not 100% sure that this parameter uses the hardware entirely. Ideally I should use the VPP filters, but it's complicated to almost no documentation for ffmpeg. As soon as I have some time, I'll redo some conversion tests.
However, what you can't see on the graphs is that QSV is faster. I had noticed it on the command line. So normally QSV is able to do more transcoding in parallel.

  • In the logs, I see the same movie played several times with only a few seconds between the timestamps. I think it happens when someone does a fastforward (or rewind) in the video. Only a few parameters are different i.e.: -ss / -hls_seek_time / -segment_time_delta / -segment_start_number. But the ChildPID is also different.
    Can you confirm it is due to the navigation in the video file ?

Yeah, I see that a lot.
But usually it comes from VideoStation because there's the *** KILLCHILD *** log which means that VideoStation sent a term signal to the wrapper.

  • I had an issue reading an old file (.avi / mpeg4 / mp3) and had a "Unknown decoder 'mpeg4_qsv'" error in the logs. Here are the logs (if useful to something)

You have just highlighted one of the problems of the wrapper: Contrary to VAAPI, with QSV it is necessary to specify the decoder to be used otherwise the decoder is software. I noticed that decoders are almost always called [codec]_qsv so I simply retrieved the codec of the video via a prob and added _qsv. Except that the mpeg4_qsv decoder doesn't exist. From what I read the h264_qsv decoder is able to read mpeg4 so I updated the wrapper to use h264_qsv for mpeg4 videos:

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/4f7b635e993a8de1105a3f3bc361dea7/raw/ffmpeg-wrapper-qsv > /var/packages/VideoStation/target/bin/ffmpeg

Another error with a HEVC video :

I've already had this kind of error on a video with 2 eac3 audio tracks. Track 1 was going well while track 2 was not. (Knowing that my video goes well in VLC).
Is it the same case? In the log, I see that you have selected audio track 2, does it work with track 1 ?
It could be interesting to test with the standard wrapper (rev11):

wget -O - https://gist.githubusercontent.com/BenjaminPoncet/bbef9edc1d0800528813e75c1669e57e/raw/ffmpeg-wrapper > /var/packages/VideoStation/target/bin/ffmpeg
@BenjaminPoncet

This comment has been minimized.