I'm trying to use a url piped from tshark into a while loop.
while read line ; do echo "$line" ffmpeg -i "$line" -c copy "filename" done < <(tshark -i tun0 -B 50 -P -V -q -l -Y 'http matches "(?<=\[Full request URI: )(http://mywebsite.com/file.*)(?=\])"' 2>&1 | grep --line-buffered -Po "(?<=\[Full request URI: )(http://mywebsite.com/file.*)(?=\])" | unbuffer -p uniq)
Inside the loop, I'm able to echo $line just fine; and it looks like this:
But for some reason, I'm unable to use this same "line" variable to feed ffmpeg, inside the same while loop. Doing
ffmpeg -i "$line" -c copy "filename"
results in (all quotes are accurately copy pasted)
[http @ 0x1ab5ec0] HTTP error 400 Bad Request: Server returned 400 Bad Request5345932&fmt=5&app_id=214748364&range=20-30&etsp=1456779359&hmac=35B2lA6D0zfR2DmfdPS4ZcilYxg
On the other hand, copying the url (from the echo output), double quoting it and using the same ffmpeg command in a terminal works perfectly.
Also, for some reason, the command is truncated when running the script with -xv, in such way that it does not show the full "+ ffmpeg -i 'http://...." line as it should.