title: Files dissapearing with ffmpeg recursive conversion
body: <p>I started in askubuntu, asking for a way to convert recursively more than 14K of wma to mp3 extracting the wma files path from a txt file.
  There was an answer that could cover my needs, but a bug appears. The first run with some hundreds worked ok. The second, some wma albums got converted, others entirely deleted. There were some modifications. And last time completely, deleted all wma without converting.</p>
  <p>this was the original script</p>
  <pre><code>#!/usr/bin/env bash
  
  readarray -t files &lt; wma-files.txt
  
  for file in &quot;${files[@]}&quot;; do
      out=`echo $file | sed &quot;s:wma:mp3:&quot;`
      probe=`avprobe -show_streams &quot;$file&quot; 2&gt;/dev/null`
      rate=`echo &quot;$probe&quot; | grep &quot;bit_rate&quot; | sed &quot;s:.*=\(.*\)[0-9][0-9][0-9][.].*:\1:&quot;`
      avconv -i &quot;$file&quot; -ab &quot;$rate&quot;k &quot;$out&quot;
      rm &quot;$file&quot;
  done
  </code></pre>
  <p>Then the adaptation with ffmpeg</p>
  <pre><code>#!/usr/bin/env bash
  
  readarray -t files &lt; wma-files.txt
  
  for file in &quot;${files[@]}&quot;; do
      out=`echo $file | sed &quot;s:wma:mp3:&quot;`
      probe=`avprobe -show_streams &quot;$file&quot; 2&gt;/dev/null`
      rate=`echo &quot;$probe&quot; | grep &quot;bit_rate&quot; | sed &quot;s:.*=\(.*\)[0-9][0-9][0-9][.].*:\1:&quot;`
      ffmpeg -i &quot;$file&quot; -ab &quot;$rate&quot;k &quot;$out&quot; &amp;&amp; rm &quot;$file&quot;
  done
  </code></pre>
  <p>With the first one I converted many files. Other just get deleted. The ones deleted were always the same release (so, all tracks from a release). I can listen, and even convert them with Soundkonverter.</p>
  <p>Both of them produces &quot;no such file of directory&quot; and when this happens, everything get deleted.</p>
  <p>The partition where files are stored is a usb HDD ntfs, but also happens in my ext4 internal HD.
  I'm under Xubuntu 14.04</p>
  <p>Here the script running with avconv (which what I managed to convert some, but other get disappeared) <a href="http://pastebin.com/w5weqEws" rel="nofollow noreferrer">http://pastebin.com/w5weqEws</a>  and with ffmpeg (that didn't convert any) <a href="http://pastebin.com/3QkaPzvW" rel="nofollow noreferrer">http://pastebin.com/3QkaPzvW</a></p>
  <p>I can't find differences between successfully and deleted original wma's. But for example, while other progs like beets read and write the tags, puddletag and mp3tag (under wine) don't, until I converted them with soundkonverter.</p>
  <p>As the person trying to help me there redirect me here on the original post <a href="https://askubuntu.com/questions/508278/how-to-use-ffmpeg-to-convert-wma-to-mp3-recursively-importing-from-txt-file/508304#508304">https://askubuntu.com/questions/508278/how-to-use-ffmpeg-to-convert-wma-to-mp3-recursively-importing-from-txt-file/508304#508304</a>
  I'm here asking for any help to make run an script like this. Or any to use ffmpeg to convert recursively the audio files. My capacity of understanding is short for being able to make something working just reading the docs.</p>
  <p>So I ask a help to run this. If I miss any relevant information, just tell me.</p>
  <p>NOTE: I want to add that doing the conversion with</p>
  <pre><code>for file in &quot;${files[@]}&quot;; do
      out=`echo &quot;$file&quot; | sed s:wma:mp3:`
      avconv -i &quot;$file&quot; -ab 192k &quot;$out&quot;
      rm &quot;$file&quot;
  done
  </code></pre>
  <p>It works in the same files (the ones that are deleted with the other). Only that it makes everything to 192k, so not good if I'm converting lower bitrate ones. And get this error &quot;Application provided invalid, non monotonically increasing dts to muxer in stream 0&quot; that seems something typical from avconv in 14.04. With ffmpeg I cant try because I don't find the way how to use it, even out of the script. I really don't understand the docs seems
  .</p>
  <p>NOTE2: This is a mediainfo exit from:</p>
  <p>1- A typical wma that get disappeared always with the script</p>
  <pre><code>Audio
  ID                                       : 1
  Format                                   : WMA
  Format version                           : Version 2
  Codec ID                                 : 161
  Codec ID/Info                            : Windows Media Audio
  Description of the codec                 : Windows Media Audio 9 - 128 kbps, 44 kHz, stereo 1-pass CBR
  Duration                                 : 2mn 25s
  Bit rate mode                            : Constant
  Bit rate                                 : 128 Kbps
  Channel(s)                               : 2 channels
  Sampling rate                            : 44.1 KHz
  Bit depth                                : 16 bits
  Stream size                              : 2.21 MiB (99%)
  Language                                 : English (US)
  </code></pre>
  <p>2- A Wma that got successfully converted (yes I'm using copies now, I can't risk specially some rare audios that I got on the road)</p>
  <pre><code>Audio
  ID                                       : 1
  Format                                   : WMA
  Format version                           : Version 2
  Codec ID                                 : 161
  Codec ID/Info                            : Windows Media Audio
  Description of the codec                 : Windows Media Audio 9 - 128 kbps, 44 kHz, stereo 1-pass CBR
  Duration                                 : 4mn 35s
  Bit rate mode                            : Constant
  Bit rate                                 : 128 Kbps
  Channel(s)                               : 2 channels
  Sampling rate                            : 44.1 KHz
  Bit depth                                : 16 bits
  Stream size                              : 4.21 MiB (99%)
  Language                                 : English (US)
  </code></pre>
  <p>So, as I don't see difference, but maybe, I'm losing any data to look into?</p>