-
Notifications
You must be signed in to change notification settings - Fork 206
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
Slow remux to mp4+aac audio. #1117
Comments
Looks like you’re encoding 1 audio stream on your FFMPEG test and copying the eac3 stream and SMA is encoding 2 audio streams and not copying. You need to add eac3 to your audio codec whitelist if you want to copy that stream (audio-codec = aac, eac3)
Additionally you have your max-audio-channel option set to 2 so if that eac3 source is more than 2 channels it won’t copy either so consider removing that limitation.
…Sent from my iPhone
> On Jan 23, 2020, at 6:43 PM, hacktek ***@***.***> wrote:
I'm trying to just remux to mp4 and keep AAC 2-channel audio. What are the optimal settings for this? I'm finding the script is rather slow when compared to plain ffmpeg.
Running this command:
ffmpeg -i "bleh.mkv" -movflags faststart -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 aac -b:a:0 192k -ac 2 -c:a:1 copy /mnt/process/a.mp4
is much faster (and also seems to use much less cpu) than running the automator with these settings:
[MP4]
ffmpeg = /usr/bin/ffmpeg
ffprobe = /usr/bin/ffprobe
threads = 0
output_directory =
copy_to =
move_to =
output_extension = mp4
output_format = mp4
delete_original = True
relocate_moov = True
video-codec = h264,x264
video-bitrate =
video-crf =
video-max-width =
video-profile =
h264-max-level =
use-qsv-decoder-with-encoder = False
use-hevc-qsv-decoder = False
enable_dxva2_gpu_decode = False
ios-audio = True
ios-first-track-only = False
ios-audio-filter =
ios-move-last = False
max-audio-channels = 2
audio-codec = aac
ignore-truehd = true
audio-language =
audio-default-language = eng
audio-channel-bitrate =
audio-filter =
audio-copy-original = False
audio-first-track-of-language = False
subtitle-codec = srt
subtitle-language = eng,spa
subtitle-default-language = eng
subtitle-encoding =
bad-internal-subtitle-sources = pgssub, hdmv_pgs_subtitle, s_hdmv/pgs, dvdsub, dvd_subtitle, dvb_teletext, dvb_subtitle
bad-external-subtitle-sources = dvdsub, dvd_subtitle, dvb_teletext, dvb_subtitle
fullpathguess = True
convert-mp4 = False
force-convert = False
tagfile = False
tag-language = en
download-artwork = Poster
download-subs = False
embed-subs = False
embed-only-internal-subs = False
sub-providers = addic7ed,podnapisi,thesubdb,opensubtitles
permissions = 0777
post-process = False
pix-fmt =
aac_adtstoasc = False
postopts =
temp_extension = samconvert
preopts =
The file I'm testing is an hour an a half, 720p with ~3.7 Mbps bitrate.
Here's the time output of the ffmpeg command:
time ffmpeg -i "bleh.mkv" -movflags faststart -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 aac -b:a:0 192k -ac 2 -c:a:1 copy /mnt/process/a.mp4
...
frame=140739 fps=687 q=-1.0 size= 2193152kB time=01:18:16.06 bitrate=3825.8kbits/s speed=22.9xframe=141151 fps=687 q=-1.0 size= 2201856kB time=01:18:29.72 bitrate=3829.9kbits/s speed=22.9xframe=141466 fps=687 q=-1.0 size= 2205440kB time=01:18:40.38 bitrate=3827.4kbits/s speed=22.9x[mp4 @ 0x55a9e3548f40] Starting second pass: moving the moov atom to the beginning of the file
frame=141621 fps=522 q=-1.0 Lsize= 2211971kB time=01:18:45.54 bitrate=3834.6kbits/s speed=17.4x
video:1723949kB audio:482467kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.251764%
[aac @ 0x55a9e3567400] Qavg: 920.201
real 4m33.642s
user 3m18.750s
sys 0m4.973s
And here's the time of SMA:
time ./manual.py -a -i "bleh.mkv" -nt
Manual processor started.
/usr/bin/python
Audio bitrate was invalid, defaulting to 256 per channel.
64bit Python.
No-tagging enabled
Reading video stream.
Video codec detected: h264.
Pix Fmt: yuv420p.
Profile: Main.
Reading audio streams.
No audio streams detected in any appropriate language, relaxing restrictions so there will be some audio stream present.
Audio detected for stream #1: eac3 [eng].
Creating audio stream 0 from source audio stream 1 [iOS-audio].
Creating audio stream 1 from source stream 1.
Reading subtitle streams.
Subtitle detected for stream #2: subrip [eng].
Ripping eng subtitle from source stream 2 into external file.
bleh.eng.4.srt created.
Subtitle stream array is empty.
{
"preopts": [],
"subtitle": {},
"format": "mp4",
"postopts": [
"-threads",
"0"
],
"video": {
"profile": null,
"map": 0,
"level": null,
"codec": "copy",
"bitrate": 2841.37115,
"pix_fmt": null
},
"audio": {
"0": {
"map": 1,
"language": "eng",
"channels": 2,
"codec": "aac",
"disposition": "default",
"bitrate": 256,
"filter": null
},
"1": {
"map": 1,
"language": "eng",
"channels": 2,
"codec": "aac",
"disposition": "none",
"bitrate": 512,
"filter": null
}
}
}
Starting conversion.
...
Relocating MOOV atom to start of file.
real 17m7.167s
user 16m18.004s
sys 0m8.937s
Am I doing something wrong?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
OK I'll try that. Thanks! |
OK so I added aac,ac3,eac3 and it seems to have improved tremendously. Thinking about other codecs, DTS sometimes comes up. Is there a catch-all way of copying any and all codecs and then just creating a single AAC stereo track using the ios-audio option? |
Rather than using the iOS audio option, you could set your max channels to 2, your codec to AAC, and then the audio-copy-original option to True Careful though depending on your source files; not all formats work in the mp4 container so blind copying everything can result in failures, its probably better to just whitelist the handful of codecs you want so they are copied most of the time unless you know all your input files will be safe. |
Right. I ended up with this list: audio-codec = aac,mp3,dca,ac3,eac3,dts IOS audio and original quality are turned off. I know DTS isn't supported in mp4 but without adding it to the list those particular encodes took way too long for my liking (i7-3770). What I mostly aim to achieve with SMA is extracting subs because things seem to direct play way more often when subs are text and external. Plex should take care of transcoding DTS audio on the fly and direct streaming video from the MP4 container which I'm fine with since that takes very little cpu. |
I actually had to remove DTS from the list as testing on several devices I found at least one Android device that would not play mp4+dts when subtitles were enabled (either embedded or external). This leads me to a question about the performance of DTS->AAC conversion. I'm currently seeing very poor performance on the aforementioned hardware and I'm trying to figure out if this is normal. SMA is currently doing this:
So it's converting DTS to AAC and also copying the original DTS stream. It's currently taking about 2 minutes per 5% which extrapolating would mean about 40 minutes to transcode audio and that just feels incredibly slow for an audio only transcode. Am I doing something wrong? Is there a log somewhere I could look at? The current machine load, while transcoding: 22:51:51 up 6 days, 23:42, 3 users, load average: 3.37, 4.24, 5.95 My current config:
Thanks |
Might be normal. You’re doing 6 channel AAC instead of 2 channel in your initial FFMPEG comparison though and 6 channel will take longer
…Sent from my iPhone
On Jan 28, 2020, at 4:50 PM, hacktek ***@***.***> wrote:
I actually had to remove DTS from the list as testing on several devices I found at least one Android device that would not play mp4+dts when subtitles were enabled (either embedded or external).
This leads me to a question about the performance of DTS->AAC conversion. I'm currently seeing very poor performance on the aforementioned hardware and I'm trying to figure out if this is normal.
SMA is currently doing this:
{
"preopts": [],
"subtitle": {},
"format": "mp4",
"postopts": [
"-threads",
"4"
],
"video": {
"profile": null,
"map": 0,
"level": null,
"codec": "copy",
"bitrate": 9490.5171,
"pix_fmt": null
},
"audio": {
"0": {
"map": 1,
"language": "chi",
"channels": 6,
"codec": "aac",
"disposition": "default",
"bitrate": 1536,
"filter": null
},
"1": {
"map": 1,
"codec": "copy",
"disposition": "none",
"language": "chi"
}
}
}
So it's converting DTS to AAC and also copying the original DTS stream. It's currently taking about 2 minutes per 5% which extrapolating would mean about 10 minutes to transcode audio and that just feels incredibly slow for an audio only transcode. Am I doing something wrong? Is there a log somewhere I could look at?
My current config:
[MP4]
ffmpeg = /usr/bin/ffmpeg
ffprobe = /usr/bin/ffprobe
threads = 4
output_directory =
copy_to =
move_to =
output_extension = mp4
output_format = mp4
delete_original = True
relocate_moov = True
video-codec = h264vaapi,h264,x264
video-bitrate =
video-crf =
video-max-width =
video-profile =
h264-max-level =
use-qsv-decoder-with-encoder = False
use-hevc-qsv-decoder = False
enable_dxva2_gpu_decode = False
ios-audio = False
ios-first-track-only = False
ios-audio-filter =
ios-move-last = False
max-audio-channels =
audio-codec = aac,mp3,dca,ac3,eac3
ignore-truehd = true
audio-language =
audio-default-language = eng
audio-channel-bitrate =
audio-filter =
audio-copy-original = True
audio-first-track-of-language = False
subtitle-codec = srt
subtitle-language = eng,spa
subtitle-default-language = eng
subtitle-encoding =
bad-internal-subtitle-sources = pgssub, hdmv_pgs_subtitle, s_hdmv/pgs, dvdsub, dvd_subtitle, dvb_teletext, dvb_subtitle
bad-external-subtitle-sources = dvdsub, dvd_subtitle, dvb_teletext, dvb_subtitle
fullpathguess = True
convert-mp4 = False
force-convert = False
tagfile = False
tag-language = en
download-artwork = Poster
download-subs = False
embed-subs = False
embed-only-internal-subs = False
sub-providers = addic7ed,podnapisi,thesubdb,opensubtitles
permissions = 0777
post-process = False
pix-fmt =
aac_adtstoasc = False
postopts =
temp_extension = samconvert
preopts =
Thanks
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I'm running a few more ffmpeg vanilla tests. Looks like the bitrate might have something to do with it. The speed for 256k:
is much faster when compared to 1536k:
Two audio channels also seems to have been better than 6. For 256k, 6 channel conversion took ~11 minutes and 2 channel conversion took ~6 minutes. I'll play with the settings some more. One final question: do the bitrate and channel limits apply to whitelisted codecs? Meaning, if I set a 2 channel limit, will that transcode AC3 or EAC3 content even though they're specified in audio-codec=? |
They do. Anything exceeding your settings will be transcoded down. Things that are less will be copied. |
Bummer. I was hoping to only do this for DTS since I copy all of the other codecs. Any chance of adding a flag so you can control this behavior in a future update? |
Not really, its kind of an odd scenario that you'd want to create a stereo track only for a specific codec Why note just use the iOS audio option and leave DTS off the whitelist? Then everything not DTS will be copied appropriately and be MP4 friendly, you'll still get your stereo AAC track, and you'll have full MP4 compatibility Alternatively you could use MKV containers and keep DTS on the whitelist. You'll still get the AAC track creation |
I'm currently using this and I'm happy with the performance:
Will enabling ios-audio change anything in this case? Also, I'm not sure if this is a bug but I had to set audio-bitrate to 128 so the ffmpeg command actually used 256. See here:
EDIT: nevermind that last bit, just saw it's per channel. If you can let me know if enabling ios-audio would make any difference than we can consider this closed. |
Nah the point of iOS audio is to create a separate two channel audio track so if you just want to have a single stereo track this will do the trick |
I'm trying to just remux to mp4 and keep AAC 2-channel audio. What are the optimal settings for this? I'm finding the script is rather slow when compared to plain ffmpeg.
Running this command:
ffmpeg -i "bleh.mkv" -movflags faststart -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 aac -b:a:0 192k -ac 2 -c:a:1 copy /mnt/process/a.mp4
is much faster (and also seems to use much less cpu) than running the automator with these settings:
The file I'm testing is an hour an a half, 720p with ~3.7 Mbps bitrate.
Here's the time output of the ffmpeg command:
And here's the time of SMA:
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: