Core-2-Extreme / Video_player_for_3DS

Video player for 3ds
https://gbatemp.net/threads/release-video-player-for-3ds.586094
GNU General Public License v3.0
181 stars 17 forks source link

Hardware Decoder data copy spikes desyncs the video? #16

Closed moisespr123 closed 1 year ago

moisespr123 commented 3 years ago

Hi,

I know the hardware decoder is in beta. It does seem it is able to provide better and accurate colors like better blacks and overall details. The problem is that the audio/video is not synched and every few seconds, the graph from the Y button reports a spike that causes the video to sync/desync/skip frame? Not really sure how to describe it. This issue does not happen on the software decoder.

Right now my solution is to encode videos to 240p and use the software decoder which plays it smoothly. However, the hardware decoder seem to do a better job at handling colors but with this tiny issue.

Not sure how easy it is to fix it, but wanted to let you know.

This is the command line I'm using to encode my videos using ffmpeg:

ffmpeg -c:v h264_cuvid -i {h264_input_video} -c:v h264_nvenc -preset slow -c:a libfdk_aac -b:v 1M -b:a 256K -ac 2 -vf scale=-1:240 {h264_output_video}
Core-2-Extreme commented 3 years ago

Could you send me screenshot of graph that shows spike?

moisespr123 commented 3 years ago

Here is playing the video in HW decoder mode. The video skips frames on those spikes. This happens periodically (maybe it's related to the buffers?)

20210725_081842.jpg

Here's the graph when playing in SW decoder mode. The video plays very smoothly.

20210725_081755.jpg

Core-2-Extreme commented 3 years ago

Hmm, can you see spike only in blue line not red line?

moisespr123 commented 3 years ago

Hmm, can you see spike only in blue line not red line?

Is there a way to filter the line? The issue just happen in the HW decoder blue line spikes. The red line doesn't seem to matter. In the SW decoder you can see the blue line is very smooth so playback is actually good.

Core-2-Extreme commented 3 years ago

There is no way to filter the line. ok, I'll try to fix it.

Core-2-Extreme commented 3 years ago

I can't use nvidia GPU right now so I couldn't encode video using command that you provide. However, I found that if I encode video following command, the video won't play smoothly in hardware decoding (plays smoothly in software decoding). ffmpeg -i {input} -c:v libx264 -preset slow -c:a aac -b:v 1M -b:a 256K -ac 2 -s 426x240 {output}

I also found if I encode video following command, the video play smoothly in hardware and software decoding. ffmpeg -i {input} -c:v h264_mf -preset slow -c:a aac -b:v 1M -b:a 256K -ac 2 -s 426x240 {output}

To investigate more, could you send me sample video that encoded by h264_nvenc?

FoxbitDreamtail commented 3 years ago

How do you switch to software mode on a new Nintendo 3DS?

Core-2-Extreme commented 3 years ago

00000034 Use blue one.

FoxbitDreamtail commented 3 years ago

oki thx

FoxbitDreamtail commented 3 years ago

what if you take a look at thirdtube's code?

Core-2-Extreme commented 2 years ago

Workaround : encode your video without using B-frames.

ffmpeg -i {input_file_name} -acodec copy -vcodec h264 -crf 20 -s {width}x{height} -bf 0 {output_file_name}

moisespr123 commented 2 years ago

Hi,

Thanks for the workaround. I ended up using -bf 0 as I couldn't find an equivalent for NVidia's h264_nvenc encoder. It seems -bf is ffmpeg's generic argument to specify B-Frames and it seems to have fixed the issue entirely.

My command now looks like this:

ffmpeg -i {input} -c:v h264_nvenc -preset slow -c:a libfdk_aac -b:a 256K -af "volume=4" -bf 0 -g 48 -ac 2 {output}

The video files are encoded and plays back fine.

Other unrelated issues I found to this one is that the audio only works if it's 2-channel, hence the -ac 2 argument. And also, for some strange issue, the video/audio desyncs after a while. It is mostly noticeable when people are talking. Seeking fixes it temporarily but the issue happens again after a while. I'll open a new issue for this.

Core-2-Extreme commented 2 years ago

Thank you fore telling me, I updated command line.

Core-2-Extreme commented 1 year ago

Hardware decoder bug has been fixed in v1.5.2.