Video_player_for_3DS icon indicating copy to clipboard operation
Video_player_for_3DS copied to clipboard

Hardware Decoder data copy spikes desyncs the video?

Open moisespr123 opened this issue 3 years ago • 13 comments

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}

moisespr123 avatar Jul 24 '21 14:07 moisespr123

Could you send me screenshot of graph that shows spike?

Core-2-Extreme avatar Jul 25 '21 07:07 Core-2-Extreme

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

moisespr123 avatar Jul 25 '21 12:07 moisespr123

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

Core-2-Extreme avatar Jul 25 '21 14:07 Core-2-Extreme

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.

moisespr123 avatar Jul 25 '21 14:07 moisespr123

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

Core-2-Extreme avatar Jul 25 '21 23:07 Core-2-Extreme

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?

Core-2-Extreme avatar Jul 28 '21 13:07 Core-2-Extreme

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

FoxbitDreamtail avatar Aug 04 '21 20:08 FoxbitDreamtail

00000034 Use blue one.

Core-2-Extreme avatar Aug 04 '21 23:08 Core-2-Extreme

oki thx

FoxbitDreamtail avatar Aug 05 '21 01:08 FoxbitDreamtail

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

FoxbitDreamtail avatar Aug 11 '21 20:08 FoxbitDreamtail

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}

Core-2-Extreme avatar Oct 11 '21 10:10 Core-2-Extreme

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.

moisespr123 avatar Dec 22 '21 23:12 moisespr123

Thank you fore telling me, I updated command line.

Core-2-Extreme avatar Dec 25 '21 09:12 Core-2-Extreme

Hardware decoder bug has been fixed in v1.5.2.

Core-2-Extreme avatar Nov 06 '22 04:11 Core-2-Extreme