Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9213871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:50:58+00:00 2026-06-18T01:50:58+00:00

So i’ve written a bash script to take newly written to video files and

  • 0

So i’ve written a bash script to take newly written to video files and transcode them for playback and streaming in my server here is the script

  while true; do
    printf -v filename '%q' "$(inotifywait --format "%w""%f" -r -e close_write /var/$
    echo $filename
            if [[ $filename == *".mp4"* ]]; then
                    echo "1"
                    avconv -i "$filename" "`echo ${filename%.mp4}.webm`"
            fi

            if [[ $filename == *".mkv"* ]]; then
                    echo "2"
                    avconv -i "$filename" "`echo ${filename%.mkv}.mp4`"
                    avconv -i "$filename" "`echo ${filename%.mkv}.webm`"
            fi

            if [[ "$filename" == *".avi"* ]]
                    then echo "3"
                    avconv -i "$filename" "`echo ${filename%.avi}.mp4`" &
                    avconv -i "$filename" "`echo ${filename%.avi}.webm`"&
                 fi
      done

The script works fairly well however if the $filename contains spaces avconv breaks and the script returns:

      Watches established.
      /var/www/media2net/tv/The\ Daily.mkv
      2
      avconv version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav s
      built on Nov  6 2012 16:51:33 with gcc 4.6.3
       /var/www/media2net/tv/The\: No such file or directory
      avconv version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav 
      built on Nov  6 2012 16:51:33 with gcc 4.6.3
      /var/www/media2net/tv/The\ Daily.mkv: No such file or directory
      Setting up watches.  Beware: since -r was given, this may take a while!
      Watches established.

however this is not correct as I can view the said file inside it’s respective directory, I also have tested avconv with the following in the shell and everything works properly and avconv transcodes video

       avconv -i /var/www/media2net/The\ Daily.mkv /var/www/media2net/tv/The\ Daily.webm

Basically I am wondering what I am doing wrong in my script or if anyone else has experienced a similar problem using avconv or ffmpeg (as the 2 are fairly similar and avconv is ubuntu’s fork of the project) any help would be greatly appreciated!
Thanks in advance
-brendan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:50:59+00:00Added an answer on June 18, 2026 at 1:50 am

    There seems to be some inconsistencies in your usage of escape backslashes and quotes. In fact, you only need one of the two, and the easier to use is certainly the quotes.

    So, to remove the backslashes in filenames would be the first good thing to do.

    Additionally,

    "$(inotifywait --format "%w""%f"...
    

    should be corrected in :

    "$(inotifywait --format '%w%f'...
    

    Also, the lines which comprehend something like :

    "`echo ${filename%.mkv}.mp4`"
    

    are somewhat ambiguous, as in, fact, you are echoing – if there is a space in $filename – two chains of characters -. It should be corrected in :

    "${filename/%.mkv/.mp4}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y’all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.