lisamelton / video-transcoding-scripts

Utilities to transcode, inspect and convert videos.
MIT License
603 stars 76 forks source link

Additional option to output 8 channel AC-3 #21

Closed ghost closed 9 years ago

ghost commented 9 years ago

I have a bunch of blu-rays which have audio that is converted from DTS-HD, to 8 channel FLAC. Regardless of whether I use the --big option or not, ffmpeg down mixes the 8 channels to 6 channel (5.1) AC-3 using libavcodec.

Is there an option where I can encode the FLAC into 8 channel AC-3 at 640kbps? Is this even supported by the codec?

Output log:

root@ULTRA-STRIKE-VM:/media/sf_Encoded# ./transcode-video.sh --big --mkv --veryslow --crop 140:140:0:0 --allow-ac3 --allow-dts 'NYSM/Now_You_See_Me_t00.mkv'
stat: cannot read file system information for ‘%z’: No such file or directory
./transcode-video.sh: line 852: (  File: "NYSM/Now_You_See_Me_t00.mkv"
    ID: 0        Namelen: 255     Type: nfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 244189951  Free: 208640802  Available: 208640802
Inodes: Total: 1000       Free: 1000 * 8) / ((duration_array[0] * 60 * 60) + (duration_array[1] * 60) + duration_array[2]): missing `)' (error token is ": "NYSM/Now_You_See_Me_t00.mkv"
    ID: 0        Namelen: 255     Type: nfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 244189951  Free: 208640802  Available: 208640802
Inodes: Total: 1000       Free: 1000 * 8) / ((duration_array[0] * 60 * 60) + (duration_array[1] * 60) + duration_array[2])")
Transcoding: NYSM/Now_You_See_Me_t00.mkv
[16:41:44] hb_init: starting libhb thread
HandBrake 0.10.1 (2015030800) - Linux x86_64 - https://handbrake.fr
1 CPU detected
Opening NYSM/Now_You_See_Me_t00.mkv...
[16:41:44] CPU: AMD FX(tm)-8350 Eight-Core Processor           
[16:41:44]  - logical processor count: 1
[16:41:44] OpenCL: library not available
[16:41:44] hb_scan: path=NYSM/Now_You_See_Me_t00.mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening NYSM/Now_You_See_Me_t00.mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening NYSM/Now_You_See_Me_t00.mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(NYSM/Now_You_See_Me_t00.mkv) failed
[16:41:44] 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
[16:41:44] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'NYSM/Now_You_See_Me_t00.mkv':
  Metadata:
    title           : Now You See Me
  Duration: 02:05:13.53, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.000000, end 506.589417
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 506.589417, end 881.755875
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 881.755875, end 1285.909625
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 1285.909625, end 1922.754167
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 1922.754167, end 2369.200167
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 2369.200167, end 2827.241083
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 2827.241083, end 3403.483417
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 3403.483417, end 3875.413208
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 3875.413208, end 4223.177292
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 4223.177292, end 4804.591458
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 4804.591458, end 5341.044042
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 5341.044042, end 5722.925542
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 5722.925542, end 6246.365125
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 6246.365125, end 6560.095208
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 6560.095208, end 6864.691167
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 6864.691167, end 7513.536000
    Metadata:
      title           : Chapter 16
    Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.98 fps, 1k tbn, 47.95 tbc
    Stream #0.1(eng): Audio: flac, 48000 Hz, 7.1, s16 (default)
    Metadata:
      title           : Surround 7.1
    Stream #0.2(eng): Subtitle: pgssub
[16:41:44] scan: decoding previews for title 1
[16:41:45] scan: audio 0x1: flac, rate=48000Hz, bitrate=1 English (FLAC) (7.1 ch)
Scanning title 1 of 1, preview 10, 100.00 %[16:41:45] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 140/140/0/0, aspect 16:9, PAR 1:1
[16:41:45] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: NYSM/Now_You_See_Me_t00.mkv
  + duration: 02:05:13
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 140/140/0/0
  + support opencl: no
  + support hwd: not built-in
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:08:27
    + 2: cells 0->0, 0 blocks, duration 00:06:15
    + 3: cells 0->0, 0 blocks, duration 00:06:44
    + 4: cells 0->0, 0 blocks, duration 00:10:37
    + 5: cells 0->0, 0 blocks, duration 00:07:26
    + 6: cells 0->0, 0 blocks, duration 00:07:38
    + 7: cells 0->0, 0 blocks, duration 00:09:36
    + 8: cells 0->0, 0 blocks, duration 00:07:52
    + 9: cells 0->0, 0 blocks, duration 00:05:48
    + 10: cells 0->0, 0 blocks, duration 00:09:41
    + 11: cells 0->0, 0 blocks, duration 00:08:56
    + 12: cells 0->0, 0 blocks, duration 00:06:22
    + 13: cells 0->0, 0 blocks, duration 00:08:43
    + 14: cells 0->0, 0 blocks, duration 00:05:14
    + 15: cells 0->0, 0 blocks, duration 00:05:05
    + 16: cells 0->0, 0 blocks, duration 00:10:49
  + audio tracks:
    + 1, English (FLAC) (7.1 ch) (iso639-2: eng)
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(PGS)
[16:41:46] 1 job(s) to process
[16:41:46] starting job
[16:41:46] work: mixdown not specified, track 1 setting mixdown 5.1 Channels
[16:41:46] work: bitrate not specified, track 1 setting bitrate 640 Kbps
[16:41:46] work: mixdown not specified, track 2 setting mixdown Dolby Pro Logic II
[16:41:46] work: bitrate not specified, track 2 setting bitrate 160 Kbps
[16:41:46] sync: expecting 180144 video frames
[16:41:46] job configuration:
[16:41:46]  * source
[16:41:46]    + NYSM/Now_You_See_Me_t00.mkv
[16:41:46]    + title 1, chapter(s) 1 to 16
[16:41:46]    + container: matroska,webm
[16:41:46]  * destination
[16:41:46]    + Now_You_See_Me_t00.mkv
[16:41:46]    + container: Matroska (libavformat)
[16:41:46]      + chapter markers
[16:41:46]  * video track
[16:41:46]    + decoder: h264
[16:41:46]    + filters
[16:41:46]      + Framerate Shaper (2:27000000:900000)
[16:41:46]        + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[16:41:46]      + Crop and Scale (1920:800:140:140:0:0)
[16:41:46]        + source: 1920 * 1080, crop (140/140/0/0): 1920 * 800, scale: 1920 * 800
[16:41:46]    + strict anamorphic
[16:41:46]      + storage dimensions: 1920 * 800, mod 0
[16:41:46]      + pixel aspect ratio: 1 / 1
[16:41:46]      + display dimensions: 1920 * 800
[16:41:46]    + encoder: H.264 (libx264)
[16:41:46]      + preset:  veryslow
[16:41:46]      + options: ref=5:vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25
[16:41:46]      + level:   4.0
[16:41:46]      + quality: 16.00 (RF)
[16:41:46]  * audio track 1
[16:41:46]    + decoder: English (FLAC) (7.1 ch) (track 1, id 0x1)
[16:41:46]      + samplerate: 48000 Hz
[16:41:46]    + mixdown: 5.1 Channels
[16:41:46]    + encoder: AC3 (libavcodec)
[16:41:46]      + bitrate: 640 kbps, samplerate: 48000 Hz
[16:41:46]  * audio track 2
[16:41:46]    + decoder: English (FLAC) (7.1 ch) (track 1, id 0x1)
[16:41:46]      + samplerate: 48000 Hz
[16:41:46]    + mixdown: Dolby Pro Logic II
[16:41:46]    + encoder: AAC (libavcodec)
[16:41:46]      + bitrate: 160 kbps, samplerate: 48000 Hz
[16:41:46] encx264: min-keyint: 24, keyint: 240
[16:41:46] encx264: encoding at constant RF 16.000000
[16:41:46] encx264: unparsed options: ref=5:vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25:level=4.0:bframes=8:b-adapt=2:direct=auto:analyse=all:me=umh:merange=24:subme=10:trellis=2:rc-lookahead=60
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SlowCTZ
[16:41:46] reader: first SCR 0 id 0x0 DTS 0
x264 [info]: profile High, level 4.0
Encoding: task 1 of 1, 0.08 % (15.60 fps, avg 24.23 fps, ETA 02h03m50s)^C
root@ULTRA-STRIKE-VM:/media/sf_Encoded# ./transcode-video.sh --big --mkv --veryslow --crop 140:140:0:0 --copy-ac3 --allow-dts 'NYSM/Now_You_See_Me_t00.mkv'
stat: cannot read file system information for ‘%z’: No such file or directory
./transcode-video.sh: line 852: (  File: "NYSM/Now_You_See_Me_t00.mkv"
    ID: 0        Namelen: 255     Type: nfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 244189951  Free: 208640799  Available: 208640799
Inodes: Total: 1000       Free: 1000 * 8) / ((duration_array[0] * 60 * 60) + (duration_array[1] * 60) + duration_array[2]): missing `)' (error token is ": "NYSM/Now_You_See_Me_t00.mkv"
    ID: 0        Namelen: 255     Type: nfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 244189951  Free: 208640799  Available: 208640799
Inodes: Total: 1000       Free: 1000 * 8) / ((duration_array[0] * 60 * 60) + (duration_array[1] * 60) + duration_array[2])")
Transcoding: NYSM/Now_You_See_Me_t00.mkv
[16:43:24] hb_init: starting libhb thread
HandBrake 0.10.1 (2015030800) - Linux x86_64 - https://handbrake.fr
1 CPU detected
Opening NYSM/Now_You_See_Me_t00.mkv...
[16:43:24] CPU: AMD FX(tm)-8350 Eight-Core Processor           
[16:43:24]  - logical processor count: 1
[16:43:24] OpenCL: library not available
[16:43:24] hb_scan: path=NYSM/Now_You_See_Me_t00.mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening NYSM/Now_You_See_Me_t00.mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening NYSM/Now_You_See_Me_t00.mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(NYSM/Now_You_See_Me_t00.mkv) failed
[16:43:24] 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
[16:43:24] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'NYSM/Now_You_See_Me_t00.mkv':
  Metadata:
    title           : Now You See Me
  Duration: 02:05:13.53, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.000000, end 506.589417
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 506.589417, end 881.755875
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 881.755875, end 1285.909625
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 1285.909625, end 1922.754167
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 1922.754167, end 2369.200167
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 2369.200167, end 2827.241083
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 2827.241083, end 3403.483417
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 3403.483417, end 3875.413208
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 3875.413208, end 4223.177292
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 4223.177292, end 4804.591458
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 4804.591458, end 5341.044042
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 5341.044042, end 5722.925542
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 5722.925542, end 6246.365125
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 6246.365125, end 6560.095208
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 6560.095208, end 6864.691167
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 6864.691167, end 7513.536000
    Metadata:
      title           : Chapter 16
    Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.98 fps, 1k tbn, 47.95 tbc
    Stream #0.1(eng): Audio: flac, 48000 Hz, 7.1, s16 (default)
    Metadata:
      title           : Surround 7.1
    Stream #0.2(eng): Subtitle: pgssub
