Forum › Forums › General › Tips and Tricks › Some useful ffmpeg commands
- This topic has 2 replies, 2 voices, and was last updated Apr 24-8:48 am by subluminal.
-
AuthorPosts
-
April 12, 2022 at 10:57 pm #81214Member
subluminal
These are one-liners to cut video using ffmpeg. For use in bash_aliases. Takes 3 input arguments. First is Input_URL, second is Start-time, third is Duration. Video height to be downloaded is <=1440. If you need best possible video, simple use bv or bv*.
If video contains both video and audio but in 2 separate streams like in youtube:
ytdlcut () { ffmpeg -ss "$2" -t "$3" -i "$(yt-dlp -f "bv[height<=?1440]" --print urls $1)" -ss "$2" -t "$3" -i "$(yt-dlp -f ba --print urls $1)" -map 0:v:0 -map 1:a:0 -vcodec copy -af "asetpts=PTS-STARTPTS" -strict experimental -movflags +faststart "$(echo "$(yt-dlp --print title $1)" | sed 's/[^a-zA-Z0-9 ]//g')-cut.mkv" }This stream-copies video and re-encodes audio ( to fix broken timestamps, duration, starttime ). Or you could simply also use stream copy for audio.
ytdlcut () { ffmpeg -ss "$2" -t "$3" -i "$(yt-dlp -f "bv[height<=?1440]" --print urls $1)" -ss "$2" -t "$3" -i "$(yt-dlp -f ba --print urls $1)" -map 0:v:0 -map 1:a:0 -vcodec copy -acodec copy "$(echo "$(yt-dlp --print title $1)" | sed 's/[^a-zA-Z0-9 ]//g')-cut.mkv" }If video contains video and audio in a single stream like in Vimeo, dailymotion etc.
ytdlcut () { ffmpeg -ss "$2" -i "$(yt-dlp -f "bv*[height<=?1440]" --print urls $1)" -t "$3" -c copy "$(echo "$(yt-dlp --print title $1)" | sed 's/[^a-zA-Z0-9 ]//g')-cut.mkv" }All cases, file is downloaded in present working directory. You need yt-dlp and ffmpeg installed.
If file is locally downloaded on disk:
ffmpegcut () { ffmpeg -ss "$2" -i "$1" -t "$3" -c:v copy -c:a copy "${1%.*}-cut.mkv" }If a locally available video h264/avc file is broken or has incorrect timestamp AND you know the correct framerate (say 25 fps):
ffmpegfix () { ffmpeg -i "$1" -an -map 0:v -vcodec copy -bsf:v h264_mp4toannexb output.h264 ffmpeg -fflags +genpts -r 25 -i "output.h264" -vcodec copy "${1%.*}-modified.mkv" rm -v "output.h264" }Hope some people find this useful. Additions would be more than welcome !!
Cheers. 😀
- This topic was modified 1 year ago by subluminal.
- This topic was modified 1 year ago by subluminal.
- This topic was modified 1 year ago by subluminal.
April 15, 2022 at 3:14 pm #81354Memberolsztyn
::Thank you for these tips.
I am just about to learn capabilities of ffmpeg and not sure yet of how useful it is in actual practice…
Trying to find out whether it is capable and howto:
– Fix video frame size scale – aspect ratio
– Fix blurry videos- This reply was modified 1 year ago by olsztyn.
Live antiX Boot Options (Previously posted by Xecure):
https://antixlinuxfan.miraheze.org/wiki/Table_of_antiX_Boot_ParametersApril 24, 2022 at 8:48 am #81999Membersubluminal
::ffmpeg is VERY capable although technically somewhat difficult to use.
ffmpeg is also THE most used multimedia backend engine in the world. From vlc, mpv, kodi, potplayer, mpc-be to Google/Youtube, Intel, facebook everyone uses it either directly or indirectly. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.