occivink / mpv-scripts

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

Preserve filter (crop) not applying to Encode #56

Closed yusufaine closed 3 years ago

yusufaine commented 3 years ago

Snippet of my mpv-crop-snippet.log shows the crop being detected and applied, but for some reason the mpv-ffmpeg-encode-snippet.log doesn't seem to apply the crop filter.

I've also attached my encode.confin case I might've messed something up there.

mpv-crop-snippet.log

[   1.429][d][cplayer] Run command: vf, flags=73, args=["remove", "@autocrop-cropdetect"]
[   1.429][v][vf] User filter list:
[   1.429][v][vf]   (empty)
[   1.467][d][cplayer] Run command: vf, flags=73, args=["pre", "@autocrop-crop:lavfi-crop=w=1920:h=816:x=0:y=132"]
[   1.468][v][vf] User filter list:
[   1.468][v][vf]   lavfi-crop (autocrop-crop)
[   1.508][v][vf] [lavfi-crop] 1920x1080 yuv420p bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[   1.508][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 fr:919025/38331 sar:1/1
[   1.509][d][ffmpeg] filter: w:1920 h:1080 sar:1/1 -> w:1920 h:816 sar:1/1
[   1.510][v][vf] [autorotate] 1920x816 yuv420p bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[   1.510][v][vf] [convert] 1920x816 yuv420p bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[   1.510][v][vf] [out] 1920x816 yuv420p bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264

mpv-ffmpeg-encode-snippet.log

[   7.455][i][encode] /usr/local/bin/ffmpeg -ss 1:33:39.656 -i '/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG.mkv' -to 2.6068541660998 -map 0:0 -map 0:1 -map 0:2 -an '/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG_1.mkv' 
[   7.455][d][cplayer] Run command: run, flags=64, args=["/usr/local/bin/ffmpeg", "-loglevel", "panic", "-hide_banner", "-ss", "1:33:39.656", "-i", "/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG.mkv", "-to", "2.6068541660998", "-map", "0:0", "-map", "0:1", "-map", "0:2", "-an", "/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG_1.mkv"]

encode.conf

only_active_tracks=yes
preserve_filters=yes
append_filter=
#codec=-c:v h264 -an
codec=-an
output_format=$f_$n.$x
output_directory=
detached=yes
ffmpeg_command=/usr/local/bin/ffmpeg
print=yes

P.S. I hope what I provided was sufficient enough, but if you need more logs, do let me know what you're looking for in particular so I can extract them and not upload the entire log file.

occivink commented 3 years ago

I think the reason is that the crop filter is named lavfi-crop here. Try to change that line to if name == "crop" or name == "lavfi-crop" then

yusufaine commented 3 years ago

Ah that did the trick, for some reason I thought that wouldn't affect it. Below is the output showing the crop was detected. For some reason it worked correctly the other time but I wasn't sure why since I couldn't reproduce the outcome.

Thanks for your response!

Potential "fix" on line 81:

if name == "crop" or name == "lavfi-crop" then
[  77.246][i][encode] /usr/local/bin/ffmpeg -ss 05:46.179 -i '/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG.mkv' -to 3.9828541660999 -map 0:0 -map 0:1 -map 0:2 -filter:v 'crop=1920:816:0:132' -an '/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG_1.mkv' 
[  77.246][d][cplayer] Run command: run, flags=64, args=["/usr/local/bin/ffmpeg", "-loglevel", "panic", "-hide_banner", "-ss", "05:46.179", "-i", "/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG.mkv", "-to", "3.9828541660999", "-map", "0:0", "-map", "0:1", "-map", "0:2", "-filter:v", "crop=1920:816:0:132", "-an", "/Users/user/Movies/Hospital.Playlist.S02E05.1080p.NF.WEB-DL.DDP2.0.x264-HoneyG_1.mkv"]