Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to not encode - only convert mkv to mp4? #677

Closed
seanvree opened this issue Feb 14, 2017 · 11 comments
Closed

How to not encode - only convert mkv to mp4? #677

seanvree opened this issue Feb 14, 2017 · 11 comments

Comments

@seanvree
Copy link

First, THANK you for this! It's great!

I'm currently using this for Radarr and Sabnzbd, and everything is working great.

I'm wondering how I can use this script to NOT encode and only convert from MKV to MP4?

Essentially, I can run this script manually, but how would I do this with this tool:

ffmpeg -i <source.movie.title>.mkv -vcodec copy -acodec copy <output.movie.title>.mp4

Thanks!

@Mirabis
Copy link
Contributor

Mirabis commented Feb 14, 2017

Just add all the video codes you do not want to convert to the accepted values. H264,hevc w/e and it will try and copy them as long as u don't set the bit rate limit

@seanvree
Copy link
Author

@Mirabis , I'm a bit confused. Sorry, a bit of a noob when it comes to encoding.

" add all the video codes you do not want to convert"

So right now I have the following in my autoprocess.ini:

video-codec = h264,x264
video-bitrate =

So, you're saying remove H264?

@Mirabis
Copy link
Contributor

Mirabis commented Feb 14, 2017

@seanvree in your case it will convert anything that is not h264 OR x264 TO h264.

So if you always want to copy you must add the video codes you want to copy to that line. E.g. H264,x264,x265,h265 would copy all those and if neither, it will convert to the first value.

@seanvree
Copy link
Author

@Mirabis - Gotcha! Thanks!

One final question, if I'm just wanting to copy from mkv to mp4, those are the main codecs, right? So If I add those to the that line, it shouldn't have to convert (often) unless it's a weird video release, right? Because with my entry before it was converting all of the files no matter what.

@zybeon
Copy link
Contributor

zybeon commented Feb 14, 2017

mkv and mp4 are containers not codecs just in case it is not clear. Post your whole autoProcess.ini for the mp4 variables. If the files that manual.py comes across are mkv and is one of the "video-codec" values it will copy the video and not transcode. It still takes some time to create a new mp4 so that might be what you are seeing. It should also take vastly less time to copy than transcode. If any of your files are already mp4 it will only convert if it doesn't meet some other requirement, ie. video quality, audio codec, subtitles, ios audio.

oh and to run it manually it is
python /path/to/sickbeard_mp4_automator/manual.py -i <media_file> -a

Manual usage readme

@seanvree
Copy link
Author

@zybeon - Right, I know MKV and MP4 are not codecs. I'm a noob but not that noob! Ha!

Anyway, yeah, i'm really only concerned with copying from MKV to MP4. When I run the Manual.py, it copies just fine, but for some reason when it automatically runs from SABNZBD it's re-encoding despite the source (and it takes a while).

Here is what I got in my autoprocess.ini:

[MP4]
ffmpeg = C:\FFMPEG-win64\bin\ffmpeg.exe
ffprobe = C:\FFMPEG-win64\bin\ffprobe.exe
threads = auto
output_directory =
copy_to =
move_to =
output_extension = mp4
output_format = mp4
delete_original = True
relocate_moov = True
video-codec = H264,x264,x265,h265
video-bitrate =
video-max-width =
h264-max-level =
use-qsv-decoder-with-encoder = True
ios-audio = True
ios-first-track-only = False
ios-audio-filter =
max-audio-channels =
audio-codec = ac3
audio-language =
audio-default-language =
audio-channel-bitrate = 0
audio-filter =
subtitle-codec = mov_text
subtitle-language =
subtitle-default-language =
subtitle-encoding =
fullpathguess = True
convert-mp4 = False
tagfile = False
tag-language = en
download-artwork = Poster
download-subs = False
embed-subs = False
sub-providers = addic7ed,podnapisi,thesubdb,opensubtitles
permissions = 0777
post-process = False
pix-fmt =
aac_adtstoasc = False

@zybeon
Copy link
Contributor

zybeon commented Feb 14, 2017

can you post the SABNZBD log showing what all it is doing. The "ios-audio=true" will always cause an audio reencode if there is any audio stream with more than 2 channels and not already ac3. Also "ios-first-track-only=false" could create multiple copies of audio streams if the file has more than one audio stream with more than 2 channels.

@seanvree
Copy link
Author

