▲ 12 r/ffmpeg

H264: How can I limit the maximum size of an I-frame?

I've been working diligently on a custom video converter for an MP3 player. It required some special x264 patches to basically disable reference P-frames and swap to disposable P-frames only, as well as disabling the VUI and some SPS units (?), and a chroma tint fix. Now, I've got it down to a science, but there's one last tricky limitation I'd like to optimize.

The device's decoder chokes under 2 conditions: the total bitrate exceeds 15-20 Mbps (which will never happen), or the size of an I-frame exceeds ~44Kb.

Unfortunately, I don't think x264 or ffmpeg have a mechanism to specifically limit a single frame size. There's a max slice size, but that doesn't work because it's not granular enough, so big frames still go through. The obvious idea is a VBV, but the VBV's sampling window would need to literally be equal to per-frame timing, which I've also tried but remember that it never actually fixed the crash, big I-frames made it through.

The current solution I had was to encode the most tortuous, noisiest source videos and determine the minimum qmin I could use to prevent an I-frame overflow crash. That ended up being qmin 20. While this works, it also means that I'm losing encoding efficiency. Flat, gradient areas need that lower quantization to look clean without banding, but if I drop qmin, a torturous scene could spike an I-frame past the limit.

The last option I came up with was once again patching x264 in ratecontrol.c to bump qmin if a frame is too big, a simple in-line loop. But when it comes to patching and writing C, I'm pretty useless; my previous x264 patches were only really made possible through Cursor (albeit, the research and refinement took months to do, so it wasn't just Cursor).

So my question is, can anyone come up with a way to limit a single I-frame's size during an encode, without needing to encode, check, re-encode, etc? Thank you

reddit.com
u/AimlessForNow — 6 days ago

Been working on this for a while

TLDR

In short, this is an AGPTEK M6 MP3 player that I loaded up with several thousand media files onto a 1 TB microSD card. I did this because I wanted a way to consume my media offline, not just leasing it from a service, and modern phones have removed the microSD card slot and the AUX port.

Contents of SD card

[Disclaimer: I realize that I probably will never go through all of this content. But the idea is that I'd like to not be so dependent on streaming services to get all of my entertainment.]

  • South Park S00-S28 w/ movies
  • Squatters E01-E04
  • Simpsons S00-S30 w/ movies
  • Myth Busters 2003-2016
  • It's Always Sunny S01-S14
  • The last 5 videos from each of my ~550 YouTube subscriptions
  • The same thing as above, but just the audio portion (for screen-off listening)
  • All of my music
  • Tens of thousands of stories from r/nosleep (they are not great quality...)
  • A handful of real E-books
  • Some cute pictures of my dog

Challenges with this project

The last couple months have been a long journey to getting what I wanted from this player. Each component was it's own project, and I learned a lot.

  • Getting videos to play: This player comes with some software for converting videos. Unfortunately, videos converted manually using tools like ffmpeg were unsuccessful, as the device refused to play them. This was probably the most difficult problem to solve. At first glace, it would seem like I just had a few settings wrong, here and there. That was absolutely not the case. The truth was that this player advertised (or at least plays) H.264 videos, but it's implementation was so restrictive, it is more similar to MJPEG than true H.264. I had to patch (with the help of Cursor) libx264 and recompile ffmpeg around it. If anyone wants the full details of what needed to be patched, let me know and I will write a reply, but it is lengthy.
  • Getting the videos to not be enormous: After finally getting videos to play, I realized that due to the strict restrictions around the device's video decoder, we are losing a lot of compression efficiency. This means that the videos need a very high bitrate to look acceptable, and thus a large file size. This led me to learning about video compression and how I could get the files to be even smaller. It boiled down to making incremental optimizations, which allowed me to crank the compression further without as much quality loss. I got the videos from ~2.2 Mbps all the way down to ~500 kbps. Essentially, I cut the video size down by roughly 80%. A 1 hour clip used to be around 1 GB in file size, and it is now around 200 Mb. I did take some liberties when compressing the video. I realized that I didn't need it to look perfect, it just had to look acceptable from a regular viewing distance. As with the audio, I took the same principles. If you look closely at the video, or even just at a regular distance, there are noticeable artifacts due to the strong compression. However, I decided that I was fine with making that trade-off in exchange for more storage capacity.
  • Download -> Convert pipeline: The original goal of this project was to get my latest uploaded YouTube videos from my subscriptions from the last 24 hours, and send them to the device for offline playback. I wrote a program to perform the downloading, extracting, and converting for every single file format that the device supports: videos, audio, images, and text. Then, I wrote another program to hook it up to, which downloads my videos and then converts them to the perfect format for my devices. I set up a way for GitHub to automatically do this for me; all I'd have to do was transfer the files to my device.
  • Deciphering MP3 player video formats: After figuring out how to make videos play on my device, I got curious about how other devices worked. I purchased a large quantity of devices, including MP3 players, MP4 players, handheld game consoles, dumbphones (r/dumphone), essentially, any device that could play videos that was not a smart device. I made sure to create converters for each device profile (some were identical, but there are ~19 profiles now, meaning that each profile requires a unique conversion to work), and uploaded them to my project.

Thoughts

Overall, this project was extremely educational for me. Part of me feels like I wasted money purchasing so many devices, just to reverse engineer them and put them away. Thankfully, each device costed no more than $18, and most were in the $10 or less range. I may be able to repurpose or gift some of these devices. I also recognize that perhaps I really do not need this much content. But there is something very attractive about knowing that I own these files now, and I'll have access to them. There won't be any software updates to slow my MP3 player down, there won't be any AI, they won't track all of my behavior with ads and algorithms, and best of all, they won't be able to remove, replace, or otherwise ruin the things I like. There's probably some deep insecurity that compels me to do this type of archiving, but I can't figure it out.

If anyone wants information or has any questions, I would love to answer.

Here's the projects I built for this:

EDIT: also, I could easily make these videos look perfect if I wanted, but it would bloat the file size past what I'd be happy with. Just wanted to say that it's my fault, not the player's.

u/AimlessForNow — 6 days ago

Any issues taking one on a plane?

I'm planning on taking a trip back home for a while and I want to bring one of my dumbphones to watch TV on, since it can use a micro SD card while my phone cannot. But I heard that TSA sometimes mistakes them as a bomb, and I'm already an anxious person, I don't want to stir up any trouble or for them to hassle me.

Those who have taken your dumbphones on a plane trip, did it go fine? Did anyone pull you aside or tell you that you can't bring it?

reddit.com
u/AimlessForNow — 13 days ago
▲ 3 r/sdcard+1 crossposts

Issue with 128GB MicroSD card showing "Empty folder" when ~70% full for some folders but not all?

I've got a bit of a predicament, but I'll try to keep it short and sweet.

I've got 6 MKTEL dumb/feature phones that can accept a microSD card. They advertise 32GB maximum size, but I discovered that they can all read a fully filled 128GB sdcard, so they do technically have the ability to work. However, 3 of the 6 phones seem to have a strange issue with the folders.

These devices can read a fully filled 128GB microSD card with no issues:

  • MKTEL 106
  • MKTEL BOOM 2
  • MKTEL/SONORO 3301-1

These devices can read a fully filled 128GB microSD, but there seems to be some issue related to folders:

  • MKTEL B310
  • MKTEL M2023
  • MKTEL EXO

The issue: when the sdcard is becoming full with TV shows and movies, the device is unable to open some folders. The folders copied over first seem to work just fine. But folders copied over after some threshold seem to throw a "Empty folder" message when I try to open them.

What I've tested:

  • It can read a single folder filled to the maximum capacity with 4GB files
  • Files within a "Empty folder" can be copied to a fresh microSD and are able to be seen by the phones fine
  • It seems unrelated to the length of the filenames
  • It seems unrelated to the actual files themselves
  • It seems unrelated to a format issue (tried FAT32 with larger sector size like 128KB)
  • The device's hardware seem to be able to handle it fine

It's a bit of a technical one, but I'm posting to see if anyone in this community has experiences a similar issue, and if they were able to resolve it or identify the issue. My favorite phones out of the 6 are unfortunately also the failing devices, so I'm testing to see if there's any way I can get this working without needing to reduce the memory card size.

Thank you <3

reddit.com
u/AimlessForNow — 14 days ago

MKTEL Chinese dumbphones &amp; AT&amp;T: should I change the IMEI?

These MKTEL devices allow me to change their IMEI to whatever I want. I assume this is to spoof the IMEI to match one that the carrier supports. In the past, at&t locked my sim if I plugged it into an unsupported/not-whitelisted phone. If I switch the IMEI to match my current smartphone, will that let it work on the network, or are they still going to block my sim?

reddit.com
u/AimlessForNow — 29 days ago

I made a program to generate map directions for MP3 players

You'll need some experience using command line applications to set up the program, but it is really easy. I have a personal objective to see if I could live life comfortably without internet or smart-devices; I know it's not very practical. More of a hobby project. Maybe some of you will find it interesting.

https://github.com/tytydraco/mp3maps

u/AimlessForNow — 30 days ago
▲ 4 r/ffmpeg

[video]: Modern FFMPEG has 40 byte extradata; MP3 player needs legacy 20 byte extradata

I'm dealing with a heavily constrained set of MP3 player devices. This is the basic configuration they need:

- Baseline H264 profile
- AVI container
- PCM_S16LE audio @ 16000HZ or 22050HZ
- VBV buffer size of 2M
- VBV max rate of 2M
- qmin of ~12 (too low = IDR overflow, too high = artifacting)

And the last requirement is, I have to use the manufacturer's ffmpeg.exe that they bundled with their converter program.

If I use the system ffmpeg, the video is recognized (no format error), but playback either doesn't start or immediately starts corrupted (RGB macroblocking, flashing, no audio, no playback).

I discovered that the bundled ffmpeg is running on a custom git branch that roughly correlates to FFMPEG v5.

The only major difference I can see between the system ffmpeg and the bundled ffmpeg is that the system ffmpeg gives a 40 byte extradata header, while the older ffmpeg has a 20 byte extradata header. Most likely, the player was designed around this era of ffmpeg and thus expects a fixed 20 byte header length. When it's off, metadata is read wrong and playback fails.

---

So, I need help with stripping the extradata to the legacy format. So far, I have no leads. I tried a few filters to strip or remove the data entirely, but it just produces the same result. Is there any way (even direct hex editing) that I can get this to work? I don't want to keep using wine just to run ffmpeg for these players. Thank you <3

Edit:
It might be SPS+PPS as well, I'm unsure at this point.

reddit.com
u/AimlessForNow — 1 month ago

AGPTEK M6/M6U Review

Unpaid, no sponsor, etc.

I made this video because there is no documentation about this player online yet. It appears to be relatively new; the firmware on it is from 9/11/2025. I also included some links to tools to convert audio, photos, text, and video for this player in particular, meaning it uses the most optimal, compatible, and quality encoding that it can for the given media.

Hopefully this helps other people find this cool player. If anyone else already has it, let me know what you think of it, I'm curious what you noticed.

youtu.be
u/AimlessForNow — 2 months ago

I made some neat tools for MP3 players!

I recently purchased the AGPTEK M6 MP3 player (excellent, by the way), and I already own a RUIZU X52 as well. These players support some interesting features like video, text, and images, but they require specific encoding to work, otherwise they will show a format error. So I build a couple tools to make it easier to do!

#1: mp3c

mp3c is a device-specific file converter that supports audio, video, images, and text. It will take any format and convert it for each dedicated device profile. For example, the same video can be converted for both players (320x240, and 128x128), with all the necessary rotation and padding done automatically. It can convert e-books and images of any type as well.

#2: ytdlmp3

Similar to the first project, but it's centered around downloading YouTube videos from a certain recent time frame (last 2 weeks) so that you can always get the latest videos for offline YouTube watching/listening.

If you want to use these programs, you might need to build your own converter script in the converters folder. It's easy to do, it's just a simple FFMPEG command and a file extension name. You can make it highly specific to your player to get the best quality.

https://github.com/tytydraco/mp3c
https://github.com/tytydraco/ytdlmp3

These projects are a little technical, so I'm sure most people won't have a good use for this. But if you are experiencing with the command line or Linux, you should have an easy time with this.

A docker file is also included so you can get this up and running on any machine, even Windows and Mac (not tested yet, but theoretically it should work perfectly).

Really enjoying my new player, just wanted to share what I've been working on!

u/AimlessForNow — 2 months ago

I have a RUIZU MP3 player that supports video, and I've gotten the videos to play just fine. The issue is, the black level seems to be messed up. Instead of a black screen, it shows a light gray. The screen itself is crappy but it can display those colors just fine. I can't seem to get that fixed in my FFMPEG command.

Is this normal for these cheap MP3 players, or am I doing something wrong?

reddit.com
u/AimlessForNow — 2 months ago

Hi, I have a RG28XX with the latest ROCKNIX nightly build and the WIFI is not seeing any networks. I know this adapter works because I was using it on Knulli without issue. Just curious if anyone else encountered this and has a solution. Thanks!

reddit.com
u/AimlessForNow — 2 months ago