petzku / Aegisub-Scripts

petzku's Aegisub automation scripts
23 stars 6 forks source link

[BUG?] Encode Clip raw: export video with subtitle #1

Closed VegethB closed 3 years ago

VegethB commented 3 years ago

It is likely that I did not understand how this script works but when in doubt I write the problem. Technically it should create sequences based on the selected times using MPV (which I put in the feedDump folder) latest version for windows. Whether you use RAW or subtitle mode he exports the clip with subs overlayed.

petzku commented 3 years ago

Can you paste the script's output from the Aegisub log window?

VegethB commented 3 years ago

I'm not understanding anything anymore 🤣😵 Yesterday I was behind the trim of motion and encode clips all day, here are the results: After a restart, to have only the two written:

Raw video clip; Clip with subtitle;

All options appeared (strange because I had installed scripts months ago but never used it until yesterday). But now from "feedDump" mpv also wants it in "log". Without it it doesn't work. I have already tried to put mpv in the windows path but it doesn't want to see it, so I had to put 2 MPV, one in FeedDump and one in Log.

New problem: For some clips the number of exported frames is wrong (for example I have a 54frame scene in the subs and in the video, but export a 52frame clip).

log 52frame export: `running: mpv --start=753.940 --end=756.190 "C:\Users\MSI\Downloads\Saekano\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws - Fine.mkv" --vf=format=yuv420p --o="Y:\Anime2\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine_753.940-756.190_noaudio_nosub.mp4" --ovcopts="profile=main,level=4.1,crf=23" --audio=no --sid=no` `C:\Users\MSI\AppData\Roaming\Aegisub\log>mpv --start=753.940 --end=756.190 "C:\Users\MSI\Downloads\Saekano\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws - Fine.mkv" --vf=format=yuv420p --o="Y:\Anime2\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine_753.940-756.190_noaudio_nosub.mp4" --ovcopts="profile=main,level=4.1,crf=23" --audio=no --sid=no [file] Cannot open file 'C:\Users\MSI\Downloads\Saekano\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws - Fine.mkv': Invalid argument Failed to open C:\Users\MSI\Downloads\Saekano\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws - Fine.mkv.` `[encode] no data written to target file Exiting... (Interrupted by error) `

As you may have noticed from this log, it didn't even export. This is because when it gets the video directory, it fetches it from the garbage in the script. Which is out of date if I open a script that was passed to me by others, because there will be the destination used by that person and not my open video file now.

image It's a problem because I opened the subs from the video. To solve I have to: Save the .ass somewhere; Re open the video. At that point, in the garbage, the new video location (which I am using) on aegisub is saved now.

Now that I've "solved" this little setback,