seanvree commented Feb 15, 2017

@zybeon - No problem:

So this file has been processing for 7 hours now and is 65% done. The original format was X264 MKV, so why is it taking so long to simply convert it to MP4?

So the input MKV Downloaded from SAB and sent to the script was as follows:

General
Unique ID : 204158816206275920321196542769913742660 (0x99978EC8FB384F37AB8478D736454544)
Complete name : C:\Media\PlexDownloads\Movies\NZBs\Deadpool (2016) 2160p Ultra HD Blu-ray DTS-HD MA 7.1 x264-TrollUHD\Deadpool (2016) 2160p Ultra HD Blu-ray DTS-HD MA 7.1 x264-TrollUHD.mkv
Format : Matroska
Format version : Version 4 / Version 2
File size : 30.2 GiB
Duration : 1 h 48 min
Overall bit rate : 39.9 Mb/s
Encoded date : UTC 2016-05-21 04:10:06
Writing application : mkvmerge v8.3.0 ('Over the Horizon') 64bit
Writing library : libebml v1.3.1 + libmatroska v1.4.2

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 1 h 48 min
Bit rate : 34.4 Mb/s
Width : 3 840 pixels
Height : 1 608 pixels
Display aspect ratio : 2.40:1
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.233
Stream size : 26.0 GiB (86%)
Writing library : x264 core 148 r2638 7599210
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=48 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=17.0 / qcomp=0.70 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=300000 / vbv_bufsize=300000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:0.90
Default : Yes
Forced : No

Audio #1
ID : 2
Format : DTS
Format/Info : Digital Theater Systems
Format profile : MA / ES Matrix / Core
Mode : 16
Format settings, Endianness : Big
Codec ID : A_DTS
Duration : 1 h 48 min
Bit rate mode : Variable / Constant / Constant
Bit rate : 4 892 kb/s / 1 509 kb/s / 1 509 kb/s
Channel(s) : 8 channels / 7 channels / 6 channels
Channel positions : Front: L C R, Side: L R, Back: L R, LFE / Front: L C R, Side: L R, Back: C, LFE / Front: L C R, Side: L R, LFE
Sampling rate : 48.0 kHz
Frame rate : 93.750 FPS (512 spf)
Bit depth : 24 bits
Compression mode : Lossless / Lossy / Lossy
Stream size : 3.69 GiB (12%)
Language : English
Default : Yes
Forced : No

Audio #2
ID : 3
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 1 h 48 min
Bit rate mode : Constant
Bit rate : 224 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 spf)
Compression mode : Lossy
Stream size : 173 MiB (1%)
Title : Commentary 1
Language : English
Default : No
Forced : No

Audio #3
ID : 4
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 1 h 48 min
Bit rate mode : Constant
Bit rate : 224 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 spf)
Compression mode : Lossy
Stream size : 173 MiB (1%)
Title : Commentary 2
Language : English
Default : No
Forced : No

Text #1
ID : 5
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 47 min
Bit rate : 13.9 kb/s
Count of elements : 3704
Stream size : 10.7 MiB (0%)
Language : English
Default : Yes
Forced : No

Text #2
ID : 6
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 47 min
Bit rate : 10.5 kb/s
Count of elements : 2742
Stream size : 8.03 MiB (0%)
Language : Spanish
Default : No
Forced : No

Text #3
ID : 7
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 47 min
Bit rate : 10.6 kb/s
Count of elements : 2834
Stream size : 8.09 MiB (0%)
Language : French
Default : No
Forced : No

Text #4
ID : 8
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 48 min
Bit rate : 28.3 kb/s
Count of elements : 4842
Stream size : 21.8 MiB (0%)
Language : English
Default : No
Forced : No

Text #5
ID : 9
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 48 min
Bit rate : 20.9 kb/s
Count of elements : 4498
Stream size : 16.2 MiB (0%)
Language : Spanish
Default : No
Forced : No

Text #6
ID : 10
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 48 min
Bit rate : 21.4 kb/s
Count of elements : 4510
Stream size : 16.5 MiB (0%)
Language : French
Default : No
Forced : No

Text #7
ID : 11
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 47 min
Bit rate : 23.6 kb/s
Count of elements : 3988
Stream size : 18.2 MiB (0%)
Language : English
Default : No
Forced : No

