occivink / mpv-scripts

Various scripts for mpv
The Unlicense
412 stars 38 forks source link

Standard 8-bit H.264 profile #30

Open Naomi010Sentzke opened 4 years ago

Naomi010Sentzke commented 4 years ago

I am trying to make a profile that records a clip in standard 8-bit in a mp4 container and hardsubs the subtitles.

only_active_tracks=yes
preserve_filters=yes
append_filter=
codec= -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a libfdk_aac -b:a 128k
output_format=$f_$n.mp4
output_directory=
detached=yes
ffmpeg_command=ffmpeg
print=yes

Any suggestions ?

occivink commented 4 years ago

So what is the problem?

Naomi010Sentzke commented 4 years ago

It does not work. I set it with Shift+e script-message-to encode set-timestamp encode_custom. I can set the timestamps, but when I press Enter to encode nothing happens unlike encode_slice and encode_webm.

occivink commented 4 years ago

This particular config seems to work for me, can you set detached=no and run mpv from a terminal, so that you see ffmpeg's error output?

Naomi010Sentzke commented 4 years ago

It said failed to encode, check log for details

[  13.444][d][cplayer] Run command: show-text, flags=64, args=[encode [encode_custom]: waiting for end timestamp, 2000, 0]
[  15.445][d][cplayer] Run command: show-text, flags=64, args=[encode [encode_custom]: waiting for end timestamp, 2000, 0]
[  15.571][d][cplayer] Run command: script-binding, flags=73, args=[encode/encode-ENTER]
[  15.571][d][cplayer] Run command: define-section, flags=64, args=[input_encode, , default]
[  15.571][d][cplayer] Run command: enable-section, flags=64, args=[input_encode, allow-hide-cursor+allow-vo-dragging]
[  15.571][d][cplayer] Run command: define-section, flags=64, args=[input_forced_encode, ENTER script-binding encode/encode-ENTER
[  15.571][d][cplayer] , force]
[  15.571][d][cplayer] Run command: enable-section, flags=64, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging]
[  15.571][d][cplayer] Run command: define-section, flags=64, args=[input_encode, , default]
[  15.571][d][cplayer] Run command: enable-section, flags=64, args=[input_encode, allow-hide-cursor+allow-vo-dragging]
[  15.571][d][cplayer] Run command: define-section, flags=64, args=[input_forced_encode, , force]
[  15.572][d][cplayer] Run command: enable-section, flags=64, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging]
[  15.572][d][cplayer] Run command: show-text, flags=64, args=[, 0, 0]
[  15.572][d][cplayer] Run command: show-text, flags=64, args=[Encoding from 00:00.000 to 01:04.314, 2000, 0]
[  15.572][d][encode] reading options for encode_custom 
[  15.576][i][encode] ffmpeg -ss 00:00.000 -i 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv' -to 64.3348541661 -map 0:0 -map 0:1 -map 0:2 -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a libfdk_aac -b:a 128k 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4' 
[  15.576][d][cplayer] Run command: subprocess, flags=64, args=[ffmpeg,-loglevel,panic,-hide_banner,-ss,00:00.000,-i,H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv,-to,64.3348541661,-map,0:0,-map,0:1,-map,0:2,-c:v,libx264,-profile:v,high,-level,4.2,-pix_fmt,yuv420p,-crf,13,-c:a,libfdk_aac,-b:a,128k,H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4, no, 0, yes, no]
[  15.695][d][cplayer] Run command: script-binding, flags=73, args=[encode/encode-ENTER]
[  15.831][d][cplayer] Run command: show-text, flags=64, args=[Failed to encode, check the log, -1, 0]

log.txt

Naomi010Sentzke commented 4 years ago

I went ahead and ran mpv through Command Prompt and got this

VO: [gpu] 1920x1080 yuv420p10
AO: [wasapi] 48000Hz stereo 2ch s16
AV: 00:01:03 / 00:24:32 (4%) A-V:  0.000
[encode] ffmpeg -ss 00:00.000 -i 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv' -to 63.7098541661 -map 0:0 -map 0:1 -map 0:2 -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a libfdk_aac -b:a 128k 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4'
(Paused) AV: 00:01:04 / 00:24:32 (4%) A-V:  0.000

Exiting... (Quit)
occivink commented 4 years ago

Ah sorry that's kind of silly of me, I forgot I have all output from ffmpeg disabled, I need to revise this. What if you run the ffmpeg command directly in the command-line?

 ffmpeg -ss 00:00.000 -i 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv' -to 63.7098541661 -map 0:0 -map 0:1 -map 0:2 -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a libfdk_aac -b:a 128k 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4'
Naomi010Sentzke commented 4 years ago

So, Zeranoe's ffmpeg build does not come with --enable-libfdk-aac. So, I went with the native aac encoder ffmpeg -ss 00:00.000 -i 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv' -to 63.7098541661 -map 0:0 -map 0:1 -map 0:2 -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a aac -b:a 128k 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4' and got this error

Automatic encoder selection failed for output stream #0:2. Default encoder for format mp4 (codec none) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:2

So, I went with this by removing the map arguments ffmpeg -ss 00:00.000 -i 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3].mkv' -to 63.7098541661 -c:v libx264 -profile:v high -level 4.2 -pix_fmt yuv420p -crf 13 -c:a aac -b:a 128k 'H:\Anime\Log Horizon 2\[SallySubs] Log Horizon 2 - 01 [BD 1080p FLAC] [2D5E1BC3]_1.mp4' But it does not contain the subs. I want ffmpeg to hardsub the subs. For that you need to pass "-vf subtitles=filename.mkv" to ffmpeg. After lots of compromises, this is my new config.

only_active_tracks=yes
preserve_filters=yes
append_filter=
codec= -c:v libx264 -profile:v main -level 4 -pix_fmt yuv420p -crf 15 -c:a libopus -b:a 160k
output_format=$f_$n.mkv
output_directory=
detached=yes
ffmpeg_command=ffmpeg
print=yes

Now, heres a new issue. I wanted to put output_format=$f_$s_$e_$n.$x, but it wont accept that.

occivink commented 4 years ago

Oh I never realized but : is not accepted in filenames on windows so $s and $e have never worked there. Should be fixed now.

Regarding vf=subtitles, I think I will add a specific parameter for this, since it's currently not easy/possible to do with the existing ones.