Log in

View Full Version : Encoding on Linux how?


fabje
4th February 2013, 10:31
Hello,

Right now I'm encoding everything using StaxRip on Windows.
But I want to try something different so in this case I want to test if I can get it to run on a Linux machine.

Right now all my recordings are H.264/AVC Transport Stream (ts) files. Including an AC3 audio file. And at this moment I'm using the deinterlace filter called Yadif and the resizer Lanczos.

Anyone here has an idea how I can do this?

Selur
4th February 2013, 13:25
if FFVideoSource can handle the video stream, so should mencoder&ffmpeg, if mencoder/ffmpeg can't handle your streams your probably lost unless you use wine.
Assuming ffmpeg/mencoder can handle your streams, you got a lot of choices:
a. using a shell script like h264enc (http://h264enc.sourceforge.net/)
b. using x264 directly assuming it's compiled with libav support
c. using one of the many encoding frontends like: handbrake, AviDemux, Hybrid,...

Cu Selur

fabje
5th February 2013, 22:09
Righ now I'm using this.
/usr/bin/mencoder test.ts -o test.mkv -ovc x264 -vf scale=1280:720:1 -sws 9 -oac copy
But when I use this I have this kind of messages:
1 duplicate frame(s)!
And also this one:
Too many video packets in the buffer: (1114 in 33578402 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.
[ac3 @ 0xd58e60]incomplete frame
Any idea how to solve this?

Selur
6th February 2013, 06:10
1 duplicate frame(s)!
adding '-noskip' should help with the duplicate frame(s) info

about the 'too many video packets' can have multiple reasons, e.g. wrong demuxer, wrong decoder, broken stream, interlaced content not handled properly, vfr input,...

fabje
6th February 2013, 17:11
adding '-noskip' should help with the duplicate frame(s) info

about the 'too many video packets' can have multiple reasons, e.g. wrong demuxer, wrong decoder, broken stream, interlaced content not handled properly, vfr input,...
I still get that "1 duplicate frame(s)!" error.

This is what kind of response I get as soon as I start it:
Encode:/home/test/test # /usr/bin/mencoder test.ts -o test.mkv -ovc x264 -vf scale=1280:720:1 -sws 9 -noskip -oac copy
MEncoder dev-SVN-r35127-4.7-openSUSE Linux 12.2 (x86_64)-Packman (C) 2000-2012 MPlayer Team

WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
success: format: 0 data: 0x0 - 0xd1b3d758
libavformat version 54.25.104 (internal)
TS file format detected.
VIDEO H264(pid=161) AUDIO A52(pid=33) SUB Teletext(pid=174) PROGRAM N. 203
FPS seems to be: 25.000000
[V] filefmt:29 fourcc:0x10000005 size:1920x1088 fps:25.000 ftime:=0.0400
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 54.54.100 (internal)
[ac3 @ 0xd58e60]frame sync error
AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000)
Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=1280 h=720 interlaced=1]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=56000 sample-1)
Unsupported PixelFormat 61
Unsupported PixelFormat 53
Unsupported PixelFormat 81
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
[swscaler @ 0xe313c0]Lanczos scaler, from yuv420p to yuv420p using MMX2
[swscaler @ 0xe313c0]Lanczos scaler, from yuv420p to yuv420p using MMX2
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile High, level 3.1

Any tips what to do?

Selur
6th February 2013, 22:10
You can try if it helps to specify:
-lavdopts -demuxer lavf -vfm ffmpeg
additionally, but other than that no clue

fabje
6th February 2013, 22:33
You can try if it helps to specify:
-lavdopts -demuxer lavf -vfm ffmpeg
additionally, but other than that no clue
Thanks for the suggestion but it doesn't help.

I upload a part of a capture can you maybe find out how to solve it? You can download it here (http://www.fabje.eu/test.1min.ts).

Selur
7th February 2013, 10:12
adding '-mc 0 -noskip' get's rid of the 'Skipping frame!' message

fabje
7th February 2013, 12:15
Alright that works :)

