Answers.Body: <p>When a single input is directed fed to ffmpeg (-i), various options can be set on it, depending on what the input reader allows and recognizes.</p>
  
  <p>However, FFmpeg does not natively read an input list from a text file. There's a bespoke module called the concat demuxer, invoked by -f concat, which parses the input list, opens each file and concatenates them. To the main ffmpeg pipeline, this is presented as a single input, generated by the concat module. And the concat module does not recognize or carry over options meant for the individual files listed within the text file. All listed files can only be opened with default parameters of their respective demuxers/decoders/protocols..etc. This is a limitation. You may open a feature request at trac.ffmpeg.org to change this.</p>
  
  <p>What you could do is read all inputs directly.</p>
  
  <pre><code>ffmpeg \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google1.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google2.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google3.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google4.com' \
      -filter_complex "[0][1][2][3]concat=n=4:v=0:a=1" \
      'output.wav'
  </code></pre>
  
  <p>For WAV inputs, re-encoding to WAV won't lose quality.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-06T01:52:36.613Z
Answers.LastActivityDate: 2019-02-06T01:52:36.613Z
Answers.UserDisplayName: Dane Jordan
Body: <p>I'm attempting to set headers (<a href="https://www.jokecamp.com/blog/passing-http-headers-to-ffmpeg/" rel="nofollow noreferrer">as suggested here</a>) for my ffmpeg <code>concat</code> command like so:</p>
  
  <pre><code>ffmpeg \
      -f concat \
      -safe 0 \
      -protocol_whitelist file,http,https,tcp,tls \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'inputs.txt' \
      -c 'copy' 'output.wav' \
      -v trace
  </code></pre>
  
  <p>where my input file is structured as such: </p>
  
  <pre><code>file 'https://path/to/file1'
  file 'https://path/to/file2'
  file 'https://path/to/file3'
  </code></pre>
  
  <p>However, when I run the command, ffmpeg doesn't set the headers, as seen by the output of -v:</p>
  
  <pre><code>[http @ 0x7fa133d01080] request: GET / HTTP/1.1
  User-Agent: Lavf/58.20.100
  Accept: */*
  Range: bytes=0-
  Connection: close
  Host: localhost:3001
  Icy-MetaData: 1
  </code></pre>
  
  <p>What's strange is if I set my input not through an input txt and just through  <code>-i /path/to file</code> (as seen below) it works just fine.</p>
  
  <pre><code>ffmpeg \
      -f concat \
      -safe 0 \
      -protocol_whitelist file,http,https,tcp,tls \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google.com' \
      -c 'copy' 'output.wav' \
      -v trace
  </code></pre>
  
  <p>Output of -v:</p>
  
  <pre><code>[https @ 0x7fed3ac03940] request: GET / HTTP/1.1
  User-Agent: Lavf/58.20.100
  Accept: */*
  Range: bytes=0-
  Connection: close
  Host: google.com
  Icy-MetaData: 1
  Content-Type: audio/wav
  </code></pre>
  
  <p>Not sure why reading the inputs through a file would affect the headers getting sent. For now the workaround is to use a string concatenating all of the inputs (a bit messier than I'd like), but I'm curious if anyone might know why this is happening.</p>
  
  <p>UPDATE: According to <a href="https://video.stackexchange.com/questions/21728/ffmpeg-concat-error">this post</a> I have to read inputs through a text file, so I'm back to square one....</p>
  
Tags: <ffmpeg>
Title: Can't set ffmpeg request header when using file for input
UserDisplayName: Dane Jordan
ThreadText: # Can't set ffmpeg request header when using file for input
  
  (Asked by: username_0 on 2019-01-20)
  
  I'm attempting to set headers ([as suggested here](https://www.jokecamp.com/blog/passing-http-headers-to-ffmpeg/)) for my ffmpeg `concat` command like so:
  
  ```
  ffmpeg \
      -f concat \
      -safe 0 \
      -protocol_whitelist file,http,https,tcp,tls \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'inputs.txt' \
      -c 'copy' 'output.wav' \
      -v trace
  
  ```
  
  where my input file is structured as such:
  
  ```
  file 'https://path/to/file1'
  file 'https://path/to/file2'
  file 'https://path/to/file3'
  
  ```
  
  However, when I run the command, ffmpeg doesn't set the headers, as seen by the output of -v:
  
  ```
  [http @ 0x7fa133d01080] request: GET / HTTP/1.1
  User-Agent: Lavf/58.20.100
  Accept: */*
  Range: bytes=0-
  Connection: close
  Host: localhost:3001
  Icy-MetaData: 1
  
  ```
  
  What's strange is if I set my input not through an input txt and just through `-i /path/to file` (as seen below) it works just fine.
  
  ```
  ffmpeg \
      -f concat \
      -safe 0 \
      -protocol_whitelist file,http,https,tcp,tls \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google.com' \
      -c 'copy' 'output.wav' \
      -v trace
  
  ```
  
  Output of -v:
  
  ```
  [https @ 0x7fed3ac03940] request: GET / HTTP/1.1
  User-Agent: Lavf/58.20.100
  Accept: */*
  Range: bytes=0-
  Connection: close
  Host: google.com
  Icy-MetaData: 1
  Content-Type: audio/wav
  
  ```
  
  Not sure why reading the inputs through a file would affect the headers getting sent. For now the workaround is to use a string concatenating all of the inputs (a bit messier than I'd like), but I'm curious if anyone might know why this is happening.
  
  UPDATE: According to [this post](https://video.stackexchange.com/questions/21728/ffmpeg-concat-error) I have to read inputs through a text file, so I'm back to square one....
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-02-06. Score: 0 | Accepted answer
  
  When a single input is directed fed to ffmpeg (-i), various options can be set on it, depending on what the input reader allows and recognizes.
  
  However, FFmpeg does not natively read an input list from a text file. There's a bespoke module called the concat demuxer, invoked by -f concat, which parses the input list, opens each file and concatenates them. To the main ffmpeg pipeline, this is presented as a single input, generated by the concat module. And the concat module does not recognize or carry over options meant for the individual files listed within the text file. All listed files can only be opened with default parameters of their respective demuxers/decoders/protocols..etc. This is a limitation. You may open a feature request at trac.ffmpeg.org to change this.
  
  What you could do is read all inputs directly.
  
  ```
  ffmpeg \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google1.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google2.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google3.com' \
      -headers $'Content-Type: audio/wav\r\n' \
      -i 'https://google4.com' \
      -filter_complex "[0][1][2][3]concat=n=4:v=0:a=1" \
      'output.wav'
  
  ```
  
  For WAV inputs, re-encoding to WAV won't lose quality.
  
  
  ---
  
  