title: conversing mp4 to wav with the same file name in python
body: <p>Below are my code and I am trying to convert <code>mp4</code> file to <code>wav</code> with some parameter change, like I am changing its frequency and so on. Now my problem is I have 100 <code>mp4</code> files in the <code>"inputdir"</code> folder and I read the file one by 1 and convert it, then I want to save the file with the same name as <code>mp4</code> file names but with different extension(in my case <code>.wav</code>). In my above code, every time I am converting, it's getting saved as out.wav. Can some one suggest me some options please?</p>
  
  <p>I also checked <a href="https://stackoverflow.com/questions/43236053/how-do-i-use-ffmpeg-to-create-a-wav-file-with-the-same-name-as-the-input-m4a-f">How do I use FFMPEG to create a WAV file with the same name as the input (m4a) file?</a></p>
  
  <p>but I don't find any answer.</p>
  
  <p>Thanks :)</p>
  
  <pre><code>import os
  import ffmpy
  
  inputdir = '/home/------my folder path------------'
  
  
  for filename in os.listdir(inputdir):
      actual_filename = filename[:-4]
      if(filename.endswith(".mp4")):
          os.system("ffmpeg -i {0} -acodec pcm_s16le -ar 16000 out.wav".format(filename))
      else:
          continue
  </code></pre>
  
  <p>I want to make it as, </p>
  
  <pre><code>os.system("ffmpeg -i {0} -acodec pcm_s16le -ar 16000 actual_filename.wav".format(filename))
  </code></pre>
  
  <p>I also tried like below. </p>
  
  <pre><code>os.system("ffmpeg -i "$filename" -acodec pcm_s16le -ar 16000 "${actual_filename}".wav".format(filename))
  </code></pre>
  
  <p>But it does not work. I am getting </p>
  
  <pre><code>os.system("ffmpeg -i "$filename" -acodec pcm_s16le -ar 16000 "${actual_filename}".wav".format(filename))
                            ^
  SyntaxError: invalid syntax
  </code></pre>