8 ms·
I absolutely love ffmpeg, but for the life of me I cannot understand how its pipeline system works. Each time I need to use it, I attempt to construct the comm
by arjvik 4y ago
I absolutely love ffmpeg, but for the life of me I cannot understand how its pipeline system works.
Each time I need to use it, I attempt to construct the command myself, but end up giving up and consulting StackOverflow. Amazingly, someone has usually done the exact thing I need to do and posted their command line to StackOverflow, so I'm never out of luck!
How do I actually start understanding how ffmpeg works? I want to be an ffmpeg power user.
- reidjs 4y agoI’ve never had to directly use ffmpeg. What do you do that makes it so useful to you? Something in video production?
- pmontra 4y agoNot parent but in my case yes, video production: ffmpeg to extract audio from captured video, process audio with Audacity, ffmpeg to cut video and merge it with the audio from Audacity.
- smcnally 4y agoAlso to quickly convert video formats and containers, scale and crop renders, alter speed, make gifs
- mmsimanga 4y agoThis. And imagemagick.
- Macha 4y agoThough I have used ffmpeg on images, too.
- Aperocky 4y agoThe ordering of the arguments changes behavior, I don't think that's a good thing or desired outcome, at most it's a bug_feature. It tend to happen when big project rolls out batteries itself, in this case command line parsing.
- gyan 4y agoThe ffmpeg cli supports multiple inputs and multiple outputs, so there needs to be a way to unambiguously map an option to its target. Position is looked at, to group options for the same target together.
- dylan604 4y agoargument order is definitely a feature. with -ss being one that behaves differently depending on it's location in reference to -i. it's not an accidental thing and the desired outcome dictates where you place it. not understanding that just means you're not using it enough to grok it.
- Aperocky 4y agoOh I used it enough to understand. But I'm not convinced, maybe it is the local optima though.
- geerlingguy 4y agoI wouldn't call myself a power user by any means, but for many parts, the documentation is quite thorough, and if you're wrestling with some specific filter long enough, you might even begin to understand some of the magic incantation required to get it to work. It's helpful to have some background in media container formats, compression algorithms, sound formats, and all the jargon and acronyms associated with the above. Easy!
- xbmcuser 4y agoI know a lot of people look down on ChatGpt. But I have been using it for creating scripts to use with ffmpeg and I was able to get most of the things that I needed with very little massaging required. You can then ask ChatGpt about what it did and why so it will explain it as well so you can get some basic understanding on how things work. People don't realise what kind of tool Chat Gpt is and how to properly utilise it but it can be very useful for stuff like this.
- quijoteuniv 4y agoAgree! I used ChatGPT to explain some (uncommented)ffmpeg scripts I wrote few years ago. Scripts where created by going trough many websites and adapting to my needs. Explanation from chatGPT was spot on.
- nicky0 4y agoYes, chat GPT excels at comprehending and explaining things that have a consistent structure, restructuring, and and synthesising variations. If you keep it in its lane, it’s an excellent tool. It’s really really bad at counting though. For example, try asking it to produce a line of 40 asterisks.
- gamegoblin 4y agoIt’s bad at counting because counting relies on a stateful O(N) algorithm you run in your brain. GPT is trained to reproduce human text, which tends to simply have the output of this O(N) counting process, but not the process itself. So GPT “thinks” it should be able to just spit out the number just like human text implies we do. It doesn’t know we are relying on an offline O(N) algorithm. If you have it emit a numbered list of 40 elements, it will succeed, because producing a numbered list embeds the O(N) process and state into the text, which is the only thing it can see and reason about.
- nicky0 4y agoThat’s very interesting. I assumed it was something about the fact that it is a language model rather than a calculating machine. So printing 44 asterisks instead of 40 is kind of close. I wonder if would it be possible to teach the machine to recognise situations it’s better at and be less confident other answers? Or does it need to be confident about everything in order to produce good answers where it does. It’s kind of funny how confident chatgpt is about giving out bullshit, and then even when you correct it, it says oh I’m terribly sorry, here is definitely the correct answer this time and then it gives you another wrong answer. Just an observation, I realise it is just a tool that you have to understand the limitations of.
- ly3xqhl8g9 4y agoUse ChatGPT, prompt: ffmpeg pipeline capture webcam to mp4 ChatGPT: >>> ffmpeg -f v4l2 -framerate 30 -video_size 640x480 -i /dev/video0 -c:v libx264 -preset veryfast -crf 28 -pix_fmt yuv420p output.mp4 Here's a brief explanation of what each part of the command does: - `f v4l2`: specifies that the input device is a V4L2 (Video for Linux 2) device, which is typically what webcams use. - `framerate 30`: sets the framerate to 30 frames per second. - `video_size 640x480`: sets the video resolution to 640x480 pixels. You can adjust this to your desired resolution. - `i /dev/video0``: specifies the input device to use, which is typically /dev/video0 for the first connected webcam. If you have multiple webcams, you may need to adjust this to the appropriate device. - `c:v libx264``: sets the video codec to use, which is H.264 in this case. - `preset veryfast``: sets the encoding speed preset to "veryfast", which is a good balance between speed and quality. - `crf 28`: sets the video quality using the Constant Rate Factor (CRF) method, with a value of 28. Lower values mean higher quality and larger file sizes, while higher values mean lower quality and smaller file sizes. You can adjust this to your desired quality/file size. - `pix_fmt yuv420p``: sets the pixel format to YUV 4:2:0, which is a commonly used format for H.264 video. - `output.mp4`: specifies the output file name and format. <<< Never used the `crf` or `pix_fmt` flags personally, but seems correct (the issue with ChatGPT).
- ttflee 4y agoYou need `-pix_fmt yuv420p` for an iPhone to recognize a ffmpeg-encoded video file.
- djkoolaide 4y agoand if you're encoding an x265 file, it needs -tag:v hvc1 for iphone/quicktime to recognize it.
- jeroenhd 4y agoDo you happen to know why? Is this a hardware decode limitation perhaps, or a bug in the standard decoder?
- 4y ago
- deleted 4y ago[deleted]
- oldstrangers 4y agoHave you tried https://handbrake.fr/ https://handbrake.fr/?
- asicsp 4y agoCheck out https://ffmpeg.guide/ https://ffmpeg.guide/ (https://news.ycombinator.com/item?id=33383023 https://news.ycombinator.com/item?id=33383023) See also https://img.ly/blog/ultimate-guide-to-ffmpeg/ https://img.ly/blog/ultimate-guide-to-ffmpeg/ (https://news.ycombinator.com/item?id=33771445 https://news.ycombinator.com/item?id=33771445)
- pjc50 4y agoI was looking for ffmpeg.guide the other day and couldn't remember what it was called, thanks!
- orbisvicis 4y agoEven given an option it can be difficult to find the corresponding documentation, if only because of the many different submodules and encoders and decoders and filters that have oh-so-slightly different options. That said, I've just switched from pydub to ffmpeg-python (due to memory issues of the former[1]) and judging from the Jupyter notebook[2] it seems a much more intuitive method of constructing ffmpeg pipelines. [1] https://github.com/jiaaro/pydub/issues/135 https://github.com/jiaaro/pydub/issues/135 [2] https://github.com/kkroening/ffmpeg-python/tree/master/examples https://github.com/kkroening/ffmpeg-python/tree/master/examp...
- ovi256 4y agoI think the only hope a mortal brain has is using a graphic tool to build ffmpeg command lines like https://ffmpeg.guide/ https://ffmpeg.guide/
- zimmund 4y agoThe manpages are good! I don't use ffmpeg too frequently so, to help myself, I made a cheatsheet (which I update whenever I do something new) https://github.com/elamperti/dotfiles/blob/master/docs/ffmpeg-tricks.md https://github.com/elamperti/dotfiles/blob/master/docs/ffmpe...
- rollcat 4y agoI know this doesn't answer your question, but have a look at GStreamer pipelines. They take the basic idea of shell pipelines, but add typing, format negotiation, M:N connections, etc all while giving you optional control over low-level details (which demuxer?), but also high-level abstractions (just show me a window with a preview). Once prototyped on the CLI (gst-launch-1.0[1]), they're also very easy to start using within an application through the framework (gst_parse_launch[2]), where you can e.g. iteratively add things like a volume slider. You can also access most of FFmpeg's codecs through libav. [1]: https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c#gstlaunch10 https://gstreamer.freedesktop.org/documentation/tutorials/ba... [2]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstparse.html?gi-language=c#gst_parse_launch https://gstreamer.freedesktop.org/documentation/gstreamer/gs...
- devwastaken 4y agoI've been trying to get color space and bit conversion to work with png's and bt2020 video. Apparently any time I use a png with ffmpeg's avif encoder it comes out too bright.
- dylan604 4y agoIf you don't use it every day, then this will be the typical result. But that can be said about anything, not specific to ffmpeg. Practice, practice, practice. Eventually, you'll start thinking like ffmpeg. Knowing how ffmpeg labels the various streams inside a file is a great place to start. For example [0:a:1] means the second audio stream inside the first input. This is key for stringing together complex filter chains in the appropriately named -filter_complex. There are some filters that require you to merge streams together so the processing is done evenly, followed by a split to get back to the original stream layout. amerge/channelsplit is a common combo in most of my commands.