I'm trying to setup a pipeline on gstreamer to decode a RTP stream with h264 encoding using GPU decode d3d11h264dec.
So far, I've made it work using avdec_h264 along with rtp pay/depay:
gst-launch-1.0 dx9screencapsrc width=1920 height=1080 monitor=1 ! "video/x-raw, framerate=30/1" ! videoconvert ! x264enc speed-preset=ultrafast threads=4 sliced-threads=true ! rtph264pay config-interval=1 pt=96 ! "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! avdec_h264 max-threads=12 ! d3d11videosink
I can also make it work using d3d11h264dec without RTP pay/depay:
gst-launch-1.0 dx9screencapsrc width=1920 height=1080 monitor=1 ! "video/x-raw, framerate=30/1" ! videoconvert ! x264enc speed-preset=medium threads=12 ! d3d11h264dec ! d3d11videosink
But not using both RTP pay/depay and d3d11h264dec:
gst-launch-1.0 dx9screencapsrc width=1920 height=1080 monitor=1 ! "video/x-raw, framerate=30/1" ! videoconvert ! x264enc speed-preset=medium threads=12 ! rtph264pay config-interval=1 pt=96 ! "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! d3d11h264dec ! d3d11videosink
The last one gives me an error not negociated (-4).
I've tried adding a h264parse between depay and decoder as seen on some other issues, to no avail (same error).
I have to work on windows OS and the d3d11videosink is compulsory.
The problem came from the default profile used by x264enc which is profile=(string)high-4:4:4 , whereas d3d11h264dec can't handle it. One must force caps after x264enc. I also had to add h264parse after depay, I d'ont know why...The final pipe is:
gst-launch-1.0 dx9screencapsrc width=1920 height=1080 monitor=1 ! "gst-launch-1.0 dx9screencapsrc width=1920 height=1080 monitor=1 ! "video/x-raw, framerate=30/1" ! videoconvert ! x264enc ! "video/x-h264, profile=(string)high" ! rtph264pay config-interval=1 pt=96 ! "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! d3d11h264dec ! d3d11videosink
Related
I am trying to testing a folder for ownership, directory & writable in the below if statement which is working as anticipated in bash script
if [ -O ./testDir -a -d ./testDir -a -w ./testDir ]
then
echo "All is well"
else
echo "All not ok"| mail -s "Folder Issue" -r "xyz<xyz#xyz.com>" xyz#xyz.com
fi
however I wanted to replace the above if statement with the below, which is not working; it works well if i test each condition in different if statement
if [ ! -O ./testDir -a ! -d ./testDir -a ! -w ./testDir ]
then
echo "All not ok"| mail -s "Folder Issue" -r " xyz<xyz#xyz.com>" xyz#cisco.com
fi
Please help in case i have done a mistake
not( expr1 and expr2 and expr3 )
with De Morgan's laws is equal to:
(not expr1) or (not expr2) or (not expr3)
So you should go with:
if [ ! -O ./testDir -o ! -d ./testDir -o ! -w ./testDir ]
Insert ! after if:
if ! [ -O ./testDir -a -d ./testDir -a -w ./testDir ]
How do you negate a test in bash if you want to combine multiple tests?
The code is
if ! [ $(pgrep Xvfb) ] || [ ! -v DISPLAY ]; then
echo starting xvfb
mkdir -p /tmp/xvfb
Xvfb :1 -fbdir /tmp/xvfb > /tmp/xvfb_output 2>&1 &
export DISPLAY=:1
fi
It is supposed to be sourced and to start Xvfb if not already running.
Previously, it lacked the || [ ! -v DISPLAY ] part to check the existence of said variable.
To negate a test, you could do either ! [ ... ] or [ ! ... ], which both seem to work.
Is the reasoning correct that you should use [ ! ...] because it is inside the test and thus clearer (and a bit more efficient)?
I'm pretty sure it doesn't matter where you put the negation in terms of efficiency. As for readability, you could write your if statement like this:
if ! (test "$(pgrep Xvfb)" -a -n "${DISPLAY:+1}"); then
This way you have only one negation on one test.
I agree with you that
if ! [ $(pgrep Xvfb) ] || [ ! -v DISPLAY ]; then
is ambiguous and
if [ ! $(pgrep Xvfb) ] || [ ! -v DISPLAY ]; then
is not.
I am new to Bash and scripting and I want to figure out a way to combine these two statements into 1 . what this script does is checks if two files D1 and D2 are the same file and if not checks if their content is the same.
if [ ! $D1 -ef $D2 ]
then
echo not the same file
if cmp -s $D1 $D2
then
echo same info
else
echo not same info
fi
else
echo same file
fi
In addition to this, I am also confused when to use [] and when to skip them, manual says when its a conditional use [], but what does that mean ?
Thank you.
The syntax of an if statement is (from 2.10 Shell Grammar):
if_clause : If compound_list Then compound_list else_part Fi
| If compound_list Then compound_list Fi
Where compound_list eventually gets down to a command.
! $D1 -ef $D2 is not a command.
[ is a a command (also known as test). See the output from type [ or type test as well as which [ and which test.
So [ ! $D1 -ef $D2 ] is a valid command used in the if statement.
The return value of the compound_list is what if tests.
So when you are using something like cmp (or any other command) then there is no reason to use [ and, in fact, using [ is incorrect.
As the compound_list can be more than a single command to combine [ ! $D1 -ef $D2 ] and cmp -s $D1 $D2 simply use && as normal. (Need ! on the cmp call too to invert that to get the "not same" test from both.)
if [ ! "$D1" -ef "$D2" ] && ! cmp -s "$D1" "$D2"; then
echo 'Not same file or same contents'
fi
if [[ -n $(find $path -name "$string*") ]]
then
<stuff>
else
<stuff>
fi
I want to reverse the above search like
if [[ ! -n $(find $path -name "$string*") ]]
then
<stuff>
else
<stuff>
fi
But it wont allow this because here I am checking the find commands output
any clue.thanks for help
You can reverse the search in find itself using:
find "$path" ! -name "$string*"
btw this is also valid:
[[ ! -n $(find $path -name "$string*") ]]
Or else you can use -z:
[[ -z $(find $path -name "$string*") ]]
I write a shell script. I have a problem that I want to determine folder name manually. Actually, I solved with #Suhas's helping. When I execute my script, I have an error
./scriptname: line 5: syntax error in conditional expression
./scriptname: line 5: syntax error near `"${folder2}"'
./scriptname: line 5: ` if [[ ! -d "${folder1}" "${folder2}" ]]; then'
Can someone figure out what's wrong?
This:
if [[ ! -d "${folder1}" "${folder2}" ]]; then
needs to be separated into 2:
if [ ! -d "${folder1}" ] && [ ! -d "${folder2}" ]; then
A better & valid solution for a double test still using [[ ]] bash test :
if [[ ! -d "${folder1}" && ! -d "${folder2}" ]]; then
Note
[[ is a bash keyword similar to (but more powerful than) the [ command. See http://mywiki.wooledge.org/BashFAQ/031 and http://mywiki.wooledge.org/BashGuide/TestsAndConditionals. Unless you're writing for POSIX sh, we(wooledge.org) recommend [[.