简体   繁体   中英

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

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}}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM