lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.37k stars 160 forks source link

Can this be used with MythTV mpeg recordings? #134

Closed wicadmin closed 7 years ago

wicadmin commented 7 years ago

I am trying to run this in batch off hours to trans-code my MythTV recordings which are in mpeg format to get the same quality (perceivable) but smaller file size. If this can work on mpeg, what would the recommended format to trans-code to? The viewing will be done on 720p displays.

lisamelton commented 7 years ago

@2devnull The output format depends on your output device or player. If it's an Apple TV or iTunes then I would recommend using the --mp4 option. Otherwise, I would use the default setting which produces MKV format.

Any other questions?

wicadmin commented 7 years ago

I'll keep the MKV then. I am testing it out now. Running my CPU high. Anyway to get it to use the GPU if I install one?

wicadmin commented 7 years ago

BTW - here is my test run. Brought down the 1.4 GB MPEG-2 file to 449 MB:

root@aa0976a91f59:/data# transcode-video --quick 1651_20170303030000.mpg 
[23:54:56] hb_init: starting libhb thread
[23:54:56] thread 7f7408dc0700 started ("libhb")
HandBrake 1.0.2 (2017012400) - Linux x86_64 - https://handbrake.fr
6 CPUs detected
Opening 1651_20170303030000.mpg...
[23:54:56] CPU: AMD Phenom(tm) II X6 1045T Processor
[23:54:56]  - logical processor count: 6
[23:54:56] hb_scan: path=1651_20170303030000.mpg, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:274: failed opening UDF image 1651_20170303030000.mpg
disc.c:352: error opening file BDMV/index.bdmv
disc.c:352: error opening file BDMV/BACKUP/index.bdmv
[23:54:56] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[23:54:56] dvd: not a dvd - trying as a stream/file instead
[23:54:56] file is MPEG Program Stream
[23:54:56] Probing 1 unknown stream
[23:54:57]     Probe: Found stream mpeg2video. stream id 0xe0-0x0
[23:54:57] Found the following streams
[23:54:57]     Video Streams : 
[23:54:57]       0xe0-0x0 type MPEG2 (0x2)
[23:54:57]     Audio Streams : 
[23:54:57]       0xbd-0x80 type AC3 (0x81)
[23:54:57]       0xbd-0x81 type AC3 (0x81)
[23:54:57]     Subtitle Streams : 
[23:54:57]     Other Streams : 
[23:54:57] stream id 0xbd (type 0x81 substream 0x80) audio 0x8000bd
[23:54:57] stream id 0xbd (type 0x81 substream 0x81) audio 0x8100bd
[23:54:57] scan: decoding previews for title 1
[23:54:57] file is MPEG Program Stream
[23:54:57] Probing 1 unknown stream
Scanning title 1 of 1, preview 1, 0.00 %[23:54:57]     Probe: Found stream mpeg2video. stream id 0xe0-0x0
[23:54:57] scan: audio 0x8000bd: ac3, rate=48000Hz, bitrate=256000 Unknown (AC3) (2.0 ch) (Dolby Surround)
[23:54:57] scan: audio 0x8100bd: ac3, rate=48000Hz, bitrate=256000 Unknown (AC3) (2.0 ch) (Dolby Surround)
Scanning title 1 of 1, preview 8, 80.00 %[23:54:57] stream: 69 good frames, 0 errors (0%)
[23:54:57] scan: 10 previews, 1280x720, 59.940 fps, autocrop = 0/2/0/0, aspect 16:9, PAR 1:1
[23:54:57] libhb: scan thread found 1 valid title(s)
+ Using preset: CLI Default
+ title 1:
  + stream: 1651_20170303030000.mpg
  + duration: 00:19:47
  + size: 1280x720, pixel aspect: 1/1, display aspect: 1.78, 59.940 fps
  + autocrop: 0/2/0/0
  + support opencl: no
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:19:47
  + audio tracks:
    + 1, Unknown (AC3) (2.0 ch) (Dolby Surround) (iso639-2: und), 48000Hz, 256000bps
    + 2, Unknown (AC3) (2.0 ch) (Dolby Surround) (iso639-2: und), 48000Hz, 256000bps
  + subtitle tracks:
    + 1, Closed Captions (iso639-2: und) (Text)(CC)
