Escaping variable when passing options inside single-quote to vlc in a bash function

StackOverflow https://stackoverflow.com/questions/20931421

  •  24-09-2022
  •  | 
  •  

문제

I'm writing a bash function to call vlc to capture video to a file. And I want the file name to be timestamp. But the dst option for file name is inside a single-quote. How can I accomplish this?

The bash function and vlc command is:

function vlc-capture-func() {
    local capture_output_file="/path/vlc-capture-$(date +%Y%m%d%H%M%S)"

    vlc qtcapture:// -vvvv --no-drop-late-frames --no-skip-frames\
 --sout='#transcode{vcodec=h264,fps=15,venc=x264{preset=fast,tune=zerolatency,keyint=30,bframes=0,ref=1,level=30,profile=baseline,hrd=cbr,crf=20,ratetol=1.0,vbv-maxrate=1200,vbv-bufsize=1200,lookahead=0}}:standard{access=file,mux=ps,dst=$capture_output_file}'\
 --qtcapture-width=1280 --qtcapture-height=720 --live-caching=300 --intf=macosx

    echo "Done!"
}

Hope I made a appropriate title and clear question, also please correct me if any wrong English.

Appreciate your help!

도움이 되었습니까?

해결책

Use double quotes instead. Like:

"#transcode{vcodec=h264,fps=15,venc=x264{preset=fast,tune=zerolatency,keyint=30,bframes=0,ref=1,level=30,profile=baseline,hrd=cbr,crf=20,ratetol=1.0,vbv-maxrate=1200,vbv-bufsize=1200,lookahead=0}}:standard{access=file,mux=ps,dst=${capture_output_file}}'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top