7 ms·
Might have come in handy while I was struggling to type out ffmpeg -i part0.mp4 -i part1.mp4 -filter_complex "[1:v]scale=1280:720:force_original_aspect_rat
by Confiks 6y ago
Might have come in handy while I was struggling to type out
ffmpeg -i part0.mp4 -i part1.mp4 -filter_complex "[1:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v1]; [0:v] [0:a] [v1] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" out.mp4
to concatenate two videos with different sizes today.
My relation with it is almost identical to my relation with any bash scripting more than a one-liner: I have to relearn it every time I want to engage with it.
- whateveracct 6y agoFeels like a nice & typed Haskell eDSL on top of ffmpeg would be helpful.
- astrange 6y agoIt would be hard to be expressive enough considering there’s a lot of exceptions where things don’t really quite work. eg copying without conversion between different formats isn’t really possible when it looks like it should be, because there’s a lot of incorrect handling of timestamps both in libavformat and in files themselves.
- herpderperator 6y agoIt's true, and I feel the same, but to give it some credit: wouldn't that apply to anything you don't use regularly? Programming languages or even regular languages. You have to use it or lose it.
- wmf 6y agoIf you don't perform a task frequently, a discoverable interface (e.g. GUI) is dramatically more productive than reading documentation.
- tartoran 6y agoConversely, if you perform a task frequently you want to be able to script it out and automate it away.
- jerf 6y agoWhy not both? GUIs can be built that can emit the command-line equivalent. In ffmpeg's case, I would be looking for a GUI beyond just "here's all the command line parameters, only in a form"... the hardest thing is taking something I already know what I want to do, and encoding it into the command line, because the way to encode a graph into a command line is not obvious. It is easy in principle but there are so many degrees of freedom in how it is done that I can never remember it all. This is a perfect time for a visual language.
- reshie 6y agothere is winff(not sure of its state today) its totally just a gui frontend even shows you it working in console for an example of something already written. scripting can help with more complicated operations but just for common shorthand there are aliases which can be written out scripts single command lines and pointing to script files.
- iso1210 6y agoI use ffmpeg not infrequently, but rarely to do the same thing, so automation doesn't help. Knowing how filter chains work and having access to the filter documentation is great.
- gifnamething 6y agoWell there are video editing GUIs, even straightforward ones. But they'll have footguns and surprising behaviour everywhere. Lossy or compressed video is a hard problem.
- eikenberry 6y agoThis really depends a lot on the quality of the GUI and the documentation. IMO the best option is the best of both worlds. A GUI that outputs the CLI command along with good documentation would be ideal.
- tialaramex 6y agoThere's a continuum, and yes that applies to human languages, both natural and constructed, and to other skills. But where you can choose (so, not natural languages really) you can design things to make this easier, or, I guess, harder. For example English orthography is a horrible mess. The inventory of squiggles needed to write English isn't too bad, but the correspondence between the words you know and the correct sequence of squiggles to write them is unnecessarily complicated. No benefit accrues to us from this, and in some other written languages it's much easier. I'd place ffmpeg somewhere in the not-bad but not-great part of the continuum. As with English orthography of course the problem is if you change things with the intent to make them better you actually introduce a cost for existing users which may be impossible to sustain.
- inopinatus 6y agoYou don’t lose it completely. It rusts over, but I had occasion recently to resurrect my 6502 assembler, and it was still in muscle memory. Kinda like running into an old friend you haven’t seen in decades.
- Const-me 6y ago> wouldn't that apply to anything you don't use regularly? Doesn't apply to well-designed GUI programs. In good GUIs features are discoverable, you don't need prior knowledge or documentation to use software. Experience speeds things up, e.g. keyboard shortcuts are faster than menus or buttons. That's optional though, one can still use the software without these shortcuts.
- amelius 6y agoI just grep through my bash history ;)
- lgeorget 6y agoI have a $HOME/bin folder full of bash scripts invoking imagemagick or ffmpeg one liners.
- Xangria 6y agocare to share? :D
- lgeorget 6y agoThis one for instance to grab my desktop quickly without starting another program when I want to make a quick demo for a colleague: #!/bin/bash size=${1:-"1920x1080"} offset=${2:-"0,0"} name=${3:-"video"} ffmpeg -video_size $size -framerate 25 -f x11grab -i :0.0+$offset -c:v libx264 -crf 0 -preset ultrafast "$name.mkv" ffmpeg -i "$name.mkv" -movflags faststart -pix_fmt yuv420p "$name.mp4"
- lmohseni 6y agoOne handy idiom I like to use after typing out a long command that I might want to save is echo ‘!!’ > ~/bin/name-of-script where !! is the previous command
- asicsp 6y agoI have shortcuts to save last (sl) executed command and another to grep that file. alias sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt' alias slg='< ~/.saved_commands.txt grep' You can also add a comment to the command before saving. For ex: $ foo_cmd args #this command does this awesome thing $ sl
- deleted 6y ago[deleted]
- neltnerb 6y agoI remember when mencoder wasn't just a frontend for ffmpeg, I literally just saved a text file with the ridiculous command required to convert a DVD to an avi. Their man page even had a like three line long example for basic stuff. ffmpeg is at least a bit more consistent with syntax though only barely!
- molticrystal 6y agoI never had to use it since I never had anything complicated enough, but next time you relearn things, I've heard good things about ffmpeg-python [0] , it supports multiple inputs, outputs, custom filters, etc. Their example from the readme: ffmpeg -i input.mp4 -i overlay.png -filter_complex "[0]trim=start_frame=10:end_frame=20[v0];\ [0]trim=start_frame=30:end_frame=40[v1];[v0][v1]concat=n=2[v2];[1]hflip[v3];\ [v2][v3]overlay=eof_action=repeat[v4];[v4]drawbox=50:50:120:120:red:t=5[v5]"\ -map [v5] output.mp4 Which turns into import ffmpeg in_file = ffmpeg.input('input.mp4') overlay_file = ffmpeg.input('overlay.png') ( ffmpeg .concat( in_file.trim(start_frame=10, end_frame=20), in_file.trim(start_frame=30, end_frame=40), ) .overlay(overlay_file.hflip()) .drawbox(50, 50, 120, 120, color='red', thickness=5) .output('out.mp4') .run() ) [0] https://github.com/kkroening/ffmpeg-python https://github.com/kkroening/ffmpeg-python
- magicalhippo 6y agoAt this point I'd prefer it if ffmpeg included Lua and allowed you to pass Lua scripts, kinda like what ZFS did[1]. [1]: https://zfsonlinux.org/manpages/0.8.3/man8/zfs-program.8.html https://zfsonlinux.org/manpages/0.8.3/man8/zfs-program.8.htm...
- 91aintprime 6y agoI feel like it's better to embed the tool in a language, or many community supported languages than embed a programming language in the tool.
- magicalhippo 6y agoMy feeling is that they're already there with the command line (just look at the filter stuff). Might as well just go all the way and have something sane that's supported all over.
- zdw 6y agoPer the docs on zfs program: The entire script is executed atomically, with no other administrative operations taking effect concurrently. Which would be somewhat hard to ensure with an external language.
- regus 6y ago> My relation with it is almost identical to my relation with any bash scripting more than a one-liner: I have to relearn it every time I want to engage with it. This is how I feel about jq, every time I want to parse some JSON I have to re-read their documentation. Their API is not very intuitive (at least to me).
- IA21 6y ago> I have to relearn it every time I want to engage with it That's my relation with regex.
- laichzeit0 6y agoI’ve heard this a few times. I’m the opposite, I think I learned it once and never forgot it, it seems impossible. Do you understand regex in terms of a state machine? Draw it out. It’s a very simple language.
- IA21 6y agoIts the syntax, not the idea that I forget. I use it rarely which is why I have to relearn from some cheat sheet what each symbol means.