Ffmpeg
Fleetingsubtitle encoding currently only possible from text to text or bitmap to bitmap
Change the format or the subtitle codec
ffmpeg -i input output.newformat
or
ffmpeg -i input -scodec webvtt output.newformat
speed up/slow down a video
- Référence externe : https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
- Référence externe : https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
This does not affect the audio speed. Use -an to not include audio in the output
— https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
ffmpeg -i input.mkv -filter:v “setpts=PTS/60” output.mkv
— https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
To double the speed of the video with the setpts filter, you can use:
ffmpeg -i input.mkv -filter:v “setpts=0.5*PTS” output.mkv
— https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
faster method, but which can have unexpected results with audio (pauses or async):
ffmpeg -itsscale 0.01666 -i input.mkv -c copy output.mkv
— https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
re-encode i.e. a timelapse, e.g. ffmpeg -i input -vf framestep=60,setpts=N/30/TB -r 30 -an out.mp4
— https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
encode VP8
-
Référence externe : https://trac.ffmpeg.org/wiki/Encode/VP8 Encode/VP8 – FFmpeg
Choose a higher bit rate if you want better quality. Note that you shouldn’t leave out the -b:v option as the default settings will produce mediocre quality output.
there’s a constant quality mode (like in the x264 encoder) that will ensure that every frame gets the number of bits it deserves to achieve a certain quality level, rather than forcing the stream to have an average bit rate. This results in better overall quality and should be your method of choice when you encode video with libvpx.
this case, the target bitrate becomes the maximum allowed bitrate. You enable the constant quality mode with the CRF parameter:
ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output.webm
By default the CRF value can be from 4–63, and 10 is a good starting point. Lower values mean better quality.
Important: If neither -b:v nor -crf are set, the encoder will use a low default bitrate and your result will probably look very bad. Always supply one of these options—ideally both.
If you want to tweak the quality even further, you can set two more parameters:
-qmin – the minimum quantizer (default 4, range 0–63) -qmax – the maximum quantizer (default 63, range qmin–63)
These Q values are quantization parameters, and lower generally means “better quality”. If you set the bounds from 0 to 63, this means the encoder has free choice of how to assign the quality. For a better overall quality, you can try to set -qmin to 0 and -qmax to 50 or lower. For example:
ffmpeg -i input.mp4 -c:v libvpx -qmin 0 -qmax 50 -crf 5 -b:v 1M -c:a libvorbis output.webm
should use constant bitrate encoding if you need your video files to have a certain size, or if you’re streaming the videos over a channel that only allows a certain bit rate.
subtitles
set subtitles track as default
-
Référence externe : https://stackoverflow.com/questions/26956762/ffmpeg-set-subtitles-track-as-default
see also ffmpeg convert a video using a specific audio and subtitle track, ffmpeg
ffmpeg -i in.mp4 -i in.srt -c copy -disposition:s:0 default out.mkv
— https://stackoverflow.com/questions/26956762/ffmpeg-set-subtitles-track-as-default
setting metadata in subtitles (like the language in english)
-
Référence externe : https://www.baeldung.com/linux/subtitles-ffmpeg
-metadata:s:s:0 language=eng
[…]
We’re also using the -metadata:s:s:0 option, which sets metadata for Stream:Subtitle: Number of the stream, starting with 0.
Finally, the language=eng option sets the subtitle language to English
add a bunch of subtitles in a file stored in ipfs
ffmpeg add a bunch of subtitles in a file stored in ipfs Using
- ffmpeg set subtitles track as default,
- ffmpeg convert a video using a specific audio and subtitle track,
- make ffmpeg more silent, quiet, less verbose,
- setting metadata in subtitles in ffmpeg,
- force ffmpeg into non-interactive mode,
while read filename srt
do
echo "$srt -> $filename"
ffmpeg -nostdin -y -hide_banner -loglevel warning -stats -i $filename -i $srt -vcodec copy -acodec copy -map 0:a:0 -map 1:s:0 -metadata:s:s:0 language=eng -map 0:v:0 -disposition:s:0 default $srt.webm
done < data.txt
In short,
- take the videos and the subtitles put in data.txt,
- get the video and audio from the file and the subtitle from the subtitle file,
- set the subtitle as shown by default,
- tell that it is in English,
making mp4 videos streamable
Fast start Flag: -movflags +faststart. Moves some data to the beginning of the file, allowing the video to be played before it is completely downloaded
more silent, quiet, less verbose
make ffmpeg more silent (less verbose)
-hide_banner -loglevel warning -stats
What are reasonable values for -aq when creating mp3?
-
Référence externe : https://superuser.com/questions/1515824/ffmpeg-what-are-reasonable-values-for-aq-when-creating-mp3
Since the value is codec-specific, -q:a (or -aq) is mapped to the LAME -V parameter when using -c:a libmp3lame. According to the FFmpeg Wiki,
a lower value is a higher quality. 0-3 will normally produce transparent results, 4 (default) should be close to perceptual transparency, and 6 produces an “acceptable” quality
— https://superuser.com/questions/1515824/ffmpeg-what-are-reasonable-values-for-aq-when-creating-mp3
keeping quality during conversion
-
Référence externe : https://superuser.com/questions/525928/ffmpeg-keeping-quality-during-conversion
FFmpeg sets the -crf option to 23 by default
— https://superuser.com/questions/525928/ffmpeg-keeping-quality-during-conversion
The CRF option sets the encode quality. The bit-rate will vary as necessary to provide a consistent quality throughout the video. 51 being the worst to 0 being the best — lossless.
I tend to set all my encodes to 20 which happens to be Handbrake’s default and I’ve been happy with the quality. I suggest playing around with that value to find a level of quality that is acceptable to you.
— https://superuser.com/questions/525928/ffmpeg-keeping-quality-during-conversion
- qmin integer (encoding,video) Set min video quantizer scale (VBR). Must be included between -1 and 69, default value is 2.
- qmax integer (encoding,video) Set max video quantizer scale (VBR). Must be included between -1 and 1024, default value is 31.
Notes pointant ici
- burn subtitle ffmpeg handbrake
- cutting the videos based on start and end time using ffmpeg
- ffmpeg -map option
- ffmpeg convert a video using a specific audio and subtitle track
- ffprobe
- handbrake
- how to prevent ffmpeg from dropping metadata?
- phasher crashes with some videos
- recover delete file still in use (open)