Log of 52frames export problem on 54frame: `running: mpv --start=753.940 --end=756.190 "Y:\Anime2\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine.mkv" --vf=format=yuv420p --o="Z:\Anime Backups\Saenai Heroine no Sodatekata\ReSub OCR\Ass\Saekano - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine_753.940-756.190_nosub.mp4" --ovcopts="profile=main,level=4.1,crf=23" --oac=aac_mf --oacopts="b=256k,frame_size=1024" --sid=no` `C:\Users\MSI\AppData\Roaming\Aegisub\log>mpv --start=753.940 --end=756.190 "Y:\Anime2\Saenai Heroine no Sodatekata\Specials\Saenai Heroine no Sodatekata - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine.mkv" --vf=format=yuv420p --o="Z:\Anime Backups\Saenai Heroine no Sodatekata\ReSub OCR\Ass\Saekano - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine_753.940-756.190_nosub.mp4" --ovcopts="profile=main,level=4.1,crf=23" --oac=aac_mf --oacopts="b=256k,frame_size=1024" --sid=no (+) Video --vid=1 (*) '[Beatrice-Raws] x265 10bit BD' (hevc 1920x1080 23.976fps) (+) Audio --aid=1 --alang=jpn (*) 'FLAC 2.1 Jpn' (flac 3ch 48000Hz) Subs --sid=1 --slang=ita (*) '[OCRD] Cartelli powa (ReSub)' (ass) Subs --sid=2 --slang=eng 'Fine-Sub' (ass) Subs --sid=3 --slang=jpn 'BD Jap' (hdmv_pgs_subtitle) File tags: Title: Saenai Heroine no Sodatekata Fine [autoconvert] Converting yuv420p10 -> yuv420p [ao/lavc] Opening encoder: AAC via MediaFoundation [aac_mf] AO: [lavc] 48000Hz stereo 2ch s16 VO: [lavc] 1920x1080 yuv420p [vo/lavc] Opening encoder: libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [libx264] [ffmpeg] libx264: MB rate (195840000) > level limit (245760) [encode] Opening output file: Z:\Anime Backups\Saenai Heroine no Sodatekata\ReSub OCR\Ass\Saekano - s00e03 - Beatrice-Raws + [OCRD] ReSub - Fine_753.940-756.190_nosub.mp4 [encode] Opening muxer: MP4 (MPEG-4 Part 14) [mp4]` `[encode] video: encoded 148977 bytes [encode] audio: encoded 55004 bytes [encode] muxing overhead 3314 bytes Exiting... (End of file)` By frames: ![image](https://user-images.githubusercontent.com/17975351/101616596-d5c04480-3a0f-11eb-8423-5cc5bd4d1a2b.png) By time: ![image](https://user-images.githubusercontent.com/17975351/101616804-1cae3a00-3a10-11eb-8db5-b04e06ca1363.png)
MediaInfo TRIM vs Encode Clip TRIM from mocha script (
command used "#{encbin}" -ss #{startt} -sn -an -i "#{inpath}\#{input}" -vframes #{lenf} -c:v libx264 -r 24000/1001 -crf 10 -pix_fmt yuv420p "#{prefix}/#{output}[#{startf}-#{endf}].mp4"
) ![image](https://user-images.githubusercontent.com/17975351/101621493-1f139280-3a16-11eb-8bcb-9f234e0cf62d.png) --------------------------------------------------------------------------------------------------------------------------------------------- Encode Clip (MPV exported): ![image](https://user-images.githubusercontent.com/17975351/101620837-4f0e6600-3a15-11eb-816e-34d9d4430e28.png) There are obvious problems with the export command: It changed framerate from the usual 23.976 to a 24.434; He used VRF instead of CRF (and export quality is too low, 120kb for 2 seconds vs 4mb for 2 seconds on ffmpeg with CRF 4); I exported with the GUI and removed the ticks on Audio and Subs but the audio is still present.
petzku commented 3 years ago

As you found out, the script is not intended for use with subtitles loaded from video. I think you can open the video file again in Aegisub (after loading the subtitles from it) to set the correct video file in the properties, though.

To my knowledge, it is not possible to get the path to the currently open video otherwise.

Yesterday I was behind the trim of motion and encode clips all day, here are the results: After a restart, to have only the two written: Raw video clip; Clip with subtitle; All options appeared (strange because I had installed scripts months ago but never used it until yesterday).

Are you saying that you previously had only those two options, but after restarting Aegisub you have all the modes (audio only, four video modes, GUI)? That would be caused by DependencyControl automatically downloading a new version of the script when you run it (but it needs to be reloaded, which doesn't happen automatically).

This would also explain how you previously ended up with subtitles in the raw clip. A prior version of Encode Clip didn't actually disable subtitles, if the original video file happened to have them.

There are obvious problems with the export command: It changed framerate from the usual 23.976 to a 24.434; He used VRF instead of CRF (and export quality is too low, 120kb for 2 seconds vs 4mb for 2 seconds on ffmpeg with CRF 4);

VFR seems to happen because the export isn't exactly lined up with the frames. The actual video should still be 23.976 fps except for the very first and last frames. I will look into this more, but I don't see it being a problem.

120 KB seems like a reasonable size for a two-second clip. This is not meant for making trims for use in motion tracking, it's more meant for easily rendering a short clip to show subtitles/audio or similar.

I exported with the GUI and removed the ticks on Audio and Subs but the audio is still present.

Seems interesting. The log output shows the audio options being enabled (--oac=aac_mf --oacopts="b=256k,frame_size=1024", as well as the filename not including _noaudio). However, I can't replicate this behaviour.

Without it it doesn't work. I have already tried to put mpv in the windows path but it doesn't want to see it, so I had to put 2 MPV, one in FeedDump and one in Log.

This should not be necessary, if mpv is correctly on your system path. You might need to restart Aegisub (and possibly log out) after making changes to your path variable, though.

VegethB commented 3 years ago

Are you saying that you previously had only those two options, but after restarting Aegisub you have all the modes (audio only, four video modes, GUI)?

👍 😆

VFR seems to happen because the export isn't exactly lined up with the frames. The actual video should still be 23.976 fps except for the very first and last frames. I will look into this more, but I don't see it being a problem.

I don't know how to explain, I didn't mean problem as "big mistake", but that something doesn't seem to work as expected. On FFMpeg with the -vframe option you are able to export the exact number of selected frames (I saw that mpv includes a build of ffmpeg, so with that command in theory it would solve the problem).

120 KB seems like a reasonable size for a two-second clip. This is not meant for making trims for use in motion tracking, it's more meant for easily rendering a short clip to show subtitles/audio or similar.

I can't argue 😂. In desperation to create the trim ffmpeg command, I was handed this script but not what I thought from the name it was obvious what it was for. Thinking about how it was designed, it does its duty (except for MPV who just don't want to find it).


Seems interesting. The log output shows the audio options being enabled (--oac=aac_mf --oacopts="b=256k,frame_size=1024", as well as the filename not including _noaudio). However, I can't replicate this behaviour.

It must have been my oversight then.

This should not be necessary, if mpv is correctly on your system path. You might need to restart Aegisub (and possibly log out) after making changes to your path variable, though.

I changed MPV path and rebooted, now it works 🙃, thanks.

In the end, somehow it's working. The only things I report: VRF and the 2 frames skipped from the selection. Thanks anyway, hopefully they will update Aegisub to 3.3.0 soon as they need it (especially with MKS).