Encode:/home/test # /usr/bin/mencoder test.ts -o test.mkv -ovc x264 -vf scale=1280:720:0 -sws 9 -mc 0 -noskip -oac copy
MEncoder dev-SVN-r35127-4.7-openSUSE Linux 12.2 (x86_64)-Packman (C) 2000-2012 MPlayer Team

WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
success: format: 0 data: 0x0 - 0xd1b3d758
libavformat version 54.25.104 (internal)
TS file format detected.
VIDEO H264(pid=161) AUDIO A52(pid=33) SUB Teletext(pid=174) PROGRAM N. 203
FPS seems to be: 25.000000
[V] filefmt:29 fourcc:0x10000005 size:1920x1088 fps:25.000 ftime:=0.0400
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 54.54.100 (internal)
[ac3 @ 0xd58e60]frame sync error
AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000)
Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=1280 h=720 interlaced=0]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=56000 sample-1)
Unsupported PixelFormat 61
Unsupported PixelFormat 53
Unsupported PixelFormat 81
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
[swscaler @ 0xe313c0]Lanczos scaler, from yuv420p to yuv420p using MMX2
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile High, level 3.1
Pos: 2.0s 105f ( 0%) 55.91fps Trem: 24min 0mb A-V:0.000 [0:448]
Writing header...
ODML: vprp aspect is 16:9.
Setting audio delay to 0.080s.
Writing header...
ODML: vprp aspect is 16:9.
Setting audio delay to 0.080s.
Pos: 147.6s 7384f ( 7%) 24.49fps Trem: 63min 560mb A-V:0.000 [1877:448]
[h264 @ 0xd58e60]error while decoding MB 88 66, bytestream (-10)
Pos: 250.0s 12509f (12%) 25.03fps Trem: 59min 522mb A-V:0.000 [1716:448]
[h264 @ 0xd58e60]Reference 2 >= 2
[h264 @ 0xd58e60]error while decoding MB 10 67, bytestream (153)
Pos: 295.8s 14794f (14%) 24.96fps Trem: 57min 509mb A-V:0.000 [1660:448]
[h264 @ 0xd58e60]left block unavailable for requested intra4x4 mode -1 at 0 38
[h264 @ 0xd58e60]error while decoding MB 0 38, bytestream (51833)
Pos: 501.8s 25098f (24%) 23.87fps Trem: 53min 552mb A-V:0.000 [1833:448]
[h264 @ 0xd58e60]Reference 4 >= 2
[h264 @ 0xd58e60]error while decoding MB 114 26, bytestream (46819)
Pos: 581.2s 29067f (28%) 23.39fps Trem: 51min 555mb A-V:0.000 [1846:448]
[h264 @ 0xd58e60]Reference 4 >= 2
[h264 @ 0xd58e60]error while decoding MB 65 57, bytestream (7991)
Pos: 893.5s 44682f (44%) 23.36fps Trem: 40min 541mb A-V:0.000 [1788:448]
[h264 @ 0xd58e60]left block unavailable for requested intra mode at 0 50
[h264 @ 0xd58e60]error while decoding MB 0 50, bytestream (61700)
Pos: 963.2s 48164f (47%) 23.30fps Trem: 38min 545mb A-V:0.000 [1807:448]
[h264 @ 0xd58e60]Reference 3 >= 2
[h264 @ 0xd58e60]error while decoding MB 42 40, bytestream (31343)
Pos:1085.1s 54262f (53%) 23.30fps Trem: 33min 533mb A-V:0.000 [1755:448]
[h264 @ 0xd58e60]Reference 2 >= 2
[h264 @ 0xd58e60]error while decoding MB 27 64, bytestream (3344)
Pos:1372.0s 68608f (67%) 22.88fps Trem: 23min 528mb A-V:0.000 [1734:448]
[h264 @ 0xd58e60]Reference 3 >= 2
[h264 @ 0xd58e60]error while decoding MB 93 32, bytestream (55934)
Pos:1918.2s 95916f (94%) 22.76fps Trem: 4min 532mb A-V:0.000 [1752:448]
[h264 @ 0xd58e60]Reference 4 >= 2
[h264 @ 0xd58e60]error while decoding MB 21 50, bytestream (27126)
Pos:2028.7s 101439f (100%) 22.76fps Trem: 0min 536mb A-V:0.000 [1770:448]

