master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.51k stars 155 forks source link

Remove audio before running scenedetect. #184

Closed nathanielcwm closed 3 years ago

nathanielcwm commented 4 years ago

Scenedetect doesn't support files with multiple audio tracks.

This error is also only visible when scenedetect is run directly as through av1an the only indicator given is that in the log where it states that it found 0 scenes.

Pyscenedetect Log:

scenedetect -i Nichijou_D1_t15.mkv  detect-content list-scenes
[PySceneDetect] Loaded 1 video, framerate: 23.98 FPS, resolution: 1920 x 1080
[PySceneDetect] Downscale factor set to 6, effective resolution: 320 x 180
[PySceneDetect] Scene list CSV file name format:
  $VIDEO_NAME-Scenes.csv
[PySceneDetect] Detecting scenes...
  0%|                                                                                                                          | 0/240 [00:00<?, ?frames/s]
[PySceneDetect] Failed to read any frames from video file. This could be caused by the video having multiple audio tracks. If so, please try removing the audio tracks or muxing to mkv via:      ffmpeg -i input.mp4 -c copy -an output.mp4or:      mkvmerge -o output.mkv input.mp4 For details, see https://pyscenedetect.readthedocs.io/en/latest/faq/

Av1an Console:

av1an -i "Nichijou_D1_t15.mkv" -fmt yuv420p10le -a "-c:a libopus -b:a 128k -af aformat=channel_layouts='7.1|5.1|stereo' -sn" --vmaf_target 95 --min_q 10 --max_q 50 -v "--threads=2 --cpu-used=4 --lag-in-frames=25 --enable-cdef=0 --enable-keyframe-filtering=2 --deltaq-mode=1 --aq-mode=0 --enable-fwd-kf=1 --end-usage=q --cq-level=22" --vmaf --mkvmerge --force
WARNING: Invalid params:
'--enable-keyframe-filtering' isn't a valid param for aom. Did you mean '--enable-keyframe-filterin'?
  0%|                                                                                                                          | 0/240 [00:00<?, ?frames/s]
Queue: 0 Workers: 0 Passes: 2
Params: --threads=2 --cpu-used=4 --lag-in-frames=25 --enable-cdef=0 --enable-keyframe-filtering=2 --deltaq-mode=1 --aq-mode=0 --enable-fwd-kf=1 --end-usage=q --cq-level=22
  0%|                                                                                                                              | 0/240 [00:00<?, ?fr/s]
Concatenation failed, error
At line: 25
Error:list index out of range

Av1an Log: log.log

master-of-zen commented 4 years ago

@nathanielcwm can you provide minimal file that errors out?

nathanielcwm commented 4 years ago

I believe this should be able to trigger it: Nichijou_D1_t15.zip

nathanielcwm commented 4 years ago

On my end I can confirm that it encodes & splits fine when I remove the audio tracks from the file beforehand.

adworacz commented 4 years ago

Not that this is a perfect fix, but as a work around you can use the new Vapoursynth support and feed your input in via a Vapoursynth script. There's no audio exposed in that mode (not yet anyways, Vapoursynth is working on audio support in the future), so it would get you off the ground.

Edit: Just thought of this... if we really want to get fancy, we can strip out the audio and pipe the video using the same method I added for Vapoursynth. Effectively use ffmpeg to feed the yuv4mpeg data via a named pipe, and point PySceneDetect at that. Would need to pass it the number of frames though.

nathanielcwm commented 4 years ago

How would I do that?

On 10/29/20, Austin Dworaczyk Wiltshire notifications@github.com wrote:

Not that this is a perfect fix, but as a work around you can use the new Vapoursynth support and feed your input in via a Vapoursynth script. There's no audio exposed in that mode (not yet anyways, Vapoursynth is working on audio support in the future), so it would get you off the ground.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/master-of-zen/Av1an/issues/184#issuecomment-718358582

master-of-zen commented 4 years ago

@nathanielcwm I would recommend use aom_keyframes for now on, it's quite fast

adworacz commented 4 years ago

Sorry, been busy of late.

To answer your question @nathanielcwm - you'll need to have Vapoursynth installed, as well as it's L-SMASH or FFMS2 source plugins.

Then you can write a script like the following, and feed that to av1an:

# save this as something like 'script.vpy'
import vapoursynth as vs
core = vs.core

source = core.lsmas.LWLibavSource(r"/path/to/your/file.mkv")
#Alternative
#source = core.ffms2.Source(r"/path/to/your/file.mkv")

source.set_output()

Or you can try using aom_keyframes as @master-of-zen recommends. Note though - you'll likely want to use the latest version of the aom encoder from git, since there's a massive performance speedup when using the git version vs the last release (2.0 or whatever).

salarx commented 4 years ago

@adworacz can you tell the parameter used to feed vpy script to av1an? It's not mentioned anywhere.

adworacz commented 3 years ago

It's the same source parameter as a video file, so av1an -i myscript.vpy will work. Note that if you're using 10-bit output from the Vapoursynth script, you'll likely want to set the pix_fmt parameter to match appropriately.

master-of-zen commented 3 years ago

That's not an issue anymore, as there is no more pyscenedetect