Text #8
ID : 12
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 48 min
Bit rate : 20.5 kb/s
Count of elements : 3844
Stream size : 15.9 MiB (0%)
Language : Spanish
Default : No
Forced : No

Text #9
ID : 13
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 h 48 min
Bit rate : 21.4 kb/s
Count of elements : 3846
Stream size : 16.6 MiB (0%)
Language : French
Default : No
Forced : No

Text #10
ID : 14
Format : PGS
Muxing mode : zlib
Codec ID : S_HDMV/PGS
Codec ID/Info : Picture based subtitle format used on BDs/HD-DVDs
Duration : 1 s 919 ms
Bit rate : 12.0 kb/s
Count of elements : 2
Stream size : 2.81 KiB (0%)
Language : English
Default : No
Forced : No


Sab sent it to the script...here is the output:

02-14 09:12:23 - SABPostProcess - INFO - SAB post processing started.
2017-02-14 09:12:23 - readSettings - INFO - C:\Python27\python.exe
2017-02-14 09:12:23 - readSettings - WARNING - Invalid external subtitle codec mov_text, ignoring.
2017-02-14 09:12:23 - readSettings - WARNING - No valid subtitle formats found, defaulting to 'srt'.
2017-02-14 09:12:23 - SABPostProcess - INFO - Performing conversion
2017-02-14 09:12:23 - SABPostProcess - INFO - Processing file c:\Media\PlexDownloads\Movies\NZBs\Deadpool (2016) 2160p Ultra HD Blu-ray DTS-HD MA 7.1 x264-TrollUHD\Deadpool (2016) 2160p Ultra HD Blu-ray DTS-HD MA 7.1 x264-TrollUHD.mkv.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Reading video stream.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Video codec detected: h264.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Pix Fmt: yuv420p.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Reading audio streams.
2017-02-14 09:13:26 - mkvtomp4 - INFO - No audio streams detected in any appropriate language, relaxing restrictions so there will be some audio stream present.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio detected for stream #1: dts [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Creating audio stream 0 from source audio stream 1 [iOS-audio].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio track is number 0 setting disposition to default
2017-02-14 09:13:26 - mkvtomp4 - INFO - Creating audio stream 1 from source stream 1.
2017-02-14 09:13:26 - mkvtomp4 - WARNING - Unable to determine audio bitrate from source stream 1, defaulting to 256 per channel.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio Track is number 1 setting disposition to none
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio detected for stream #2: ac3 [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Creating audio stream 2 from source stream 2.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio Track is number 2 setting disposition to none
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio detected for stream #3: ac3 [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Creating audio stream 3 from source stream 3.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Audio Track is number 3 setting disposition to none
2017-02-14 09:13:26 - mkvtomp4 - INFO - Reading subtitle streams.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #4: hdmv_pgs_subtitle [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #5: hdmv_pgs_subtitle [spa].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #6: hdmv_pgs_subtitle [fre].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #7: hdmv_pgs_subtitle [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #8: hdmv_pgs_subtitle [spa].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #9: hdmv_pgs_subtitle [fre].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #10: hdmv_pgs_subtitle [eng].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #11: hdmv_pgs_subtitle [spa].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #12: hdmv_pgs_subtitle [fre].
2017-02-14 09:13:26 - mkvtomp4 - INFO - Subtitle detected for stream #13: hdmv_pgs_subtitle [eng].
2017-02-14 09:13:26 - mkvtomp4 - ERROR - No valid subtitle language specified, cannot download subtitles.
2017-02-14 09:13:26 - mkvtomp4 - INFO - Starting conversion.

@zybeon
Copy link
Contributor

zybeon commented Feb 15, 2017

From what I can tell it is copying the video over and only making a iOS compatible track for the 5.1 channel track (Audio #1). So it should only be transcoding that single audio track when making the mp4. No matter your system specs it should not be taking 7 hours.

Can you change "ios-audio" to "false" and try another mkv file with h264/x264 codec?

@mdhiggins
Copy link
Owner

How long it takes to encode/transcode is entirely hardware dependent
If you're doing this on old hardware or a NAS the audio stream alone can take some time
In this case you are transcoding 2 audio streams (DTS to AAC for iOS audio and DTS to AC3 for standard)

Is there anything in the log after "starting conversion" ? There should usually be a printout (it might only be in info.log) of what is being converted and what is being copied

@seanvree
Copy link
Author

Hey guys, everything is working great!

Thanks for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants