ffmpeg socks4 proxy parameter with rtmp - proxy

I am unable to capture some livestreams because of the proxy issues. So in rtmpdump i can use:
rtmpdump -v -r rtmp://a_rtmp_address -p http://a_http_address -S 85.185.244.101:1080 -B 10 -o aaa.flv
But I need to use ffmpeg or avconv. But I can not find a parameter corresponds to that -S 85.185.244.101:1080 parameter.
Can anyone please give me an ffmpeg command corresponding to this rtmpdump command.

You should place socks option in quotes with rtmp:// address.
Options must be in the form KEY=VALUE after rtmp://. Like this:
ffmpeg ... -f flv "rtmp://a_rtmp_address socks=85.185.244.101:1080"

Related

Including Youtube-dl in FFMPEG not working in Bash (OSX)

I am trying to download 5 second samples for a list of youtube video. The traditional approach is to download the entire file with "youtube-dl" and then use "ffmpeg" to split it however you want it.
I am trying to use the following method: https://github.com/ytdl-org/youtube-dl/issues/622#issuecomment-162337869
It does work when I include the variables in the command, for example:
ffmpeg -ss 0 -i $(youtube-dl -f best --get-url https://www.youtube.com/watch?v=ySVi-0RS5vI&t=5s) -t 10 -c:v copy -c:a copy title2.mp4
However, I am having issues trying to automate the system. Specifically, I would like ffmpeg and youtube-dl to read a file and use the values. I created the file "youtube.txt" which includes the following codes:
440.8,https://www.youtube.com/watch?v=0-4wOE_DNeA,661.2,881.6,0-4wOE_DNeA
330,https://www.youtube.com/watch?v=0-AMWW6tHzw,495,660,0-AMWW6tHzw
509.2,https://www.youtube.com/watch?v=0-Rmto2rgMw,763.8,1018.4,0-Rmto2rgMw
427.6,https://www.youtube.com/watch?v=0-U53qm45cA,641.4,855.2,0-U53qm45cA
320.4,https://www.youtube.com/watch?v=0-dja9Ys4Sg,480.6,640.8,0-dja9Ys4Sg
343.6,https://www.youtube.com/watch?v=0-g_PulsqtM,515.4,687.2,0-g_PulsqtM
415.6,https://www.youtube.com/watch?v=0-nniRyn7dU,623.4,831.2,0-nniRyn7dU
431.2,https://www.youtube.com/watch?v=006BQU3BFxw,646.8,862.4,006BQU3BFxw
I am using the following command:
parallel -j 6 --colsep ',' ffmpeg -ss {1} -i $(youtube-dl -f best --get-url {2}) --t 5 -c:v copy -c:a copy {5} :::: youtube.txt
However, I get the following errors:
ERROR: '{2}' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:{2}" ) to search YouTube
--t: No such file or directory
Would you mind helping me?
Thanks!
Here's a solution using python2, so this should work on the python version shipped with MacOS. My original bash script was choking on the csv line reading for some reason. Add this script to getvids.py in the same directory as your youtube.txt, then run chmod +x getvids.py and when you're ready to turn it loose ./getvids.py
#!/usr/bin/python
import csv, os
with open('youtube.txt') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
starttimes = [row[0], row[2], row[3]]
yturl = os.popen('youtube-dl -f best --get-url '+row[1]).read().strip()
for thistime in starttimes:
print(row[1] + ' #time='+thistime)
os.system('ffmpeg -hide_banner -loglevel panic -ss '
+thistime+' -i "'+yturl+'" -t 5 -c copy '+row[4]+'['+thistime+'s].mp4')

awkward behaviour in bash find-loop with ffmpeg

There is something weird going on when running following script with Docker.
The dockerfile for this is:
FROM debian:9
WORKDIR /app
RUN apt-get -y update && \
apt-get -y install ffmpeg curl
COPY . /app
The script run.sh:
#!/bin/bash
find /pfs/in -maxdepth 1 -name "*.flac" -print0 | while IFS= read -r -d $'\0' inFile; do
echo "\n##### Process '${inFile}' #####"
ffmpeg -y -i ${inFile} -ar 16000 tmp.wav # use 16kHz - default for EML
done
Starting this, when mounting 3 files into the container:
$ ls pfs/in/
Testaudio16k_2.flac Testaudio16k.flac Testaudio16k.wav TestSprache_Saetze.flac
$ docker run --rm -t -v $(pwd)/pfs/in:/pfs/in test-img:latest /bin/bash run.sh
I get an error on processing the second file: pfs/in/Testaudio16k_2.flac: No such file or directory. The leading / is missing. It is also missing in the preceeding echo. Indeed this happens every second file (if I put more than 3 files in that folder).
Now coming to the counter example:
If I comment out the ffmpeg line in the script, rebuild and run, The echo prints for every file the correct path.
Does anybody have an idea about this?
Is it about the find or is the ffmpegdoing something weird? Something completely different?
Use -nostdin:
ffmpeg -nostdin -i input output
From the ffmpeg documentation:
-stdin
Enable interaction on standard input. On by default unless
standard input is used as an input. To explicitly disable interaction
you need to specify -nostdin.
Disabling interaction on standard input is useful, for example, if
ffmpeg is in the background process group. Roughly the same result
can be achieved with ffmpeg ... < /dev/null but it requires a shell.
I was able to reproduce on a regular Bash console. It's indeed a weird interaction between ffmpeg and the IFS or null delimiter.
This method work as intended
find ~/tmp -maxdepth 1 -name "*.flac" -print0 | xargs -r0 -i bash -c 'echo {}; ffmpeg -hide_banner -y -i {} -ar 16000 tmp.wav'
For your code, add < /dev/null at the end of ffmpeg command as explained here.
ffmpeg -hide_banner -y -i {} -ar 16000 tmp.wav < /dev/null
Can't reproduce that but I strongly recommend to quote the filename when passing it to ffmpeg like this:
ffmpeg -y -i "${inFile}" -ar 16000 tmp.wav.
A space at the beginning or end of the filename would explain your error when you don't use quotes
Btw, you don't need a bash loop. You can just use find:
docker run --rm -t -v $(pwd)/pfs/in:/pfs/in foo \
find /pfs/in -maxdepth 1 -name "*.flac" \
-printf "## Process file %f ##\n" \
-exec ffmpeg -y -i {} -ar 16000 tmp.wav \;

/usr/local/share/timidity/timidity.cfg: No such file or directory

Timidity version is TiMidity++-2.14.0, and here is my install commond:
./configure && make && make install
Then I run the commond
timidity song.mid -Ow -o | ffmpeg -i - -acodec libmp3lame -ab 64k song.mp3
and it returns error:
/usr/local/share/timidity/timidity.cfg: No such file or directory timidity: Can't read any configuration file. Please check /usr/local/share/timidity/timidity.cfg
"find / -name timidity.cfg", but there is no such file.
I am confused about the error.
Thanks for your reply in advance.
The documentation says:
TiMidity++ uses Either GUS/patch, or SoundFont (,or both) as the voice data to play. You must get a SoundFont or GUS/patch files, and make the configuration file. You must make the configuration file (*.cfg). By default, timidity.cfg is /usr/local/share/timidity/timidity.cfg.
Also see the Arch documentation.

avconv output_volume option - trying to understand the man page

I'm trying to increase the volume of my input .wav file by means of the output_volume option within the avconv command. I would like to increase the volume by 6 dBs similarly as demonstrated in the man page.
I have my command in a script format
for i in *.wav; do avconv -i "$i" output_volume=volume=6dB:precision=fixed "$i{%.*}".mp3;done
But I receive the following error. I see many search results pertaining to FFmpeg but I not helpful towards avconv
Unable to find a suitable output format for 'output_volume=volume=6dB:precision=
fixed'
The general sytanx from the man page is:
avconv [global options] [[infile options][ā€˜-iā€™ infile]]... {[outfile options] outfile}...
I having trouble interpreting the documentation..
Try something like this:
for i in *.wav; do
avconv -i "$i" -af volume=6dB:precision=fixed "$i{%.*}".mp3
done

#/bin/sh in one line

I'm working on some Haskell project using FFmpeg. I need to batch create from a media folder with MP4 files and create screenshots from all of them. I got the code and am using it on a terminal in Unix. It works, but how do I make it in one line to be executed in system "xxxx" in Haskell?
If not using several system"xx"...
#/bin/sh
for i in $(ls *.mp4)
do
ffmpeg -i $i -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 $i%1d.jpg
done
I tried:
import System.Cmd
function = do{system "#/bin/sh";
system "for i in $(ls *.mp4)";
system "do";
system "ffmpeg -i $i -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 $i%1d.jpg";
system "done";}
but it gives a error:
-vframes: No such file or directory
/bin/sh: Syntax error: "done" unexpected
The problem is that you're trying to execute each line of your script as a separate, independent invocation of the shell. You just need to do it all with one system call, and separate each line of the script with \n:
system "for i in $(ls *.mp4)\ndo\n..."
but you can write the shell command on one logical line, instead:
system "for i in $(ls *.mp4); do ...; done"
The first line (which should be #!/bin/sh, by the way) is not necessary when using system.
I'm not sure why you want to use Haskell for this purpose, though, if you're just going to execute a single shell script. You should write the loop over the directory contents in Haskell, and only call out to the system to do an individual conversion. At the very least, you should probably put this script into its own file and invoke it with system "sh convert.sh" or similar.
(If you want a more convenient syntax for multi-line strings like these scripts in Haskell, try the interpolatedstring-perl6 or string-qq packages.)
First, It's #!/bin/sh. Notice the exclamation mark.
Second, you're trying to execute a series of commands one after another, so no state is kept between them. Try to execute it as a single command:
function = system "for i in $(ls *.mp4); do ffmpeg -i $i -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 $i%1d.jpg; done"
Another option is to save your whole script, with the #! corrected, as a .sh file, make it executable and:
function = system "./myscript.sh"
Bash 4.X Solution
system "/bin/bash -c 'shopt -s globstar; for i in **.mp4; do ffmpeg -i \"$i\" -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 \"$i\"%1d.jpg; done'"
You don't need #!/bin/bash with system (don't forget the bang !)
Quote your variables otherwise files with spaces in their names wont work
Don't use ls like that, it will break when it comes across a file with spaces in its name
Posix Solution
system "find /some/path -type f -name \"*.mp4\" -exec sh -c 'for f; do ffmpeg -i \"$f\" -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 \"$f%1d.jpg\"; done' _ {} +"
You should not echo the shell script like this but create a shell command like this:
system "for i in $(ls *.mp4); do ffmpeg -i $i -vframes 7 -y -ss 10 -s 150x150 -an -sameq -f image2 -r 1/5 $i%1d.jpg; done"

Resources