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. |
6th October 2020, 07:56 | #1 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
xvid_encraw how to use pipe input?
Looking at 'xvid_encraw -help':
Code:
xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert xvid_encraw built at 20:58:26 on Apr 9 2020 Usage : xvid_encraw [OPTIONS] Input options: -i string : input filename (stdin) -type integer : input data type (yuv=0, pgm=1, avi/avs=2) (0) -w integer : frame width ([1.4096]) -h integer : frame height ([1.4096]) -csp string : colorspace of raw input file i420, yv12 (default) -frames integer : number of frames to encode (all) Output options: -dump : save decoder output -save : save an Elementary Stream file per frame -o string : save an Elementary Stream for the complete sequence -avi string : save an AVI file for the complete sequence Rate control options: -framerate float : target framerate (auto) -bitrate [integer] : target bitrate in kbps (700) -size integer : target size in kilobytes -single : single pass mode (default) -cq float : single pass constant quantizer -pass1 [filename] : twopass mode (first pass) -full1pass : perform full quality first pass (disabled) -pass2 [filename] : twopass mode (2nd pass) -max_key_interval integer : maximum keyframe interval (300) -zones [zones] : use `-help zones' for usage guidelines -zq starting_frame float : bitrate zone; quant -zw starting_frame float : bitrate zone; weight Single Pass options: -reaction integer : reaction delay factor (16) -averaging integer : averaging period (100) -smoother integer : smoothing buffer (100) Second Pass options: -kboost integer : I frame boost (10) -kthresh integer : I frame reduction threshold (1) -kreduction integer : I frame reduction amount (20) -ostrength integer : overflow control strength (5) -oimprove integer : max overflow improvement (5) -odegrade integer : max overflow degradation (5) -chigh integer : high bitrate scenes degradation (0) -clow integer : low bitrate scenes improvement (0) -overhead integer : container frame overhead (0) -vbvsize integer : use vbv buffer size -vbvmax integer : vbv max bitrate -vbvpeak integer : vbv peak bitrate over 1 second BFrames options: -max_bframes integer : max bframes (2) -bquant_ratio integer : bframe quantizer ratio (150) -bquant_offset integer : bframe quantizer offset (100) Other options -noasm : do not use assembly optimized code (use) -turbo : use turbo presets for higher encoding speed (don't use) -quality integer : quality ([0..6]) (6) -vhqmode integer : level of R-D optimizations ([0..4]) (1) -bvhq : use R-D optimizations for B-frames (don't use) -metric integer : distortion metric for R-D opt (PSNR:0, PSNRHVSM:1) (0) -qpel : use quarter pixel ME (don't use) -gmc : use global motion compensation (don't use) -qtype integer : quantization type (H263:0, MPEG4:1) (0) -qmatrix filename : use custom MPEG4 quantization matrix -interlaced [integer] : interlaced encoding (BFF:1, TFF:2) (1) -nopacked : disable packed B-frames mode (enabled) -noclosed_gop : disable closed GOP mode (enabled) -masking [integer] : HVS masking mode (None:0, Lumi:1, Variance:2) (0) -stats : print stats about encoded frames (don't print) -ssim [integer] : print ssim for every frame (accurate: 0 fast: 4) (2) -ssim_file filename : output the ssim stats into a file -psnrhvsm : print PSNRHVSM metric for every frame (don't print) -debug integer : activate xvidcore internal debugging output (don't activate) -vop_debug : print some info directly into encoded frames (don't print) -nochromame : disable chroma motion estimation (enabled) -notrellis : disable trellis quantization (enabled) -imin integer : minimum I Quantizer (1..31) (2) -imax integer : maximum I quantizer (1..31) (31) -bmin integer : minimum B Quantizer (1..31) (2) -bmax integer : maximum B quantizer (1..31) (31) -pmin integer : minimum P Quantizer (1..31) (2) -pmax integer : maximum P quantizer (1..31) (31) -drop integer : frame Drop Ratio (0..100) (0) -start integer : starting frame number (0) -threads integer : number of threads (auto) -slices integer : number of slices (1) -progress [integer] : show progress updates every n frames (10) -par integer[:integer] : set Pixel Aspect Ratio (1) 1 = 1:1 2 = 12:11 (4:3 PAL) 3 = 10:11 (4:3 NTSC) 4 = 16:11 (16:9 PAL) 5 = 40:33 (16:9 NTSC) other = custom (width:height) -help : print this help message NB: You can define up to 8192 zones via both the -zones and the -z[qw] options as needed. Code:
"I:\Hybrid\64bit\ffmpeg.exe" -y -loglevel fatal -i "F:\TestClips&Co\files\test.avi" -map 0:0 -an -sn -pix_fmt yuv420p -f rawvideo - | "I:\Hybrid\64bit\xvid_encraw.exe" -cq 3 -w 640 -h 352 -csp i420 -framerate 25 -o "E:\Temp\test.m4v" Code:
xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert xvidcore build version: xvid-1.3.7 Bitstream version: 1.3.7 Detected CPU flags: ASM MMX MMXEXT SSE SSE2 SSE3 SSE41 TSC Detected 16 cpus, using 16 threads. -1: key=0, time= 0, len= -5 | type=I, quant= 0, len= 0 Tot: enctime(ms) = 0.00, length(bytes) = 0 Avg: enctime(ms) = -1.00, fps =-1000.00, length(bytes) = -1 N frames: 1 frames, size = 0/ 0 The ffmpeg decoding part works fine. (saving to a file instead of piping properly saves yuv data) I tried '-csp yv12', which didn't help. I tried adding '-type 0', which didn't help. I tried adding '-i stdin' or '-i -' but those aborted with 'Error opening input file stdin' and 'Error opening input file -'. => Does anyone know how to use xvid_encraw with pipe input? Cu Selur Ps.: I know when doing no filtering and the input is avi, directly using xvid_encraw might work, but I'd like to use vspipe and ffmpeg to pipe content to xvid_encraw. |
6th October 2020, 10:27 | #2 | Link |
Registered User
Join Date: Dec 2005
Location: Germany
Posts: 1,795
|
Try with -f yuv4mpegpipe instead of rawvideo.
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth VapourSynth Portable FATPACK || VapourSynth Database |
6th October 2020, 10:27 | #3 | Link |
German doom9/Gleitz SuMo
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,783
|
@Selur:
I guess that xvid_encraw is unable to determine the number of frames of a pipe stream (because it cannot seek to the end of a file and possibly returns a size of 0 bytes), so you may have to add the number of frames explicitly as parameter... @ChaosKing: The sources of xvid_encraw don't look like Y4M header parsing is implemented. Even PGM header parsing appears in TODO's. |
6th October 2020, 10:37 | #4 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
@LigH: adding '-frames 429'
Code:
"I:\Hybrid\64bit\ffmpeg.exe" -y -loglevel fatal -i "F:\TestClips&Co\files\test.avi" -map 0:0 -an -sn -pix_fmt yuv420p -f rawvideo - | "I:\Hybrid\64bit\xvid_encraw.exe" -cq 3 -w 640 -h 352 -csp i420 -frames 429 -framerate 25 -o "E:\Temp\test.m4v" xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert xvidcore build version: xvid-1.3.7 Bitstream version: 1.3.7 Detected CPU flags: ASM MMX MMXEXT SSE SSE2 SSE3 SSE41 TSC Detected 16 cpus, using 16 threads. -1: key=0, time= 0, len= -5 | type=I, quant= 0, len= 0 Tot: enctime(ms) = 0.00, length(bytes) = 0 Avg: enctime(ms) = -1.00, fps =-1000.00, length(bytes) @ChaosKing: yuv4mpegpipe doesn't work either and I agree with LigH doesn't seem like there's code to parse y4m headers. |
6th October 2020, 14:17 | #5 | Link | |
SuperVirus
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
|
Quote:
I have just run a fast encoding test... yes, xvid_encraw reads Avisynth files, but does not accept the output(s) from avs2yuv :-/ Anyway, that's not so unexpected from devilopers who think "nobody will ever need more than 64 zones" and believe Cygwin still is relevant |
|
6th October 2020, 15:04 | #7 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
@LigH: last time I checked ffmpeg doesn't support vhq and some other options. (iirc mbd is similar to vhq) -> I'll check that again just to be sure
So atm. I'm stuck with mencoder for xvid encoding. Comparing https://www.ffmpeg.org/ffmpeg-codecs.html#libxvid and http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.txt mencoder clearly wins. A few examples: Code:
mencoder ffmpeg vhq=<0-4> mbd=<simple,bits,rd> qmin/qmin or I/P/B qmin/qmax same for all (or just I ?) quant_intra/inter_matrix no custom matrix as far as I see => It's a pain, but either I find a modified xvid_encraw or I'm stuck with mencoder. Cu Selur Last edited by Selur; 6th October 2020 at 15:40. |
6th October 2020, 16:06 | #8 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
@LigH: since you got an environment setup where you can compile xvid, could you try to compile xvid_encraw with the source from squid_80 http://forum.mediacoderhq.com/viewto...714de0c57709d7 ?
That source seems to define stdin for Windows, but the binary in that thread doesn't seem to work with current xvidcore.dll and the link to the xvidcore.dll which it should work with doesn't work anymore. :/ squid_80 (http://members.optusnet.com.au/squid_80/) also has a 64bit xvid_encraw and a xvid64bit but sadly that doesn't seem to work either. ---- experimenting with the xvid64 and xvid_encraw64 from squid_80: Code:
.. | "C:\Users\Selur\Desktop\xvid_test\xvid_encraw.exe" -o "E:\Temp\test.m4v" Code:
xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert 2002-2003 Trying to retrieve width and height from input header xvid [error]: Bad Framerate 0.000000 (25/1) Code:
.. | "C:\Users\Selur\Desktop\xvid_test\xvid_encraw.exe" -w 640 -h 352 -o "E:\Temp\test.m4v" Code:
xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert 2002-2003 xvid [error]: Bad Framerate 0.000000 (25/1) Code:
.. | "C:\Users\Selur\Desktop\xvid_test\xvid_encraw.exe" -w 640 -h 352 -framerate 25 -o "E:\Temp\test.m4v" Code:
xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert 2002-2003 xvid [warn]: Single pass defaulting to quant 4.00 xvid [info]: Input is 640 x 352, 25.000fps (25/1), starting from frame 0 xvid [info]: xvidcore build version: xvid-1.2.0-dev xvid [info]: Bitstream version: 1.2.-127 xvid [info]: Detected CPU flags: ASM MMX MMXEXT SSE SSE2 TSC xvid [info]: Detected 16 cpus, using 16 threads. 3: key=0, time= 4, len= 3399 | type=I, quant= 4, len= 16093 same with: Code:
.. | "C:\Users\Selur\Desktop\xvid_test\xvid_encraw.exe" -w 640 -h 352 -framerate 25 -frames 429 -type 0 -o "E:\Temp\test.m4v" Code:
... | "C:\Users\Selur\Desktop\xvid_test\xvid_encraw.exe" -w 640 -h 352 -framerate 25 -frames 2 -o "E:\Temp\test.m4v" xvid_encraw - raw mpeg4 bitstream encoder written by Christoph Lampert 2002-2003 xvid [warn]: Single pass defaulting to quant 4.00 xvid [info]: Input is 640 x 352, 25.000fps (25/1), starting from frame 0 xvid [info]: Number of frames to encode: 2 xvid [info]: xvidcore build version: xvid-1.2.0-dev xvid [info]: Bitstream version: 1.2.-127 xvid [info]: Detected CPU flags: ASM MMX MMXEXT SSE SSE2 TSC xvid [info]: Detected 16 cpus, using 16 threads. 1: key=0, time= 2, len= 6 | type=I, quant= 4, len= 16093 -1: key=0, time= 0, len= -5 | type=P, quant= 4, len= 6 Tot: enctime(ms) = 4.00, length(bytes) = 16099 Avg: enctime(ms) = 2.00, fps = 500.00, length(bytes) = 8049 I frames: 1 frames, size = 16093/ 16093, quants = 4 / 4.00 / 4 N frames: 1 frames, size = 6/ 6 Last edited by Selur; 6th October 2020 at 16:43. |
6th October 2020, 21:49 | #9 | Link |
SuperVirus
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
|
Hummm, I have tried some modifications on xvid_encraws's code, but they didn't work as expected :-/
According to squid80's mod, adding "include io.h ++ include fcntl.h" apparently is sufficient only if the compiler = MSVC :-/ Evidently I replaced "MSVC" with "_WIN32" so that the recipe could be used by MinGW, but the effectivel «trick» is less simple than I thought. |
7th October 2020, 10:30 | #10 | Link |
Swallowed in the Sea
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,191
|
I've got something working here using this build within yuv4mpegpipe & stdin switches...
Code:
ffmpeg .... -f yuv4mpegpipe - | xvid -type 0 .... -i stdin -o output.m4v |
7th October 2020, 12:58 | #11 | Link | |
SuperVirus
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
|
Quote:
First, the good part Now encraw.exe's -i stdin accepts the outputs from avs2yuv. Secondly, the bad part :-/ encraw.exe swaps the chroma channels (U & V) when avs2yuv uses the -raw switch and does even worse things when avs2yuv doesn't use the -raw option. My conclusion: now it should be clear that xvid_encraw is just an EXAMPLE application, not a production-model frontend. Therefore in my humble opinion trying to fix it is not worth the hassle :-/ By the way, and just for a comparison, the Theora fanboys were smarter for creating a frontend based on ffmpeg (ffmpeg2theora), instead of trying to reinvent the wheel. |
|
7th October 2020, 13:55 | #12 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
output from:
Code:
"I:\Hybrid\64bit\ffmpeg.exe" -y -loglevel fatal -i "F:\TestClips&Co\files\test.avi" -map 0:0 -an -sn -pix_fmt yuv420p -f yuv4mpegpipe - | "C:\Users\Selur\Desktop\xvid-1.3.7\examples\xvid_encraw.exe" -cq 3 -i stdin -w 640 -h 352 -csp i420 -framerate 25 -o "E:\Temp\test.m4v" @filler5689: have you tried with '-csp i420'? Cu Selur Ps.: strange thing is that '-w 640 -h 352' is still required. Last edited by Selur; 7th October 2020 at 15:39. |
7th October 2020, 14:45 | #13 | Link | |
SuperVirus
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
|
You are right, with "-csp i420" the stupid EXE finally worked as expected.
As I always say, evil devilopers love to choose stupid default settings Quote:
|
|
7th October 2020, 16:02 | #14 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Okay, somwhere I mixed stuff up,
Code:
"I:\Hybrid\64bit\ffmpeg.exe" -y -loglevel fatal -i "F:\TestClips&Co\files\test.avi" -an -sn -pix_fmt yuv420p -f yuv4mpegpipe - | "C:\Users\Selur\Desktop\xvid-1.3.7\examples\xvid_encraw.exe" -type 0 -w 640 -h 352 -csp i420 -framerate 25 -frames 10 -i stdin -o "E:\Output\test.m4v" Code:
"I:\Hybrid\64bit\ffmpeg.exe" -y -loglevel fatal -i "F:\TestClips&Co\files\test.avi" -an -sn -pix_fmt yuv420p -f rawvideo - | "C:\Users\Selur\Desktop\xvid-1.3.7\examples\xvid_encraw.exe" -type 0 -w 640 -h 352 -csp i420 -framerate 25 -frames 10 -i stdin -o "E:\Output\test.m4v" |
7th October 2020, 16:31 | #15 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Argh,... now that xvid_encraw works MP4Box fails me.
A simple: Code:
MP4Box -add "E:\Temp\2020-10-07@17_16_39_1610_01.m4v" -tmp "E:\Temp" -new "E:\Output\2020-10-07@17_16_39_1610__02.mp4" Code:
[Importer] Error probing E:\Temp\2020-10-07@17_16_39_1610_01.m4v Error importing E:\Temp\2020-10-07@17_16_39_1610_01.m4v: Filter not found for the desired type Cu Selur |
7th October 2020, 16:43 | #16 | Link |
SuperVirus
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
|
FWIW,
MP4Box - GPAC version 0.8.0-rev1-gc1990d5c-master is what I've been using since "ages ago". Code:
Filter not found for the desired type https://sourceforge.net/p/gpac/discu...read/43881fa9/ |
7th October 2020, 19:02 | #17 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Okay, muxing to mkv using mkvmerge (v51) doesn't work either,..
Seems like MPEG4 ASP raw streams are not supported by mkvmerge. (https://gitlab.com/mbunkus/mkvtoolnix/-/issues/270) iirc xvid_encraw doesn't use opendml so file size is limited to 2GB which kind of kills .avi as output for me. :/ So to mux to mp4 or mkv one either needs a xvid_encraw version which supports mkv or one needs to use ffmpeg for muxing,.. :/ Last edited by Selur; 7th October 2020 at 19:10. |
8th October 2020, 07:26 | #18 | Link |
German doom9/Gleitz SuMo
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,783
|
MeGUI needs this workaround too: xvid_encraw doesn't create OpenDML AVIs >2GB (and MKV support is marginal, if enabled at all), so it has to create raw MPEG-4 ASP, and then it can't mux it with the optimal tools. Somehow, xvid_encraw is really only a test tool, not a production application.
As already mentioned: It may not even have a YUV4MPEG parser. Hence it doesn't expect any header. @Kurtnoise: Is your magic available as patch, or may it not even work with GCC? Last edited by LigH; 8th October 2020 at 07:29. |
8th October 2020, 09:45 | #19 | Link | |
Swallowed in the Sea
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,191
|
Quote:
Code:
Index: xvidcore/examples/xvid_encraw.c =================================================================== --- xvidcore/examples/xvid_encraw.c (revision 2196) +++ xvidcore/examples/xvid_encraw.c (working copy) @@ -38,6 +38,14 @@ * Use ./xvid_encraw -help for a list of options * ************************************************************************/ +#ifdef _WIN32 +/* The following two defines must be located before the inclusion of any system header files. */ +#define WINVER 0x0500 +#define _WIN32_WINNT 0x0500 +#include <windows.h> +#include <io.h> /* _setmode() */ +#include <fcntl.h> /* _O_BINARY */ +#endif #include <stdio.h> #include <stdlib.h> @@ -350,6 +358,7 @@ double totalenctime = 0.; float totalPSNR[3] = {0., 0., 0.}; + FILE *in_file = stdin; FILE *statsfile; frame_stats_t framestats[7]; @@ -991,6 +1000,12 @@ if (avi_in_stream) AVIStreamRelease(avi_in_stream); AVIFileExit(); } + else if (ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0) { +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif + in_file = stdin; + } else #endif { Sources including this patch are available in the package linked previously... |
|
|
|