Hacker News new | past | comments | ask | show | jobs | submit login
An ffmpeg and SDL Tutorial (2015) (dranger.com)
102 points by swyx on Oct 30, 2022 | hide | past | favorite | 20 comments



This tutorial is very outdated, eg. `AVPicture`, which is used throughout, is completely deprecated and removed from the library, so you will simply encounter linker errors trying to follow this tutorial and will have to replace every `avpicture` call made in the tutorial. Also, `avcodec_decode_video2` is deprecated and you have to use `avcodec_send_packet` and `avcodec_receive_frame`.

The FFmpeg libraries are possibly the worst thing I have ever worked with in my life. I have never been more afraid to use a library than this. FFmpeg libraries randomly break themselves, so if you find an answer from a few years ago, chances are it's useless. Want to free an AVPacket? `av_free_packet` is deprecated,. You can use `av_packet_unref` (but there's _also_ a function named `av_packet_free` that doesn't do quite the same thing).

Most questions on Stack Overflow or related platforms have no replies, the library is not well-documented (requiring you to always read the massive source code and the API reference). In addition, some things are outright undocumented and missing from the API reference or documentation and require reading often-unfinished conversations on the mailing lists with no solution. The FFmpeg libraries have very little error handling, which means if you're a bad C developer like me you are required to recompile FFmpeg with debugging information unstripped so you can trace segfaults in gdb.

https://github.com/leandromoreira/ffmpeg-libav-tutorial/ is a better and more up-to-date tutorial than this one.


For the last point: Most distros have some way to get debug symbols. On Ubuntu for example, you add some repos and install -dbgsym packages (documented in https://wiki.ubuntu.com/Debug%20Symbol%20Packages).


Yes, ffmpeg is one hell of a library and documentation doesn't make things easier. You have to ask a lot of questions to understand the low level details, and also have to answer them yourself by doing experiments.

For the point about packet freeing, i think ``av_packet_unref`` is supposed to de-reference the ``encoded video/audio`` data being read in the RAM, so that internal ffmpeg code can deallocate it. It has to be called for every ``av_read_frame``. ``av_packet_free`` is supposed to release the generic ``packet`` object/struct allocated by ``av_packet_alloc``. I learnt this while making a simple video player based on ffmpeg library.


ah thanks.. was trying to learn ffmpeg last night and the old tutorial was the best i found.. appreciate any and all links and resources


as the old saying goes... the best way to get a correct answer on the internet is not to ask a question but to post an incorrect answer on the internet. it's fine you opened up the discussion for everyone to see this much more well written resource.


yeah ive definitely internalized that one https://www.swyx.io/learn-in-public/


somewhat related: https://ffmpeg.guide


I guess it was that, which triggered this (I saw your link posted yesterday).

I'm curious, how accurate/ useful is this 2015 guide today, Vs the newer (?) one you linked (which is also very cool too!).

Having been watching various media related YouTube videos lately, in wondering whether to jump on the AV1 bandwagon for encoding all of my family videos.

Currently I'm using H264/MP4 in 4K, my kids are only 1 and 3yo and I already have a couple of terabytes of video, not to mention all of the photos.


and the comments from when it was submitted yesterday: https://news.ycombinator.com/item?id=33383023


FFmpeg is definitely in one of the lowest circles of Hell.

I did figure out the very simple switches to convert WAV to FLAC. Mercifully I don't need it for anything else (yet).


Isn't that just `ffmpeg -i myfile.wav convertedfile.flac`? That's how all other video/audio file format conversion options work at least.


Indeed. Once you ignore all the other bazillion things you can do, you attain bliss.


That simple use case is literally the first piece of code on the home page of the ffmpeg website haha you don't really have to ignore anything


That must be what happened, then :)

Of course, you still have this morbid curiosity: "Is that it? What am I not seeing?"

Then you shudder and close the page.


So it isn't just me then! There was this one time, I downloaded a piece of porn in h.265 .mkv and I wanted to change its container to mp4 using ffmpeg(so that I could view it on iPad), and I actually, actually got pissed. In the end I just re-encoded the whole thing using Handbrake. The documentation does not explain its syntax.


It can be complex, but given what it's capable of doing and how well it does it, I'd put it in purgatory at worst.


Awesome but if you want to inject some fun into your day, somewhat related

https://youtu.be/9kaIXkImCAM


>At its very *basic* level, dealing with video and audio streams is very easy:

Then proceeds to use a pseudocode that looks like BASIC. Tasteful.


Should have a (2015) tag.


Also because since 2015 there have been some API changes so some of the content/code in there might not work out of the box.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: