Video & audio desync in homebrew video players


Joined
Oct 20, 2026
Messages
10
I'm running Open2X DR7 on my F200 with an SDHC card plugged in. I'm encoding videos to be played on the GP2X using this tool on the file archive. I've tried four different video players:
For the first 3, the audio seems to run just a little bit faster than the video, enough that over time you can hear dialogue before that part in the video is reached. You can reset this by pausing and unpausing; the video and audio come back in sync then, but drift away again over time. I've tried encoding as both XviD and AVC and both have this issue.

The only player that works perfectly fine is the player within the compatibility environment. I don't mind this all too much, but it would definitely be nicer to not have to rely on it. I haven't heard of anyone with this issue anywhere else on these forums, so I'm hoping it can be fixed.
 
The software has to be updated at many points.

I'm recording sometimes videos and resize them to watch later on GP2X, the best, that's working for me, is matroshka format. It can be easily converted to avi. Sometimes the desync comes just while recording (recording program notices it), then the delayis are coming in the converted video as well. For the most time the recorded video is fine, so is the converted one.

Why do you use mencoder? What Linux Distro do you use on your main PC?

And how long are the videos, that you are watching? Mine are just about 20 minutes, maybe they are to short to notice anything. :eek:
 
I haven't yet tried recording any videos to play on the GP2X, I've been putting episodes of TV shows on. Those are also around 20 minutes and originally in MKV format. I used mencoder via reencode because I was having trouble making video show up myself when writing up commands manually in FFmpeg, though honestly looking at the script's source code now I could probably do that now. I know the desync issue is not with the video itself because it'll play fine on my laptop (and on GPH's MPlayer).

I'm using Arch Linux, but I don't think that should affect things, mencoder should run the same on anything. My best guess is that maybe the resulting video could be compressed a bit more or something. I'll try messing around with FFmpeg more to try tweaking the output parameters, maybe it'll help.
 
I'm just wondering, that you have access to mencode, it is deleted out of the Debian repositories. I was pretty surprised, as i saw, that my resizing script for mencode did'nt work, after i upgraded my linux mint distro XD

here is my short bash script for resizing videos with FFMPEG:

ffmpeg -i "Path_To_Your_Video" -f avi -vcodec libxvid -b:v 300k -s 320x240 -r 30 -acodec mp3 -ar 44100 -b:a 128k -ac 2 -async 44100 "Output_File"

Still figuring out, how to write a whole script for resizing more than one video at a time ^^"
 
Ooh I didn't know it wasn't in the Debian repos. I guess it makes sense, this is the first time I'm ever having to use it. I'm gonna try your script when I'm home, hopefully it'll do the trick!

I don't know of any way to convert multiple videos than a simple loop, but here's a quick script that should work, I was a bit lazy so the only supported inputs are individual files or globs and the only way to edit params is with shell variables

Bash:
#!/bin/bash

: "${FORMAT:=avi}"
: "${VID_CODEC:=libxvid}"
: "${AUD_CODEC:=mp3}"
: "${VID_BITRATE:=300k}"
: "${AUD_BITRATE:=128k}"
: "${VID_FPS:=30}"
: "${AUD_SAMPLE_HZ:=44100}"
: "${AUD_CHANNELS:=2}"
: "${VID_SCALE:=320x240}"

FFMPEG_ARGS=(
    -f "$FORMAT"
    -vcodec "$VID_CODEC"
    -acodec "$AUD_CODEC"
    -b:v "$VID_BITRATE"
    -b:a "$AUD_BITRATE"
    -r "$VID_FPS"
    -ar "$AUD_SAMPLE_HZ" -async "$AUD_SAMPLE_HZ"
    -ac "$AUD_CHANNELS"
    -s "$VID_SCALE"
)

print_usage() {
    echo "Usage: ${0##*/} in-files/dirs out-dir"
    echo "Modify output parameters by changing the following values:"
    echo "    FORMAT (currently set to: $FORMAT)"
    echo "    VID_CODEC (currently set to: $VID_CODEC)"
    echo "    AUD_CODEC (currently set to: $AUD_CODEC)"
    echo "    VID_BITRATE (currently set to: $VID_BITRATE)"
    echo "    AUD_BITRATE (currently set to: $AUD_BITRATE)"
    echo "    VID_FPS (currently set to: $VID_FPS)"
    echo "    AUD_SAMPLE_HZ (currently set to: $AUD_SAMPLE_HZ)"
    echo "    AUD_CHANNELS (currently set to: $AUD_CHANNELS)"
    echo "    VID_SCALE (currently set to: $VID_SCALE)"
}

[ "$#" -lt 2 ] && {
    print_usage
    exit 1
}

OUT_DIR="${@: -1}"
mkdir -p "$OUT_DIR"

while [ "$#" -gt 1 ]; do
    in_file="$1"
    in_base="${in_file##*/}"
    out_base="${in_base%.*}.$FORMAT"
    out_file="$OUT_DIR/$out_base"
 
    ffmpeg -i "$in_file" "${FFMPEG_ARGS[@]}" "$out_file"
    shift
done

Example running would be:

Bash:
./script in1/* in2/*.mp4 in3/foo.mkv out_dir

I also just realized you might mean converting a bunch of videos in parallel. I think you could run each ffmpeg command as a daemon then and just make sure the number of jobs doesn't go over some value like nproc or anything. I'll probably refine this later.
 
Last edited:
Back
Top