Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
27th June 2014, 22:57 | #1 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
Avisynth Sound -> Opus Encoder
Is it possible to pipeline the Output Avisynth has to Opus?
Why i want this is because i do some syncing, and the output will be 32bit float, but if i save it to Wave with Foobar for example, it will become 24bit. So i would like to input the Float directly to Opus to get the best out of it. (Yes i know it's nothing to really be bothered with in terms of quality, but if it can be done, why not. Saves the extra step as well) Thanks! |
28th June 2014, 07:46 | #4 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Nope (EDIT but a good question, and I thought you would be correct, but no)
Code:
ffmpeg.exe -i "test.avs" -vn "test.wav" ... Input #0, avisynth, from 'D:\VideoProjects\raw\test.avs': Duration: 00:00:01.00, start: 0.000000, bitrate: 162 kb/s Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc Stream #0:1: Audio: pcm_f32le, 48000 Hz, 2 channels, flt, 3072 kb/s Output #0, wav, to 'D:\VideoProjects\work\test.wav': Metadata: ISFT : Lavf55.44.100 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16 , 1536 kb/s Metadata: encoder : Lavc55.68.100 pcm_s16le Stream mapping: Stream #0:1 -> #0:0 (pcm_f32le (native) -> pcm_s16le (native)) Last edited by raffriff42; 28th June 2014 at 08:06. |
28th June 2014, 09:20 | #5 | Link | |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Quote:
Unless you want ffmpeg specifically, avs2pipe is quicker and simpler, though. It simply outputs exactly whatever format avisynth is using internally. |
|
28th June 2014, 11:18 | #6 | Link |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
ffmpeg will output whatever AviSynth's output format is if you use copy. AviSynth support is as a demuxer rather than a decoder, so like any other demuxer, copy preserves whatever the input to ffmpeg/output from AviSynth is, just like it would for demuxing any other compression format from its container. It's simply that AviSynth always outputs into the corresponding pcm_***le and rawvideo (as needed pixel format) sinks.
I actually deal with this fairly often because of the bounds issue when resampling with FFMS2 as source filter under AviSynth+'s MT branch. To illustrate: Code:
>ffmsindex -t -1 "draculauntold-tlr1zepk_h1080p.mp4" Writing index... done... 100% >echo FFmpegSource2("draculauntold-tlr1zepk_h1080p.mp4",atrack=-1,fpsnum=24000,fpsden=1001).Lanczos4Resize(720,352).AddBorders(0,64,0,64) 1>"16.9 23.976 draculauntold-tlr1zepk_h1080p.avs" >ffmpeg -i "16.9 23.976 draculauntold-tlr1zepk_h1080p.avs" -vn -acodec copy "16.9 23.976 draculauntold-tlr1zepk_h1080p.wav" ffmpeg version r64294 git-25f8fda Copyright (c) 2000-2014 the FFmpeg developers built on Jun 28 2014 01:34:08 with gcc 4.9.0 (GCC) libavutil 52. 90.101 / 52. 90.101 libavcodec 55. 68.100 / 55. 68.100 libavformat 55. 44.100 / 55. 44.100 libavdevice 55. 13.101 / 55. 13.101 libavfilter 4. 9.100 / 4. 9.100 libavresample 1. 3. 0 / 1. 3. 0 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 Guessed Channel Layout for Input Stream #0.1 : stereo Input #0, avisynth, from '16.9 23.976 draculauntold-tlr1zepk_h1080p.avs': Duration: 00:02:35.45, start: 0.000000, bitrate: 0 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x480, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc Stream #0:1: Audio: pcm_f32le, 44100 Hz, 2 channels, flt, 2822 kb/s [wav @ 093c0360] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead. Output #0, wav, to '16.9 23.976 draculauntold-tlr1zepk_h1080p.wav': Metadata: ISFT : Lavf55.44.100 Stream #0:0: Audio: pcm_f32le ([3][0][0][0] / 0x0003), 44100 Hz, stereo, 2822 kb/s Stream mapping: Stream #0:1 -> #0:0 (copy) Press [q] to stop, [?] for help size= 53552kB time=00:02:35.43 bitrate=2822.4kbits/s video:0kB audio:53552kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000208% Code:
>mediainfo "16.9 23.976 draculauntold-tlr1zepk_h1080p.wav" General Complete name : 16.9 23.976 draculauntold-tlr1zepk_h1080p.wav Format : Wave File size : 52.3 MiB Duration : 2mn 35s Overall bit rate mode : Constant Overall bit rate : 2 822 Kbps Writing application : Lavf55.44.100 Audio Format : PCM Format profile : Float Format settings, Endianness : Little Format settings, Sign : Signed Codec ID : 00001000-0000-0300-8000-00AA00389B71 Codec ID/Hint : IEEE Duration : 2mn 35s Bit rate mode : Constant Bit rate : 2 822 Kbps Channel(s) : 2 channels Channel positions : Front: L R Sampling rate : 44.1 KHz Bit depth : 32 bits Stream size : 52.3 MiB (100%) |
29th June 2014, 03:26 | #7 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
Confused, one say you have to force else it thinks it's 16bit, other says it keeps the original state as Avisynth as a demuxer?
EDIT: Tried avs2pipe, but doesn't seem to work? avs2pipe --audio "test.avs" | opus "-" "out.opus" Last edited by zerowalker; 29th June 2014 at 04:28. |
29th June 2014, 05:07 | #8 | Link | |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
Quote:
If you don't tell ffmpeg what to do via -acodec/-c:a, it defaults to acting as a converter based on the output file's extension. So if you output to .wav but don't use -acodec/-c:a, ffmpeg will convert the output to pcm_s16le. If you tell ffmpeg to use a specific -acodec/-c:a, then it will convert to that format, so long as the output container supports it (it'll complain if it doesn't). And if the particular -acodec/-c:a you tell ffmpeg to use is copy, then it will copy the samples given to it by AviSynth directly to the output, without converting it. Part of the assumption here, at least on my part, is that you should be using the codec specifiers any time you process something through ffmpeg. IMO, there's too much that can go awry if you just leave it up to ffmpeg to auto-select a codec to use, so always tell it which one you want. And in normal cases when you don't want ffmpeg to do anything to the audio and just pass it through, you use copy. This is true regardless of whether it's an MKV file or an MP4 file (with any number of lossless or lossy audio streams to select from) or an AviSynth script (that only outputs uncompressed video and audio). |
|
29th June 2014, 05:37 | #9 | Link | |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
Ah okay, well i tried using ffmpeg copy thing but i am not possible to output to a pipeline no matter how i do it.
Quote:
Even specifying 32bit, 16bit or whatever doesn't work |
|
29th June 2014, 06:46 | #10 | Link |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
opusenc can't accept wav headers through a pipe, then. Or at least not the ones ffmpeg writes. Although it's fine with them if you write the .wav file to disk first. If ffmpeg pipes out as wav, opusenc still requires --raw to handle the input from it. Which opens up more cans of worms because the --raw defaults are not what you want and you'd have to still specify them manually to get around that (and --raw-bits doesn't allow 32, only 24).
Again, as raffriff42 pointed out right at the beginning, there's no reason to pipe here. Just encode as opus from ffmpeg itself. |
29th June 2014, 06:59 | #11 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
I prefer using the original encoder, can't it ignore the wav header with --ignorelength?
And it's ffmpeg that fails the pipe, it doesn't even reach opus. Also if i encode with ffmpeg, it doesn't show the settings, i want the settings to be written to the header, it's quite useful to have that information. |
29th June 2014, 11:19 | #12 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
I had trouble piping wav to opusenc in the past as well but with the current tools this seems to be working (with links to the versions I use):
avs2pipemod -wav "input.avs" | opusenc - "output.opus" (Not sure if --ignorelength is needed. Check that.) Last edited by sneaker_ger; 29th June 2014 at 11:26. |
29th June 2014, 11:26 | #13 | Link | |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Quote:
|
|
29th June 2014, 13:05 | #14 | Link |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
Only if the piped output from the source application would exceed 2GB (or was it 4GB)? As far as I know, that's the only reason an --ignorelength option exists in the audio encoders that have one.
So, it'd be a 'maybe', although it'd probably be a good idea to use just in case. |
29th June 2014, 15:48 | #15 | Link | |
Registered User
Join Date: Nov 2005
Posts: 693
|
If you really want to use opusenc.exe, you shouldn't use -c:a copy at all, as opusenc.exe doesn't accept f32le (or you'll get distorted sound). Instead you should specify/force the format you want to send over the pipe.
Btw, --ignorelength isn't needed either in this case: Quote:
Code:
avs2pipemod.exe -wav input.avs | opusenc.exe (--bitrate 64) - output.opus ffmpeg.exe -i input.avs -c:a libopus (-ab 64k) output.opus ffmpeg.exe -i input.avs -f s24le - | opusenc.exe (--bitrate 64) --raw --raw-bits 24 --raw-rate 44100 - output.opus //and as a bonus... ffmpeg.exe -i input.avs -f f32le - | sox.exe -t f4 -r 44100 -c 2 - -t s3 - rate -v 48k | opusenc.exe (--bitrate 64) --raw --raw-bits 24 - output.opus //...if you want SoX to do the samplerate-conversion. (-f f32le and -t f4 = 32-bit float. -t s3 = 24bit int)
__________________
My hobby website |
|
29th June 2014, 21:09 | #16 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
it works with the avspipemod
Guess i should use "ignorelength" as i use STDIN? Is there any drawback using this? EDIT: Tried using both on and off, seems same length and same size. Guess i should just take the one without it? Last edited by zerowalker; 29th June 2014 at 21:14. |
30th June 2014, 03:32 | #17 | Link | |||
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Quote:
EDIT Before someone says, "32 bits (fixed point) should be enough for anybody," let me quote Wikipedia: Quote:
Quote:
Last edited by raffriff42; 30th June 2014 at 04:16. |
|||
30th June 2014, 04:21 | #18 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
Wait, what does opus do with it then?
I thought it would take 32 bit float, do it's thing with it. It seems to accept f32le though, it worked for me. I am only using 32float as that's the source (after doing some sync stuff with it). I don't care if it's 16 bit when opus is done with it, i just want to give it the "untouched source". |
30th June 2014, 04:44 | #19 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Sorry, I somehow assumed this was for intermediate storage, and you wanted losslessness above all.
If you need Opus for some reason, fine; but convert to 32 bit fixed first as per CoRoNe (unless using ffmpeg, which converts automatically) Code:
ffmpeg.exe -i "test.avs" -vn -c:a opus "test-opus.mka" ... Input #0, avisynth, from 'D:\VideoProjects\test.avs': Duration: 00:00:01.00, start: 0.000000, bitrate: 162 kb/s Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc Stream #0:1: Audio: pcm_f32le, 48000 Hz, 2 channels, flt, 3072 kb/s ... Output #0, matroska, to 'D:\VideoProjects\test-opus.mka': Metadata: encoder : Lavf55.44.100 Stream #0:0: Audio: opus (libopus) ([255][255][255][255] / 0xFFFFFFFF), 4800 0 Hz, stereo, flt, 96 kb/s Metadata: encoder : Lavc55.68.100 libopus Stream mapping: Stream #0:1 -> #0:0 (pcm_f32le (native) -> opus (libopus)) Code:
ffprobe version N-64226-g7e8fdf0 Copyright (c) 2007-2014 the FFmpeg developers ... Input #0, matroska,webm, from 'D:\VideoProjects\test-opus.mka': Metadata: ENCODER : Lavf55.44.100 Duration: 00:00:01.01, start: 0.007000, bitrate: 110 kb/s Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp(default) Metadata: ENCODER : Lavc55.68.100 libopus |
30th June 2014, 04:48 | #20 | Link |
Registered User
Join Date: Jul 2011
Posts: 1,121
|
I simply used the avspipemod -> opus. So i am guessing the results should be the same. Opus get's the entire floating point data, and does it's work on it.
I was only interested in the floating point as that was it's output. For example, in video, i rather give x264 the 16bit output rather than dithering to 8 bit first. (This is when i use 10bit, so i don't waste 2 bit of information). |
Thread Tools | Search this Thread |
Display Modes | |
|
|