title: How to get & set the video format in youtube-dl?
body: <p>I want to download <strong>mp3</strong> or any other <strong>audio file</strong> available through <strong>youtube-dl</strong>.</p>
  <p><strong>getaudio.php</strong></p>
  <pre><code>&lt;?php
      $youtubeUrl =  $_GET['url'];
      $content = shell_exec(&quot;youtube-dl -j $youtubeUrl &quot;); 
      $meta=json_decode($content);  
      $file= $meta-&gt;{'_filename'};
      $fileWithoutExtension = explode(&quot;.&quot;,$file)[0];
      $extension = &quot;.m4a&quot;;
      $file = $fileWithoutExtension . $extension;         
      header(&quot;Content-Disposition: attachment; filename=\&quot;$file\&quot;&quot; );
      header(&quot;Content-Type: application/octet-stream&quot;);
      passthru(&quot;youtube-dl -o - $youtubeUrl&quot;);
  ?&gt;
  </code></pre>
  <p>This file downloads the <strong>video file</strong>. Before downloading I need to confirm all the audio formats available. How can I do that?</p>