fallingsnow / h265ize Goto Github PK
View Code? Open in Web Editor NEWA node utility utilizing ffmpeg to encode videos with the hevc codec.
License: MIT License
A node utility utilizing ffmpeg to encode videos with the hevc codec.
License: MIT License
h265ize 4.0 should have the ability to output a few thumbnails after file is encoded. Perhaps even have the ability to make a comparison between the before and after video.
Need to fix stats
Not really the best place to ask this I guess but anyway to add to delete audio tracks that are not a certain language? for example I tend to get alot of stuff that is dual language however I'd like to remove everything but english / unknown.
Also was wondering if you have anything that I might use to identify all the video files I have that contain unknown audio tracks. Can't seem to find the best way to go about this.
Thanks!
It seems that it is creating additional directories inside the encoding folder.
Enable i have it set to delete the source after encoding and that works but, it is create useless directory tree inside the encoder folder.
h265ize.tv.txt
nas@nas:/hd/01/media/encoding$ ls -al
total 1820
drwxr-xr-x 3 nas nas 4096 Dec 2 21:00 .
drwxr-xr-x 4 nas nas 4096 Nov 7 13:00 ..
-rwxr--r-- 1 nas nas 1755691 Dec 2 20:59 h265ize.log.txt
-rw-r--r-- 1 nas nas 86506 Dec 2 20:49 h265ize.stats
drwxr-xr-x 4 nas nas 4096 Dec 2 20:30 tv
nas@nas:/hd/01/media/encoding$
nas@nas:/hd/01/media/encoding$ ls -al tv
total 16
drwxr-xr-x 4 nas nas 4096 Dec 2 20:30 .
drwxr-xr-x 3 nas nas 4096 Dec 2 21:00 ..
drwxr-xr-x 3 nas nas 4096 Dec 2 19:54 2 Broke Girls
drwxr-xr-x 3 nas nas 4096 Dec 2 20:30 Chrisley Knows Best
nas@nas:/hd/01/media/encoding$
HE encoded audio streams may get the wrong title if the title is generated.
Another fiddly "your environment is too old" check - ffmpeg 1.0.8 doesn't do the necessary stuff to generate audio codec detection and video dimension data, at a minimum:
Debug generated commandline with a modern ffmpeg (2.8.2):
[h265ize]: [Debug] [Query] HandBrakeCLI -i video.mkv -o /home/pfriedel/h265/encoding-in-process-9512.mkv -w 1280 -l 720 --previews 50 -e x265 -q 23 --vfr -a 1,2 --gain 0 --audio-fallback ac3 -6 dpl2 -E ac3,ac3 -A"DD 5.1 @ 448Kbps,Commentary DD 2.0 @ 192Kbps" --subtitle 1 --encoder-profile=main --encoder-preset=superfast --modulus 2 -m --verbose=0 < /dev/null
Versus one with an ancient version of ffmpeg:
[h265ize]: [Debug] [Query] HandBrakeCLI -i video.mkv -o /home/pfriedel/h265/encoding-in-process-9379.mkv -w -l --previews 50 -e x265 -q 23 --vfr -a 1,2 --gain 0 --audio-fallback ac3 -6 dpl2 -E --subtitle 1 --encoder-profile=main --encoder-preset=superfast --modulus 2 -m --verbose=0 < /dev/null
HandBrakeCLI chokes on the -E --subtitle 1 with the following error:
+ audio tracks:
+ 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
+ 2, English (AC3) (2.0 ch) (iso639-2: eng), 48000Hz, 192000bps
+ subtitle tracks:
+ 1, English (iso639-2: eng) (Text)(UTF-8)
Invalid codec --subtitle, using default for container.
The hazard is that it makes files which appear to be correct, but are missing one of the important things that people are using h265ize for - pulling in all audio and sub track data without having to manually add them. I suspect a big red line in verbose mode to holler if ${tempVars[sourceWidth]} is null would be a useful alert here. I mean, I'd hate to parse ffmpeg -v and figure out if it's v1 or v2 and figuring out where to draw the line in the sand for "supported" versus "not supported" when it all boils down to "did I get data that I expected to get out of ffmpeg" seems like overkill anyway.
rolls back zpool snapshots from a week ago, starts over. 😄
Should a no-auto-subtitle-titles
to add uniformity.
Provide an ETA for when an encode will finish.
Trying to run this via Docker and getting this error
const optional = require('optional');
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Should be able to use h265ize as a module in other projects.
When batch converting a bunch of videos, many of them may not be properly tagged for language, or the user may not want additional metadata (which may present in the player) added to the audio stream.
Can you please add an option to disable adding audio title metadata?
Example problem output:
[h265ize]: [alert] Audio does not have a title. Title set to "Unknown MP3 (Stereo)".
In this example the player would default to playing the audio w/o a label until the metadata is added giving the user a bad UX because of the "Unknown" audio. Yes, one could go through the multitude of videos and ensure they all have proper language and meta tags, but:
[h265ize]: [alert] Audio does not have a title. Title set to "English AC3 (6.0 Channel)".
For someone who doesn't know what AC3 (or MP3) is, there's no need to add that to a label. They just want to know (if they want to know at all) what the language is.
For my videos the only title metadata that's stored on a per-stream basis is for subtitles to denote SDH subs.
Anyway we could get a command to specify as config file that I can use instead of modify the whole h265ize, it would make it easier to keep up to date with you git.
Thank you
Currently h265ize does not return a version when the --version
flag is passed.
Hi,
I'm trying out the new version, it seems to work almost flawlessly, but on some files it gives me an error:
ffmpeg exited with code 1: av_interleaved_write_frame(): Invalid argument
Logs (removed because of privacy issue)
Each level carries on to the next. This means level 3 includes all normalizations from level 1 to 3.
Add support for crop detection and execution
I was transcoding a bunch of files, there were some complete seasons which consistently failed.
After looking at the output, I noticed the the -w and -l (video dimensions) were crazy. I traced it back to the fact that some mp4 files have embedded thumbnails that return this at the ffprobe:
codec_name=png
codec_type=video
width=600
height=600
coded_width=600
coded_height=600
avg_frame_rate=0/0
bits_per_raw_sample=N/A
There is another category of files that fail, which seems to be correlated with srt subtitles, that have something like the following streams:
0:
codec_name=aac
codec_type=audio
avg_frame_rate=0/0
bits_per_raw_sample=N/A
1:
codec_name=h264
codec_type=video
width=1280
height=716
coded_width=1280
coded_height=720
avg_frame_rate=2997/125
bits_per_raw_sample=8
2:
codec_name=srt
codec_type=subtitle
width=N/A
height=N/A
avg_frame_rate=0/0
bits_per_raw_sample=N/A
3:
codec_name=mjpeg
codec_type=video
width=120
height=176
coded_width=120
coded_height=176
avg_frame_rate=0/0
bits_per_raw_sample=8
4:
codec_name=mjpeg
codec_type=video
width=600
height=882
coded_width=600
coded_height=882
avg_frame_rate=0/0
bits_per_raw_sample=8
5:
codec_name=mjpeg
codec_type=video
width=1067
height=600
coded_width=1067
coded_height=600
avg_frame_rate=0/0
bits_per_raw_sample=8
6:
codec_name=mjpeg
codec_type=video
width=213
height=120
coded_width=213
coded_height=120
avg_frame_rate=0/0
bits_per_raw_sample=8
... again, I'm guessing these differently sized "mjeg" streams are related to subtitles.
I fixed this by just skipping them with a hack:
L501 if [ "$codec_type" = "video" ]; then
if [ $codec_name = "png" ] || [ $codec_name = "mjpeg"]; then
unset language
unset title
unset codec_name
unset codec_type
unset bits_per_raw_sample
unset width
unset height
unset avg_frame_rate
continue
fi
tempVars+=([sourceWidth]="$width")
tempVars+=([sourceHeight]="$height")
but, there's probably a more elegant solution
Not an issue but a feature requestion:
Can you please add an option to replace source file with converted file, after encoding in different directory, I've hacked up your older version to do this but it's not clean please see sample.
h265ize.tv.txt
Add support for multiple passes.
Hi,
I tried converting a bunch of movies, it works fine except for a few ones: after encoding with handbrake, ffmpeg causes an error:
Stream map '0:3' matches no streams.
To ignore this, add a trailing '?' to the map.
[h265ize]: Ut oh. Ffmpeg exited with error code 1.
[h265ize]: h265ize did not end cleanly. Deleting temp file and extra files.
[h265ize]: [Debug] Temporary output at ./tempOutput/encoding-in-process-21637.mkv has not been deleted because you are in debug mode
Full debug log here:
The temporary mkv file doesn't have any subtitles included in it.
How can I fix this ?
Regards,
Azsde.
Running on mac throws integer expression errors on line 5 which appears to be the default settings.
Any suggestions for getting this to properly run on mac would be great.
Thanks.
Hi,
I have a message error when i encode and after the encode, the files are disappeared.
Erreur :
[aac @ 0x7f898c0b3f00] element type mismatch 1 != 0
The video : -link removed by FallingSnow-
Screen of error : http://prntscr.com/8tmgue
The command use to do this : ./h265ize -n fr -q 19 -d h265 Ushio.to.Tora.S01E01.VOSTFR.1080p.WEBRip.x264-HORiZON.mkv
Thanks.
Regards.
I'm not sure if this is by design, but when a file is converted, the audio gets dropped from 5.1 to stereo. Linked is a sample file.
Original file: http://imgur.com/T0AJKkj
Output file: http://imgur.com/Hs1j0GD
Is there something I need to change, or an option I need to use, to get it to maintain the original audio? I looked through the script and didn't see anything.
Thanks in advance, and thanks for the great script!
I'm not sure the best route forward for this - the file autodetection is great when it works, but it seems to stumble a bit, i.e. this is autodetected:
$ file video1.m4v
video1.m4v: ISO Media, MPEG v4 system, version 2
$ file -i video1.m4v
video1.m4v: video/mp4; charset=binary
While this is never looked at - Handbrake will gladly convert it, but the script skips it since the mime-type that file -i returns isn't captured by the sed in the FILES=$() builder.
$ file video2.mkv
video2.mkv: EBML file, creator matroska
$ file -i video2.mkv
video2.mkv: application/octet-stream; charset=binary
I'm not sure what the right solution is, to be honest, since "application/octet-stream" is a perfectly legitimate mime-type, although not particularly specific. In the meantime I've added the following and am letting HandBrake reject errata:
ADDFILES=$(find "$DIRECTORY" -maxdepth ${options[depth]} -type f -exec file -N -i -- {} + | sed -n 's!: application/[^:]*$!!p')
And changed the file accumulator to:
FILES=( "${FILES[@]}" "${ADDFILES[@]}" "${EXCLUSIVEFILES[@]}" )
My magic is probably dated - it is FC18 after all.
As h265ize has grown, the code base has become a bit of a mess. While bash is a useful language for automating user actions, its age has started to become apparent. I would like to ask the users of h265ize if a their would be any restrictions to using h265ize if the code base was moved to nodejs. This would mean adding nodejs as a dependency. I will leave this issue open for at least 2 weeks for discussion.
If you have any questions, comments, or suggestions please reply below.
I don't really know if this should be done... because you lose all the custom styling done with PGS subtitles and of course there is the inaccuracy of the OCR software used to upconvert the subtitles.
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 2: syntax error
(standard_in) 2: syntax error
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
h265ize: Subtitle title was empty. Subtitle title changed to Unknown.
h265ize: Subtitle title was empty. Subtitle title changed to Unknown.
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 2: syntax error
/opt/h265ize/h265ize.1080: line 887: [: -eq: unary operator expected
HandBrake 0.10.1 (2015100400) - Linux x86_64 - https://handbrake.fr
8 CPUs detected
Opening /hd/02/media/movie/1080p/33, The (2015)/The 33.2015.tt2006295.sub...
index_parse.c:190: indx_parse(): error opening /hd/02/media/movie/1080p/33, The (2015)/The 33.2015.tt2006295.sub/BDMV/index.bdmv
index_parse.c:190: indx_parse(): error opening /hd/02/media/movie/1080p/33, The (2015)/The 33.2015.tt2006295.sub/BDMV/BACKUP/index.bdmv
bluray.c:2365: nav_get_title_list(/hd/02/media/movie/1080p/33, The (2015)/The 33.2015.tt2006295.sub) failed
libdvdnav: Using dvdnav version 5.0.1
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
No title found.
HandBrake has exited.
h265ize: Handbraking Complete -----------------------------------------------
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 2: syntax error
(standard_in) 2: syntax error
/opt/h265ize/h265ize.1080: line 943: [: : integer expression expected
h265ize: Ut oh. Duration of The 33.2015.tt2006295 is not within acceptable limits of the original file.
h265ize: Bad file stored at /hd/02/media/encoding/encoding-in-process-7355.mkv.
h265ize: Processing The 33.2015.tt2006295-trailer.mkv.
Debian jessie, handbrake
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
h265ize: [Debug] Stream Index: 0 Title: Language: unk Codec: subtitle
h265ize: [Debug] Subtitle #1
h265ize: [Debug] Language: unk Default Audio: NativeLangCode: eng
h265ize: [Debug] Stream Index: 1 Title: Language: unk Codec: subtitle
h265ize: [Debug] Subtitle #2
h265ize: [Debug] Language: unk Default Audio: NativeLangCode: eng
h265ize: Subtitle title was empty. Subtitle title changed to Unknown.
h265ize: Subtitle title was empty. Subtitle title changed to Unknown.
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 2: syntax error
/opt/h265ize/h265ize.1080: line 887: [: -eq: unary operator expected
h265ize: [Debug] [Query] HandBrakeCLI -i /hd/02/media/movie/1080p/5\ Flights\ Up\ (2014)/5\ Flights\ Up.2014.tt2933544.sub -o /hd/02/media/encoding/encoding-in-process-1829.mkv -w -l --previews 50 -e x265 -q 23 --vfr -a --gain 0 --audio-fallback ac3 -6 dpl2 -E --subtitle 1,2 --subtitle-default=1 --encoder-profile=main --encoder-preset=medium --modulus 2 -m --verbose=0 < /dev/null
HandBrake 0.10.1 (2015100400) - Linux x86_64 - https://handbrake.fr
8 CPUs detected
Opening /hd/02/media/movie/1080p/5 Flights Up (2014)/5 Flights Up.2014.tt2933544.sub...
index_parse.c:190: indx_parse(): error opening /hd/02/media/movie/1080p/5 Flights Up (2014)/5 Flights Up.2014.tt2933544.sub/BDMV/index.bdmv
index_parse.c:190: indx_parse(): error opening /hd/02/media/movie/1080p/5 Flights Up (2014)/5 Flights Up.2014.tt2933544.sub/BDMV/BACKUP/index.bdmv
bluray.c:2365: nav_get_title_list(/hd/02/media/movie/1080p/5 Flights Up (2014)/5 Flights Up.2014.tt2933544.sub) failed
libdvdnav: Using dvdnav version 5.0.1
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
^CSignal 2 received, terminating - do it again in case it gets stuck
No title found.
Only defaults to 10 on some systems, should be on all systems.
....
h265ize: line 793: [: : integer expression expected
....
this is line:
if [ "${options[parallel]}" -eq 1 ]; then
I looked through the script, it seems that "parallel" is never defined...
While the --help
flag contains info about the --10bit
and --12bit
flags, the readme does not.
Shouldn't be using $RANDOM
to make a random file name, mktemp
should be used instead.
Size can be significantly reduced by down scaling. h265ize should be able to down scale to 720p or 480p.
Thanks for your always quick responses.
I was saving this until I could track down the error, but I can't find it.
version 0.2.2 fails to loop. Output shows all files found. First file is handbraked successfully, and then the script terminates without error. Removing the first finished file allows the next file to be handbraked, and then the script stops again.
As I said, I can't see the cause, but I haven't looked too closely.
This will increase the performance of h265ize itself but will most certainly create a logging incomprehensible to humans unless I create another logging method.
It seems to crap out because of this, before I was getting a bunch of unary operator expected; according to manuals i read i could correct this by added an additional [ around if /&& statements, which i've done (see attachment) however I am getting illegal character N
Quick fix:
Setting subtitle names...
/bin/ffmpeg: No such file or directory
$which ffmpeg
/usr/bin/ffmpeg
suggestion:
/bin/ffmpeg -> ffmpeg
(is it considered good practice to hard-code each executable? even /bin/rm?)
thanks for this great script.
It would be cool if the stats file had the ssim or psnr of the newly encoded file.
Hello :)
Is-it possible to launch the script in the background so it won't stop even if the session's stopped ?
Thank's !
If an error is encountered at any point, the entire script stops. Need to add a --skip-errors
flag.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
�[0;32m[h265ize]�[0m: Handbraking Complete -----------------------------------------------
�[0;32m[h265ize]�[0m: Setting subtitle names...
Stream map '0:3' matches no streams.
To ignore this, add a trailing '?' to the map.
�[0;31m[h265ize]�[0m: Ut oh. Ffmpeg exited with error code 1.
�[0;33m[h265ize]�[0m: h265ize did not end cleanly. Deleting temp file and extra files.
h265ize.log.txt
Hello :)
I keep having this error despite having installed handbrake and handbrake-cli.
The machine is under debian 8 server.
Do you have any idea how to fix it ?
Thank's ! :)
I run this script as a normal user.Got this errors
./h265ize: 5: ./h265ize: declare: not found
./h265ize: 6: ./h265ize: Syntax error: word unexpected (expecting ")")
h265ize will make a sample of the finished encode. The length will be set by the -l
flag.
Debug mode should be able to be enabled by pressing the d key at any time.
Would be cool if p paused and resumed an encode.
nas@nas:/opt/h265ize$ bash h265ize.tv /hd/01/media/tv
(standard_in) 1: syntax error
h265ize: Finding videos...
see #6 (comment)
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi,
My linux is in french, and your script doesn't like the way my date are formatted.
date: incorrect date «mardi 10 mai 2016, 10:20:21 (UTC+0200)»
Doesn't seem to prevent the script from running, but I don't know if this could cause trouble.
Regards,
Azsde.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.