[23:54:58] 1 job(s) to process
[23:54:58] json job:
{
    "Audio": {
        "AudioList": [
            {
                "Encoder": 65536,
                "Track": 0
            }
        ],
        "CopyMask": [
            "copy:aac",
            "copy:ac3",
            "copy:eac3",
            "copy:dtshd",
            "copy:dts",
            "copy:mp3",
            "copy:truehd",
            "copy:flac"
        ],
        "FallbackEncoder": "av_aac"
    },
    "Destination": {
        "ChapterList": [
            {
                "Name": "Chapter 1"
            }
        ],
        "ChapterMarkers": false,
        "File": "1651_20170303030000.mkv",
        "Mp4Options": {
            "IpodAtom": false,
            "Mp4Optimize": false
        },
        "Mux": "mkv"
    },
    "Filters": {
        "FilterList": [
            {
                "ID": 6,
                "Settings": {
                    "mode": 2,
                    "rate": "27000000/900000"
                }
            },
            {
                "ID": 11,
                "Settings": {
                    "crop-bottom": 0,
                    "crop-left": 0,
                    "crop-right": 0,
                    "crop-top": 0,
                    "height": 720,
                    "width": 1280
                }
            }
        ]
    },
    "Metadata": {},
    "PAR": {
        "Den": 1,
        "Num": 1
    },
    "SequenceID": 0,
    "Source": {
        "Angle": 0,
        "Path": "1651_20170303030000.mpg",
        "Range": {
            "End": 1,
            "Start": 1,
            "Type": "chapter"
        },
        "Title": 1
    },
    "Subtitle": {
        "Search": {
            "Burn": true,
            "Default": false,
            "Enable": false,
            "Forced": false
        },
        "SubtitleList": []
    },
    "Video": {
        "ColorMatrixCode": 0,
        "Encoder": "x264",
        "Level": "3.1",
        "OpenCL": false,
        "Options": "vbv-maxrate=3000:vbv-bufsize=6000:crf-max=25:qpmax=34:partitions=none:ref=1:rc-lookahead=30",
        "Preset": "medium",
        "Profile": "high",
        "QSV": {
            "AsyncDepth": 4,
            "Decode": false
        },
        "Quality": 1.0,
        "Tune": "",
        "Turbo": false,
        "TwoPass": false
    }
}
[23:54:58] starting job
[23:54:58] work: mixdown not specified, track 1 setting mixdown Dolby Surround
[23:54:58] work: bitrate not specified, track 1 setting bitrate 160 Kbps
[23:54:58] job configuration:
[23:54:58]  * source
[23:54:58]    + 1651_20170303030000.mpg
[23:54:58]    + title 1, chapter(s) 1 to 1
[23:54:58]  * destination
[23:54:58]    + 1651_20170303030000.mkv
[23:54:58]    + container: Matroska (libavformat)
[23:54:58]  * video track
[23:54:58]    + decoder: mpeg2video
[23:54:58]      + bitrate 9500 kbps
[23:54:58]    + filters
[23:54:58]      + Framerate Shaper (mode=2:rate=27000000/900000)
[23:54:58]        + frame rate: 59.940 fps -> peak rate limited to 30.000 fps
[23:54:58]      + Crop and Scale (width=1280:height=720:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[23:54:58]        + source: 1280 * 720, crop (0/0/0/0): 1280 * 720, scale: 1280 * 720
[23:54:58]    + Output geometry
[23:54:58]      + storage dimensions: 1280 x 720
[23:54:58]      + pixel aspect ratio: 1 : 1
[23:54:58]      + display dimensions: 1280 x 720
[23:54:58]    + encoder: H.264 (libx264)
[23:54:58]      + preset:  medium
[23:54:58]      + options: vbv-maxrate=3000:vbv-bufsize=6000:crf-max=25:qpmax=34:partitions=none:ref=1:rc-lookahead=30
[23:54:58]      + profile: high
[23:54:58]      + level:   3.1
[23:54:58]      + quality: 1.00 (RF)
[23:54:58]  * audio track 1
[23:54:58]    + decoder: Unknown (AC3) (2.0 ch) (Dolby Surround) (track 1, id 0x8000bd)
[23:54:58]      + bitrate: 256 kbps, samplerate: 48000 Hz
[23:54:58]    + mixdown: Dolby Surround
[23:54:58]    + encoder: AAC (libavcodec)
[23:54:58]      + bitrate: 160 kbps, samplerate: 48000 Hz
[23:54:58] file is MPEG Program Stream
[23:54:58] Probing 1 unknown stream
[23:54:58]     Probe: Found stream mpeg2video. stream id 0xe0-0x0
[23:54:58] sync: expecting 71174 video frames
[23:54:58] encx264: min-keyint: 60, keyint: 600
[23:54:58] encx264: encoding at constant RF 1.000000
[23:54:58] encx264: unparsed options: vbv-maxrate=3000:vbv-bufsize=6000:crf-max=25:qpmax=34:level=3.1:ref=1:analyse=none:rc-lookahead=30
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT
Encoding: task 1 of 1, 0.00 %x264 [info]: profile High, level 3.1
[23:54:58] sync: first pts video is 1791
Encoding: task 1 of 1, 0.00 %[23:54:59] sync: first pts audio 0x8000bd is 0
Encoding: task 1 of 1, 7.58 % (124.40 fps, avg 124.57 fps, ETA 00h08m48s)[23:55:42] sync: video time went backwards 16 ms, dropped 1 frames. PTS 8117698
Encoding: task 1 of 1, 15.97 % (127.74 fps, avg 128.09 fps, ETA 00h07m47s)[23:56:27] sync: video time went backwards 16 ms, dropped 1 frames. PTS 17131202
Encoding: task 1 of 1, 17.08 % (129.57 fps, avg 128.20 fps, ETA 00h07m41s)x264 [warning]: VBV underflow (frame 6035, -135600 bits)
Encoding: task 1 of 1, 17.33 % (127.97 fps, avg 128.19 fps, ETA 00h07m39s)x264 [warning]: VBV underflow (frame 6125, -15104 bits)
Encoding: task 1 of 1, 20.21 % (126.57 fps, avg 128.28 fps, ETA 00h07m23s)[23:56:51] sync: video time went backwards 16 ms, dropped 1 frames. PTS 21640206
Encoding: task 1 of 1, 26.17 % (127.22 fps, avg 127.97 fps, ETA 00h06m50s)[ac3 @ 0x7f73f8001f60] exponent out-of-range
Encoding: task 1 of 1, 30.51 % (126.55 fps, avg 127.79 fps, ETA 00h06m27s)[23:57:49] sync: video time went backwards 16 ms, dropped 1 frames. PTS 32662410
Encoding: task 1 of 1, 37.11 % (129.45 fps, avg 127.67 fps, ETA 00h05m50s)[23:58:25] sync: video time went backwards 16 ms, dropped 1 frames. PTS 39695935
Encoding: task 1 of 1, 40.96 % (125.24 fps, avg 127.85 fps, ETA 00h05m29s)[23:58:46] sync: video time went backwards 16 ms, dropped 1 frames. PTS 43787522
Encoding: task 1 of 1, 49.37 % (131.56 fps, avg 127.28 fps, ETA 00h04m43s)[23:59:35] sync: video time went backwards 16 ms, dropped 1 frames. PTS 52799526
Encoding: task 1 of 1, 53.56 % (126.98 fps, avg 127.33 fps, ETA 00h04m20s)[23:59:58] sync: video time went backwards 16 ms, dropped 1 frames. PTS 57308530
Encoding: task 1 of 1, 57.85 % (119.41 fps, avg 125.04 fps, ETA 00h04m00s)[00:00:28] sync: video time went backwards 16 ms, dropped 1 frames. PTS 61817534
Encoding: task 1 of 1, 62.82 % (118.37 fps, avg 124.46 fps, ETA 00h03m33s)[00:00:58] sync: video time went backwards 16 ms, dropped 1 frames. PTS 67134075
Encoding: task 1 of 1, 71.23 % (125.98 fps, avg 123.65 fps, ETA 00h02m46s)[00:01:49] sync: video time went backwards 16 ms, dropped 1 frames. PTS 76146079
Encoding: task 1 of 1, 75.46 % (120.41 fps, avg 123.43 fps, ETA 00h02m22s)[00:02:14] sync: video time went backwards 16 ms, dropped 1 frames. PTS 80655083
Encoding: task 1 of 1, 79.66 % (117.79 fps, avg 123.49 fps, ETA 00h01m57s)[00:02:38] sync: video time went backwards 16 ms, dropped 1 frames. PTS 85164087
Encoding: task 1 of 1, 83.91 % (121.82 fps, avg 123.32 fps, ETA 00h01m32s)[00:03:03] sync: video time went backwards 16 ms, dropped 1 frames. PTS 89668586
Encoding: task 1 of 1, 88.13 % (116.46 fps, avg 123.24 fps, ETA 00h01m09s)[00:03:27] sync: video time went backwards 16 ms, dropped 1 frames. PTS 94180593
Encoding: task 1 of 1, 92.34 % (121.79 fps, avg 123.03 fps, ETA 00h00m44s)[00:03:53] sync: video time went backwards 16 ms, dropped 1 frames. PTS 98686594
Encoding: task 1 of 1, 96.53 % (122.57 fps, avg 122.82 fps, ETA 00h00m20s)[00:04:18] sync: video time went backwards 16 ms, dropped 1 frames. PTS 103191094
Encoding: task 1 of 1, 99.82 % (118.53 fps, avg 122.73 fps, ETA 00h00m01s)[00:04:38] reader: done. 1 scr changes
Encoding: task 1 of 1, 99.88 % (118.53 fps, avg 122.73 fps, ETA 00h00m01s)[00:04:39] work: average encoding speed for job is 122.725212 fps
Encoding: task 1 of 1, 99.88 % (118.53 fps, avg 122.73 fps, ETA 00h00m01s)[00:04:39] vfr: 35599 frames output, 35531 dropped and 0 duped for CFR/PFR
[00:04:39] vfr: lost time: 0 (0 frames)
[00:04:39] vfr: gained time: 0 (0 frames) (0 not accounted for)
[00:04:39] stream: 693799 good frames, 0 errors (0%)
[00:04:39] ac3-decoder done: 37078 frames, 0 decoder errors
[00:04:39] mpeg2video-decoder done: 71147 frames, 0 decoder errors
[00:04:39] sync: got 71130 frames, 71174 expected
[00:04:39] sync: framerate min 59.920 fps, max 300.000 fps, avg 59.945 fps
x264 [info]: frame I:311   Avg QP:18.57  size: 62922
x264 [info]: frame P:19068 Avg QP:21.93  size: 18416
x264 [info]: frame B:16220 Avg QP:23.93  size:  4608
x264 [info]: consecutive B-frames: 32.0% 14.3% 22.2% 31.5%
x264 [info]: mb I  I16..4:  9.3% 85.8%  4.9%
x264 [info]: mb P  I16..4:  9.6%  0.0%  0.0%  P16..4: 71.7%  0.0%  0.0%  0.0%  0.0%    skip:18.7%
x264 [info]: mb B  I16..4:  0.3%  0.0%  0.0%  B16..8: 41.9%  0.0%  0.0%  direct: 2.9%  skip:54.8%  L0:42.7% L1:45.3% BI:12.0%
x264 [info]: 8x8 transform intra:12.2% inter:83.9%
x264 [info]: coded y,uvDC,uvAC intra: 31.0% 70.5% 19.5% inter: 25.4% 32.3% 1.2%
x264 [info]: i16 v,h,dc,p: 35% 24% 18% 23%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 22%  4%  4%  6%  5%  6%  6%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 24% 10%  5%  8%  9%  7%  6%  4%
x264 [info]: i8c dc,h,v,p: 47% 22% 25%  6%
x264 [info]: Weighted P-Frames: Y:0.1% UV:0.1%
x264 [info]: kb/s:3003.15
[00:04:39] mux: track 0, 35599 frames, 445445034 bytes, 3003.00 kbps, fifo 1024
[00:04:39] mux: track 1, 55620 frames, 23790060 bytes, 160.38 kbps, fifo 2048
[00:04:39] libhb: work result = 0

Encode done!
HandBrake has exited.

Elapsed time: 00:09:46
wicadmin commented 7 years ago

Well, I just read this which is disheartening.

HEVC encoding is CPU-taking. If your computer is a high-end one and has GPU-enabled NVIDIA product, you can use the GPU for really fast transcoding. But, ffmpeg has supported GPU acceleration,including nvenc(Nvidia) and QSV(Intel ), but the current version of HandBrake doesn’t support NVENC, and it can’t support QSV very well. That is because Handbrake doesn’t use ffmpeg but libav and NVENC hasn’t release of libav yet. Handbrake team said they didn’t have the plan to add NVENC.

lisamelton commented 7 years ago

@2devnull Yes, but your log shows you're not using transcoding to HEVC anyway. You're transcoding to H.264, which is the default behavior.

And, sadly, H.264 transcoding doesn't leverage the GPU either, except optionally for scaling. And, trust me, you don't want to use that feature because the scaling algorithm is not good quality.

BTW, where did you get that quote?

wicadmin commented 7 years ago

Yes, I know..I'm looking for a way to get there. I just need another way to do this processing so other things aren't affected due to the high system load. I once try to do it on another server via NFS but the NFS process itself created the same load and I rather not move these large files to another server to process them. Perhaps there is a way to use the "nice" feature on Linux.

I'll send you that link on another reply.

wicadmin commented 7 years ago

Here is the link to where that was quoted:

lisamelton commented 7 years ago

@2devnull Thanks for the link. OK, is there anything else you need to know? Otherwise I will close this issue.

wicadmin commented 7 years ago

No. You can close. I'm looking into developing a processing pipeline on a server I can wake up via WOL. Will be using your tools to do the actual transcoding. Thanks.