I have this command using ffmpeg
root#ubuntu-4cpu-8gb-sg-sin1:/home/jaac/torrents/rtorrent/dots# ffmpeg -i Title.NF.WEB-DL.DDP2.0.x264-Ao.mkv -map 0:7 indo16.srt
That will rip 1 sub (Indonesia region)
How to rip it in batch? I have 17 files in dots folder
Thanks
Run these commands:
cd /home/jaac/torrents/rtorrent/dots
for f in *.mkv; do ffmpeg -i "$f" -map 0:s:m:language:ind "${f%.*}.srt"; done
Adapted from How do you convert an entire directory with ffmpeg?
What the -map option is doing: 0:s:m:language:ind is input #0: subtitles:metadata:language:indonesian. Which means it chooses all subtitle streams from the input that have Indonesian language metadata.
If you get error:
Stream map '0:s:m:language:ind' matches no streams.
To ignore this, add a trailing '?' to the map.
You can ignore it. Just a message telling you there is no subtitle stream with Indonesian language metadata in that particular input.
You can use a for loop:
for f in *.mkv; do ffmpeg -i $f -vf subtitles="${f%.mkv}".srt "${f%.mp4}"_sub.mkv; done
Subtitules files must have the same name as videos.
Thanks guys for helping me out.
I use this command to batch rip the subtitle:
#!/bin/bash
cd /home/jaac/torrents/rtorrent/dots || exit
for f in *.mkv; do ffmpeg -i "$f" -map 0:5:s:m:language:id "${f%.*}.srt"; done
I use Shellcheck
Thanks #llogan and #m8factorial
Related
I have a full directory of 40-50 audio files that I am trying to "concat" into one long mp3.
I was able to do this just testing around with 2 files using the command shown below, but I need an easy way to do this with a script that I can make if I have a folder of many files with complicated file names. This is something I'm going to be doing frequently so if I had a script or something I could use quickly that would be most helpful.
ffmpeg -i a.webm -i b.webm -filter_complex "[0:a] [1:a] concat=n=2:v=0:a=1 [a]" -map [a] -c:a mp3 testfull.mp3
The simplest solution is to use the concat demuxer, but all inputs must be the same format and have the same attributes (sample rate, sample format, channel layout).
printf "file '%s'\n" *.webm > input.txt
ffmpeg -f concat -safe 0 -i input.txt -map 0:a output.mp3
-safe 0 is only needed if your input file names contain special characters.
I have a folder with episodes called ep and a folder with subtitles called sub
Each episode has corresponding subtitles and i need to bulk add them with ffmpeg.
I've read that i can add subtitles with the following command:
ffmpeg -i video.avi -vf "ass=subtitle.ass" out.avi
But that only does it one file at a time.
Is there a bulk variant?
Some useful info:
ls ep prints
<series name> - Ep<episode number>.mkv
ls sub prints
<series name> - Ep<episode number>.ass
I made a small sh script that will do this:
#!/bin/sh
SUBTITLES_FOLDER=sub
EPISODES_FOLDER=ep
OUTPUT_FOLDER=out
for i in "$EPISODES_FOLDER"/*.mkv; do
sub="$SUBTITLES_FOLDER/$(echo "$i" | sed 's/mkv$/ass/')"
ffmpeg -i "$i" -i "$sub" -c:v copy -c:a copy -c:s copy -map 0:0 -map 0:1 -map 1:0 -y "$OUTPUT_FOLDER/$i" &
done
Note the '&' at the end of the ffmpeg command: it makes sure ffmpeg runs in parallel (is this the correct term for it?)
You may want to modify the file extensions and check if ffmpeg supports subtitles with your format, the rest will be done by itself.
Im using this ffmpeg command to convert mp3 to wav:
ffmpeg -i audio.mp3 -acodec libmp3lame -ab 64k -ar 16000 audio.wav
and this command to create waveform from audio.wav:
wav2png --foreground-color=ffb400aa --background-color=2e4562ff -o example4.png papa2.wav
I would love to know, how to run this commands multiple? For example, when conversion from .mp3 to .wav is done, then run the wav2png command.
Thank You!
You have several options here:
Option 1: Use &&
In Bash you can use an and list to concatenate commands. Each command will be executed one after the other. The and list will terminate when a command fails, or when all commands have been successfully executed.
ffmpeg -i audio.mp3 audio.wav && wav2png -o output.png audio.wav
Using -acodec libmp3lame when outputting to WAV makes no sense, so I removed that.
WAV ignores bitrate options, so I removed -ab.
Do you really need to change the audio rate (-ar)? Removed.
Option 2: Pipe from ffmpeg to wav2png
Instead of making a temporary WAV file you can pipe the output from ffmpeg directly to wav2png:
ffmpeg -i audio.mp3 -f wav - | wav2png -o output.png /dev/stdin
Option 3: Just use ffmpeg
Saving the best for last, you can try the showwavespic filter.
ffmpeg -i music.wav -filter_complex showwavespic=s=640x320 showwaves.png
If you want to make a video of the wave form, then try showwaves.
You can see a colored example at Generating a waveform using ffmpeg.
I'm trying to write a shell script that will extract the audio from all the movie files in a folder.
audio_extracter.sh
for f in *; do
if [ "$f" != "audio_extracter.sh" ]; then
/usr/bin/avconvert --source "$f" --output */Converted/"$f" --audioTrack -af aac
echo "$f converted"
else
echo "problems"
exit 1
fi
done
It's spitting back avconvert is a command line application that will transcode a source or group of sources to create a destination file output...
Also, if possible the script should find out the format of the audio in the video and extract it as such, without converting it to a different different format (at the moment I think I'm forcing it to convert to AAC).
Any thoughts on how to make this work?
-acodec copy extracts audio without re-encoding in ffmpeg:
for f in *.mkv; do ffmpeg -i "$f" -acodec copy "${f%mkv}aac"; done
You can see the formats of the audio streams with ffmpeg -i input.mkv.
If you can use mencoder, then try this. It works for me. (video format like mkv, mp4, flv, rmvb all works)
mencoder -oac mp3lame -ovc copy -of video_file -o audio_file.mp3
How can I automatically convert all MP4 files to FLV in a specific folder?
ffmpeg -i VID00002.MP4 -ar 44100 test.flv
Is there a way to queue these tasks, assuming that I don't know the file names?
If I need to run any scripts (I'm familiar with Python), how can I do that?
You can do this fairly easy within the terminal, given you have ffmpeg installed. In your terminal, enter the following:
$>cd /your/path/to/videos
$>for i in *.mp4; do ffmpeg -i $i -ar 44100 $i.flv; done
The second command simply iterates through each mp4 file and assigns the filename to '$i'. You then call ffmpeg using $i as the input and output filename. For the output, you simply add the extension, in this case $i.flv. So, if your filename is 'video.mp4', it will output as 'video.mp4.flv'.
Hope this helps.
This will convert and rename the new files using the find and ffmpeg functions and suppressing output questions:
find /mymediapath (\ -name '*.mp4' \) -exec bash -c 'ffmpeg -y -i "$0" -strict -2 "${0/mp4/flv}"' {} \;