Flushing video frames.
Writing index...
Writing header...
ODML: vprp aspect is 16:9.
Setting audio delay to 0.080s.

Video stream: 1772.161 kbit/s (221520 B/s) size: 449393543 bytes 2028.680 secs 101439 frames

Audio stream: 448.000 kbit/s (56000 B/s) size: 113620720 bytes 2028.941 secs
x264 [info]: frame I:512 Avg QP:20.46 size: 62267
x264 [info]: frame P:23129 Avg QP:23.85 size: 14338
x264 [info]: frame B:27076 Avg QP:26.05 size: 3172
x264 [info]: consecutive B-frames: 16.1% 32.1% 18.5% 33.3%
x264 [info]: mb I I16..4: 17.8% 65.3% 16.9%
x264 [info]: mb P I16..4: 2.6% 6.1% 0.7% P16..4: 40.7% 11.0% 7.1% 0.0% 0.0% skip:31.8%
x264 [info]: mb B I16..4: 0.1% 0.3% 0.0% B16..8: 36.3% 2.0% 0.4% direct: 0.9% skip:60.1% L0:37.6% L1:59.3% BI: 3.0%
x264 [info]: 8x8 transform intra:65.2% inter:79.9%
x264 [info]: coded y,uvDC,uvAC intra: 53.1% 58.7% 17.5% inter: 13.6% 15.3% 0.3%
x264 [info]: i16 v,h,dc,p: 35% 21% 5% 39%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 18% 19% 6% 8% 8% 8% 7% 7%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 12% 6% 8% 8% 7% 6% 5%
x264 [info]: i8c dc,h,v,p: 56% 18% 19% 7%
x264 [info]: Weighted P-Frames: Y:4.5% UV:2.3%
x264 [info]: ref P L0: 64.6% 16.5% 13.5% 5.1% 0.2%
x264 [info]: ref B L0: 87.6% 11.0% 1.4%
x264 [info]: ref B L1: 95.1% 4.9%
x264 [info]: kb/s:1772.16

Only after the encode my audio is out of sync. I have checked the source file with VideoRedo on errors and the source file is error free.

Any idea?

Also how can I crop at all sides so the bottom/top/left and right side only 1 pixel?
And is it possible to only encode from start frame lets say 1000 or 1 minute until the end?

Selur
7th February 2013, 16:29
Also how can I crop at all sides so the bottom/top/left and right side only 1 pixel?
not sure if mencoder supports it, but an additional color space convertion from Yv12 to RGB to Yv12 would be needed since Yv12 only allows to crop even values (2,4,6,...).
if you use even values, you can simply use crop:
crop[=w:h:x:y]
Crops the given part of the image and discards the rest. Useful
to remove black bands from widescreen movies.
<w>,<h>
Cropped width and height, defaults to original width and
height.
<x>,<y>
Position of the cropped picture, defaults to center.source: http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.txt


And is it possible to only encode from start frame lets say 1000 or 1 minute until the end?
-ss <time> (also see -sb)
Seek to given time position.

EXAMPLE:
-ss 56
Seeks to 56 seconds.
-ss 01:10:00
Seeks to 1 hour 10 min.
-endpos <[[hh:]mm:]ss[.ms]|size[b|kb|mb]> (also see -ss and -sb)
Stop at given time or byte position.
NOTE: Byte position may not be accurate, as it can only stop at
a frame boundary. When used in conjunction with -ss option,
-endpos time will shift forward by seconds specified with -ss if
not a byte position.

EXAMPLE:
-endpos 56
Stop at 56 seconds.
-endpos 01:10:00
Stop at 1 hour 10 minutes.
-ss 10 -endpos 56
Stop at 1 minute 6 seconds.
mplayer -endpos 100mb
Stop playback after reading 100MB of the input file.
mencoder -endpos 100mb
Encode only 100 MB.source: http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.txt

Cu Selur