fsphil / hacktv

Analogue TV transmitter for the HackRF
GNU General Public License v3.0
713 stars 84 forks source link

Video/audio "lag" #10

Closed amdorj closed 5 years ago

amdorj commented 6 years ago

While playing NTSC video through the HackTV, the video "lags" behind the audio by an increasing amount as the video is playing. Not sure if it is a FFmpeg problem, computer problem, PEBKAC, or just a problem with my particular HackRF. Unfortunately, I have no experience coding, so I can't really help, sorry. But thanks for having a wonderful "turn-key" solution; it is nice to find a use for that old GoldStar.

fsphil commented 6 years ago

hacktv currently assumes the video's frame rate matches the TV format. Playing a 30fps video on a PAL mode will cause the video to slow down to 25fps, but the audio still plays at normal speed. So it's my fault :-)

I have a fix for this but it's not quite ready.

amdorj commented 6 years ago

Temporary stop-gap is to "match" the frame rate outside of hacktv before transmitting. You can do this with ffmpeg: ffmpeg -y -r <input fps> -i <input file> -r <output fps> <output file> This command either duplicates or drops frames to match the framerate.

Find the original frame rate by doing ffmpeg -i <input file> and find this line: Stream #0... ...592 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) For this file it was 25 fps.

Haven't tested playback via HTV yet, but if It works I'll let you know (maybe put it in the README? ;) ).

Edit: It works!

fsphil commented 5 years ago

I've just pushed 87c0c8b2d9352352afaa559e0bb84062ffe72f60 which should solve this issue. The AV should remain in sync even with a mismatched frame rate. Hopefully it hasn't introduced new bugs, let me know how it goes.