[16:43:24] scan: decoding previews for title 1
[16:43:24] scan: audio 0x1: flac, rate=48000Hz, bitrate=1 English (FLAC) (7.1 ch)
Scanning title 1 of 1, preview 10, 100.00 %[16:43:25] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 140/140/0/0, aspect 16:9, PAR 1:1
[16:43:25] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: NYSM/Now_You_See_Me_t00.mkv
  + duration: 02:05:13
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 140/140/0/0
  + support opencl: no
  + support hwd: not built-in
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:08:27
    + 2: cells 0->0, 0 blocks, duration 00:06:15
    + 3: cells 0->0, 0 blocks, duration 00:06:44
    + 4: cells 0->0, 0 blocks, duration 00:10:37
    + 5: cells 0->0, 0 blocks, duration 00:07:26
    + 6: cells 0->0, 0 blocks, duration 00:07:38
    + 7: cells 0->0, 0 blocks, duration 00:09:36
    + 8: cells 0->0, 0 blocks, duration 00:07:52
    + 9: cells 0->0, 0 blocks, duration 00:05:48
    + 10: cells 0->0, 0 blocks, duration 00:09:41
    + 11: cells 0->0, 0 blocks, duration 00:08:56
    + 12: cells 0->0, 0 blocks, duration 00:06:22
    + 13: cells 0->0, 0 blocks, duration 00:08:43
    + 14: cells 0->0, 0 blocks, duration 00:05:14
    + 15: cells 0->0, 0 blocks, duration 00:05:05
    + 16: cells 0->0, 0 blocks, duration 00:10:49
  + audio tracks:
    + 1, English (FLAC) (7.1 ch) (iso639-2: eng)
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(PGS)
[16:43:25] 1 job(s) to process
[16:43:25] starting job
[16:43:25] work: mixdown not specified, track 1 setting mixdown 5.1 Channels
[16:43:25] work: bitrate not specified, track 1 setting bitrate 640 Kbps
[16:43:25] work: mixdown not specified, track 2 setting mixdown Dolby Pro Logic II
[16:43:25] work: bitrate not specified, track 2 setting bitrate 160 Kbps
[16:43:25] sync: expecting 180144 video frames
[16:43:25] job configuration:
[16:43:25]  * source
[16:43:25]    + NYSM/Now_You_See_Me_t00.mkv
[16:43:25]    + title 1, chapter(s) 1 to 16
[16:43:25]    + container: matroska,webm
[16:43:25]  * destination
[16:43:25]    + Now_You_See_Me_t00.mkv
[16:43:25]    + container: Matroska (libavformat)
[16:43:25]      + chapter markers
[16:43:25]  * video track
[16:43:25]    + decoder: h264
[16:43:25]    + filters
[16:43:25]      + Framerate Shaper (2:27000000:900000)
[16:43:25]        + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[16:43:25]      + Crop and Scale (1920:800:140:140:0:0)
[16:43:25]        + source: 1920 * 1080, crop (140/140/0/0): 1920 * 800, scale: 1920 * 800
[16:43:25]    + strict anamorphic
[16:43:25]      + storage dimensions: 1920 * 800, mod 0
[16:43:25]      + pixel aspect ratio: 1 / 1
[16:43:25]      + display dimensions: 1920 * 800
[16:43:25]    + encoder: H.264 (libx264)
[16:43:25]      + preset:  veryslow
[16:43:25]      + options: ref=5:vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25
[16:43:25]      + level:   4.0
[16:43:25]      + quality: 16.00 (RF)
[16:43:25]  * audio track 1
[16:43:25]    + decoder: English (FLAC) (7.1 ch) (track 1, id 0x1)
[16:43:25]      + samplerate: 48000 Hz
[16:43:25]    + mixdown: 5.1 Channels
[16:43:25]    + encoder: AC3 (libavcodec)
[16:43:25]      + bitrate: 640 kbps, samplerate: 48000 Hz
[16:43:25]  * audio track 2
[16:43:25]    + decoder: English (FLAC) (7.1 ch) (track 1, id 0x1)
[16:43:25]      + samplerate: 48000 Hz
[16:43:25]    + mixdown: Dolby Pro Logic II
[16:43:25]    + encoder: AAC (libavcodec)
[16:43:25]      + bitrate: 160 kbps, samplerate: 48000 Hz
[16:43:25] encx264: min-keyint: 24, keyint: 240
[16:43:25] encx264: encoding at constant RF 16.000000
[16:43:25] encx264: unparsed options: ref=5:vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25:level=4.0:bframes=8:b-adapt=2:direct=auto:analyse=all:me=umh:merange=24:subme=10:trellis=2:rc-lookahead=60
lisamelton commented 9 years ago

No, the Dolby Digital AC-3 format doesn't support more than 5.1. channels. However, Handbrake (and not FFmpeg in this case) does an exceptionally good job of mixing down 6.1 and 7.1 audio to that format. Remember that two goals of the script are reduction in size and portability, so this is expected.