1

I'm attempting to set headers (as suggested here) 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 I have to read inputs through a text file, so I'm back to square one....

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.