I'm currently using mencoder to generate a video file output of many pngs
mencoder 'mf://*.png' -mf type=png:fps=2 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o out.mpg")
This works fine, but i actually need the time reversed version. Sure it would be possible to rename the files so they are in the right order but isn't there another way to start with the higher values and stop with the lower ones?
I might be late, bit for the record:
ls -r *.png >> filelist.txt; mencoder "mf://#filelist.txt" -ovc lavc -o aegeespirit2.avi
Related
I need to concat multiple mp3 files together then adjust there volume then play via aplay. I currently do this using the following 3 commands
sox file1.mp3 file2.mp3 file3.mp3 out1.wav
sox -v 0.5 out1.wav out2.wav
aplay -D plughw:1,0 out2.wav
This works correctly the only minor issue is it creates temporary files and I know it can be done by piping all these commands together somehow. Sort of like.
sox file1.mp3 file2.mp3 file3.mp3 | sox -v 0.5 | aplay -D plughw:1,0
But can't appear to get the piping to work (I am not really a linux user) Any help would be much appreciated :)
I'm using Spleeter to remove music from audios.
My goal is to build a script that automates the process of extracting audio from the video, execute Spleeter on the extracted audio & than merge the manipulated audio back to the video replacing the original one.
The main issue I had is that I don't have enough ram to process the whole extracted audio. I need to split it the into multiple pieces & execute Spleeter upon each piece.
Then concatenate the manipulated pieces together and merge the result to the video.
Here's what I tried:
#!/bin/bash
cd ~/Desktop/Video-convert
# create audio from video
ffmpeg -i *.mp4 output.mp3
# Split the audio into pieces
ffmpeg -i output.mp3 -f segment -segment_time 120 -c copy output_%03d.mp3
# Execute Spleeter upon each sample
FILES=~/Desktop/Video-convert/*.mp3
for f in $FILES
do
spleeter separate -i $f -o output_vocal
done
# delete unneeded audios
rm *.mp3
cd output_vocal
# ===========================================================
# the problem starts here
# ===========================================================
# concatenate manipulated audios together
find . -name 'vocals.wav' -exec echo {} >> mylist.txt \;
ffmpeg -f concat -safe 0 -i mylist.txt -c copy vocal.mp3
mv vocal.mp3 ../
cd ../
# merge the audio back to video
ffmpeg -i *.mp4 -i vocal.mp3 \
-c:v copy -c:a aac -strict experimental \
-map 0:v:0 -map 1:a:0 vocal-vid.mp4
Everything works well until having to concatenate the audios together. Spleeter outputs the result into vocal.wav & accompaniment.wav within a sub-folder that is named the same as the audio that was processed.
The File Tree looks like this:
output_vocal
- output_000
----- vocal.wav
----- accompaniment.wav
- output_001
----- vocal.wav
----- accompaniment.wav
- output_002
----- vocal.wav
----- accompaniment.wav
As you can see the problem comes with the naming. My objective is to concatenate all vocal.wav into one mp3 audio.
And then merge the final vocal.mp3 audio with the *.mp4 video.
Only issue is going around the way that Spleeter outputs the result audios.
the problem you are experiencing is that ffmpeg's concat demuxer requires an input file that contains directives, rather than a naive file-list.
Your find invocation creates a file like:
output_vocal/output_000/vocal.wav
output_vocal/output_001/vocal.wav
output_vocal/output_002/vocal.wav
whereas ffmpeg's concat demuxer really requires a file like:
file output_vocal/output_000/vocal.wav
file output_vocal/output_001/vocal.wav
file output_vocal/output_002/vocal.wav
Also note that find does not necessarily return the files in alphabetic order, whereas you will most likely want to concatenate the files in that order.
Finally, when concatenating the WAV-files, you cannot use the copy codec to generate an MP3 file (since the WAV/RIFF codec is not MP3). but you don't need an intermediate MP3-file anyhow
Here's an updated script, that
- uses a temporary directory for all intermediate files
- iterates over all mp4-files provided at the cmdline (rather than hardcoding the input directory)
- creates a "XXX_voc.mp4" file for each input file "XXX.mp4" (overwriting any existing files)
#!/bin/bash
for infile in "$#"
do
outfile=${infile%.mp4}_voc.mp4
# create a temp-directory to put our stuff to
TMPDIR=$(mktemp -d)
# create audio from video
ffmpeg -i "${infile}" "${TMPDIR}/output.mp3"
# Split the audio into pieces
ffmpeg -i "${TMPDIR}/output.mp3" -f segment -segment_time 120 -c copy "${TMPDIR}/output_%03d.mp3"
# Execute Spleeter upon each sample
find "${TMPDIR}" -maxdepth 1 -type f -name "output_*.mp3" \
-exec spleeter separate -i {} -o "${TMPDIR}/output_vocal" ";"
# find all 'vocal.wav' files generated by spleeter, sort them,
# prefix them with 'file ', and put them into output.txt
find "${TMPDIR}/output_vocal" -type f -name "vocal.wav" -print0 \
| sort -z \
| xargs -0 -I{} echo "file '{}'" \
> "${TMPDIR}/output.txt"
# concatenate the files and create an MP3 file
ffmpeg -f concat -safe 0 -i "${TMPDIR}/output.txt" -c copy "${TMPDIR}/vocal.wav"
# merge the audio back to video
ffmpeg -y -i "${infile}" -i "${TMPDIR}/vocal.wav" \
-c:v copy -c:a aac -strict experimental \
-map 0:v:0 -map 1:a:0 "${outfile}"
rm -rf "${TMPDIR}"
done
I have multiple wav files with the duration of 2.2 - 2.8 seconds.
I want to modify (stretch/squeeze) them, such that all of them will be with the exact duration of 2.5 seconds.
I mean slightly stretch the actual data and not just add leading/trailing zeros.
Is it possible?
Thanks
Yes, you can use https://github.com/waywardgeek/sonic like this:
sonic -s 3.2 book.wav book_fast.wav
I haven't found a simple solution with ffmpeg, but you can use RubberBand:
rubberband --duration d input.wav output.wav
(thanks to https://superuser.com/a/1132229/807246)
Example:
$ duration=2.5; for file in *.wav; do rubberband -D $duration $file out_${file}; done;
$ sox --info -D file.wav
2.390875
$ sox --info -D out_file.wav
2.500000
I want to include subtitle to a avi file with mencorder. Mencoder is starting to encode but subtitle does not appeaer in new file. Here is my mencoder code
/usr/local/bin/mencoder -oac copy -ovc copy -sub "mov.srt" -o "Domino_with_subs.avi" "mov.avi"
It's because you set the video codec to by copied... To be able to add subtitle mencoder needs to re-encode the video.
This will work
/usr/local/bin/mencoder -oac copy -ovc lavc -sub "mov.srt" -o "Domino_with_subs.avi" "mov.avi"
Is there a command line program for linux (ubuntu) which can generate a large image containing say 6 caps from a given video (e.g. WMV) laid out storyboard style (I know on Windows media player classic can do this)? I need this for part of a script I am writing.
I pulled the answer from this site: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
Where -4 is the number of seconds into the file to grab the screenshot, 320x240 is the screenshot size, and test.jpg is the output file.
Hope this helps.
Use SlickSlice
./slickslice.sh -x video.avi -s 5x3 -e
I've used MPlayer to save frames as images and ImageMagick to combine them:
mplayer -nosound -sstep 15 -vo png video.mkv
montage *.png -tile 3x3 -geometry 300x+0+0 screencaps.png
vcsi can do this. It is a command-line tool written in Python. Example:
vcsi video.mkv -o output.jpg