remove audio from mp4 file ffmpeg - python-3.x

I am on a Mac using Python 3.6. I am trying to remove audio from an mp4 file using ffmpeg but unfortunately it does not give me the "silenced" mp4 file I look for. Code I use is:
ffmpeg_extract_audio("input_file.mp4", "output_file.mp4", bitrate=3000, fps=44100)
It gives me a new output file with a low-quality video image, but still the audio. Any suggestion?

ok thank you #sascha. I finally put all my mp4 files in the same folder and run the following code:
for file in *.mp4; do ffmpeg -i "$file" -c copy -an "noaudio_$file"; done
If, like me, one uses Sublime Text or any other text editor (already using Python language), it run with the following:
import subprocess
command = 'for file in *.mp4; do ffmpeg -i "$file" -c copy -an "noaudio_$file"; done'
subprocess.call(command, shell=True)

Related

How to execute this ffmpeg command for multiple videos in a folder and rename them on Linux terminal [duplicate]

This question already has answers here:
Looping over pairs of values in bash [duplicate]
(6 answers)
Closed 16 days ago.
I'm trying to change the framerate of my video to 15fps and I need to do that for 100+ videos that are in the same folder
For processing a single video I use the following command-
ffmpeg -i input.mp4 -filter:v fps=fps=15 processed/input_15fpst.mp4
How do I do this for multiple videos in the folder and add a suffix _15fps to them ? I'm not very familiar with Linux programming
Thank you so much!
I tried doing this-
for f in *.MP4; do ffmpeg -i "$f" -filter:v fps=fps=15 process/"$f"; done
But I want to rename the file as well, how do I change my loop?
This should do the trick:
for f in *.MP4; do ffmpeg -i "$f" -filter:v fps=fps=15 process/"${f}_15fps"; done

ffmpeg doesn't accept input in script

this is a beginner's question but i can't figure out the answer after looking into it for several days:
I want ffmpeg to extract the audio portion of a video and save it in an .ogg container. If i run the following command in terminal it works as expected:
ffmpeg -i example.webm -vn -acodec copy example.ogg
For convenience, i want to do this in a script. However, if i pass a variable to ffmpeg it apparently just considers the first word and produces the error "No such file or directory".
I noticed that my terminal escapes spaces by a \ so i included this in my script. This doesn't solve the problem though.
Can someone please explain to me, why ffmpeg doesn't consider the whole variable that is passed to it in a script while working correctly when getting passed the same content in the terminal?
This is my script that passes the filename with spaces escaped by \ to ffmpeg:
#!/bin/bash
titelschr=$(echo $# | sed "s/ /\\\ /g")
titelohne=$(echo $titelschr | cut -d. -f 1)
titelogg=$(echo -e ${titelohne}.ogg)
ffmpeg -i $titelschr -vn -acodec copy $titelogg
Thank you very much in advance!
You need to quote variable expansions, try this :
#!/usr/bin/env bash
titelschr=$1
titelogg="${titelschr%.*}.ogg"
ffmpeg -i "$titelschr" -vn -acodec copy "$titelogg"
call with :
bash test.sh "Some video file.mp4"
This way, you don't need to escape spaces.

Redirecting ffmpeg result into another file

I'm trying to get the size of an input video using ffmpeg, below is the code that I use, what I'm trying to do is to first store the result into a txt file and then do some parsing to get the size of the video:
$ ffmpeg -i TheNorth.mp4
The terminal says "At least one output file must be specified"
Then I tried this:
$ ffmpeg -i TheNorth.mp4 result.txt
The terminal says "Unable to find a suitable output format for 'size.txt'"
So how could I get the result and save it to the specified file?
You can store the output ffmpeg generates with piping:
ffmpeg -i TheNorth.mp4 2> result.txt
You need to use 2> here, as ffmpeg writes to StdErr (and not StdOut).
ffprobe
If you just want to get the size of the video then you can get that, and other info, directly with ffprobe. This will avoid redirection, temporary output files, and the additional parsing.
$ ffprobe -v error -select_streams v:0 -show_entries stream=height,width -of csv=p=0:s=x input.mkv
1280x720
See FFmpeg Wiki: FFprobe Tips for more examples.
tee
For users who want to encode and capture the resulting console output, I recommend using tee. The problem with pure redirection is that important messages such as error messages, failures, and prompts can be missed.
You can avoid this by including tee to show the output in the console and to save it to a file:
ffmpeg -i input … output |& tee console.txt
ffmpeg outputs to stderr instead of the more typical stdout, so the & is added to the | pipe to deal with that. This is only for Bash 4+. If you're using something else then change |& to 2>&1 which redirects stderr to stdout before it is sent to the pipe.
Somewhat better idea is to use ffprobe
ffprobe -show_format -print_format json TheNorth.mp4
that will output JSON formated info about video. Guess it is easier to parse than raw output. To redirect output to file use just ordinary pipe > result.txt similar to accepted answer but without two.

How can i add cover image on mp3 file using ffmpeg?

I'm trying to convert audio file to mp3 and I want to add cover image into mp3 file.
I tried this:
ffmpeg.exe -i "input audio file" -i image.png out.mp3
When conversion completes there is no cover image into mp3.
I tried and this which is from the official documentation of ffmpeg. The result is the same mp3 file without cover image.
ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"-metadata:s:v comment="Cover (Front)" out.mp3
Thank you in advance!

How to generate video screencaps of video files via linux commandline

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

Resources