lisamelton / video_transcoding

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

transcode-video vs convert-video #30

Closed dgibbs64 closed 8 years ago

dgibbs64 commented 8 years ago

been testing convert-video to try ans speed to transcoding to mp4. However encountered an issue that increases the file size significantly of the output mp4. It adds 3 audio streams. I dont know if this is by design or not. However I thought I would raise it

convert-video

lisamelton commented 8 years ago

@dgibbs64 Interesting. That could be a bug in convert-video then. Can you send me more information about the original file? Via transcode-video --scan and mediainfo. Thanks.

dgibbs64 commented 8 years ago

No problem.

I tested a few files and got the same result.

output from transcode-video --scan

+ title 1:
  + stream: Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
  + duration: 00:01:00
  + size: 1920x816, pixel aspect: 1/1, display aspect: 2.35, 23.976 fps
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:01:00
  + audio tracks:
   + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
  + subtitle tracks:

Mediainfo

General
Unique ID                                : 229627141255310573133927457221120111695 (0xACC0942839406982B6C20DE65250344F)
Complete name                            : Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 21.0 MiB
Duration                                 : 1mn 0s
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 911 Kbps
Encoded date                             : UTC 2014-08-23 20:23:23
Writing application                      : mkvmerge v5.6.0 ('Kenya Kane') built on May 27 2012 16:44:04
Writing library                          : libebml v1.2.3 + libmatroska v1.3.0

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 1mn 0s
Bit rate mode                            : Variable
Bit rate                                 : 2 213 Kbps
Maximum bit rate                         : 40.0 Mbps
Width                                    : 1 920 pixels
Height                                   : 816 pixels
Display aspect ratio                     : 2.35:1
Frame rate mode                          : Constant
Frame rate                               : 23.976 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.059
Stream size                              : 15.9 MiB (76%)
Title                                    : ETRG
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : A_AC3
Duration                                 : 1mn 0s
Bit rate mode                            : Constant
Bit rate                                 : 640 Kbps
Channel(s)                               : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : 28ms
Stream size                              : 4.61 MiB (22%)
Title                                    : ETRG
Language                                 : English
Default                                  : Yes
Forced                                   : No

Menu
00:00:00.000                             : en:A Message and a Gift
lisamelton commented 8 years ago

@dgibbs64 Thanks! OK, It's normal for convert-video to create the first AAC format track for MP4 compatibility on Apple devices. But it shouldn't be creating that second AAC track. That looks like a bug.

I'll start tracking it down soon.

dgibbs64 commented 8 years ago

@donmelton yeah I thought that was the case. Good luck :). Im hoping to use convert-video to speed up the long process of converting all my media

dgibbs64 commented 8 years ago

Found the issue

ffmpeg -hide_banner -nostdin -i file.mkv -map 0: -map 0: -map 0: -c:v copy -c:a:0 copy -strict experimental -ac 2 -c:a:1 aac -b:a:1 160k file.mp4

Should be

ffmpeg -hide_banner -nostdin -i file.mkv -map 0:0 -map 0:1 -map 0:1 -c:v copy -strict experimental -ac 2 -c:a:0 aac -b:a:0 160k -c:a:1 copy file.mp4

The problem is that your script is not putting the 0 or one in map.

lisamelton commented 8 years ago

@dgibbs64 Weird. Nice detective work.

Hmmm, looking at the code now, I'm not sure how the stream indicator could be missing unless the media information was wrong for that file.

In other words, if this always happened, convert-video would never work.

Unfortunately, I can't even investigate this at the moment since I'm away for several days. But I'll try to reproduce this as soon as I get back.

dgibbs64 commented 8 years ago

No problem. I was trying to figure out how to fix this myself. However my ruby skills are very limited.

Im currently using your bash script instead and thats working fine

lisamelton commented 8 years ago

@dgibbs64 I'm sorry, but I can't reproduce this bug.

As I suspected, convert-video would never work if this happened all the time. I always get the proper stream indicator in my call to ffmpeg.

So, I suspect there might be something odd about the tools you have installed. Can you give me the output of ffmpeg -version?

dgibbs64 commented 8 years ago

Of course

user@video-transcode:~$ ffmpeg -version
ffmpeg version 2.7.3-0ubuntu0.15.10.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
libavutil      54. 27.100 / 54. 27.100
libavcodec     56. 41.100 / 56. 41.100
libavformat    56. 36.100 / 56. 36.100
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5. 16.101 /  5. 16.101
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  2.100 /  1.  2.100
libpostproc    53.  3.100 / 53.  3.100
dgibbs64 commented 8 years ago

If I remember correctly the tools installed are just the standard ones available in the ubuntu repo.

lisamelton commented 8 years ago

@dgibbs64 While that's not as recent as version 2.8.4, which is what I'm running, your version 2.7.3 shouldn't be an issue.

I also don't see anything weird about your configuration either.

What version of HandBrake are you using?

lisamelton commented 8 years ago

@dgibbs64 I think the issue might be that the stream number is missing from the original scan of your media by HandBrake. Can you send me the entire output of transcode-video --scan -vv (note the -vv at the end there) for your media?

dgibbs64 commented 8 years ago

Sure

user@video-transcode:~$ transcode-video --scan -vv nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
  transcode-video 0.3.0
  Copyright (c) 2013-2016 Don Melton
  Processing: nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv...
  Scanning media title 1 with HandBrakeCLI...
  HandBrake 0.10.2 found...
  [16:29:35] hb_init: starting libhb thread
  HandBrake 0.10.2 (2015090200) - Linux x86_64 - https://handbrake.fr
  4 CPUs detected
  Opening nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv...
  [16:29:35] CPU: Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
  [16:29:35]  - Intel microarchitecture Haswell
  [16:29:35]  - logical processor count: 4
  [16:29:35] OpenCL: library not available
  [16:29:35] hb_scan: path=nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv, title_index=1
  udfread ERROR: ECMA 167 Volume Recognition failed
  disc.c:251: failed opening UDF image nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
  disc.c:332: error opening file BDMV/index.bdmv
  disc.c:332: error opening file BDMV/BACKUP/index.bdmv
  [16:29:36] bd: not a bd - trying as a stream/file instead
  libdvdnav: Using dvdnav version 5.0.1
  libdvdread: Encrypted DVD support unavailable.
  ************************************************
  **                                            **
  **  No css library available. See             **
  **  /usr/share/doc/libdvdread4/README.css     **
  **  for more information.                     **
  **                                            **
  ************************************************
  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:29:36] dvd: not a dvd - trying as a stream/file instead
  Input #0, matroska,webm, from 'nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv':
    Metadata:
      encoder         : libebml v1.2.3 + libmatroska v1.3.0
      creation_time   : 2014-08-23 20:23:23
    Duration: 00:01:00.41, start: 0.000000, bitrate: 2910 kb/s
      Chapter #0:0: start 0.000000, end 60.412000
      Metadata:
        title           : A Message and a Gift
      Stream #0:0: Video: h264 (High), yuv420p, 1920x816 [SAR 1:1 DAR 40:17], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
      Metadata:
        title           : ETRG
      Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
      Metadata:
        title           : ETRG
  [16:29:36] scan: decoding previews for title 1
  [16:29:36] scan: audio 0x1: ac3, rate=48000Hz, bitrate=640000 English (AC3) (5.1 ch)
  Scanning title 1 of 1, preview 1, 50.00 %[16:29:36] scan: 2 previews, 1920x816, 23.976 fps, autocrop = 0/0/0/0, aspect 2.35:1, PAR 1:1
  [16:29:36] libhb: scan thread found 1 valid title(s)
  + title 1:
    + stream: nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
    + duration: 00:01:00
    + size: 1920x816, pixel aspect: 1/1, display aspect: 2.35, 23.976 fps
    + autocrop: 0/0/0/0
    + support opencl: no
    + support hwd: not built-in
    + chapters:
      + 1: cells 0->0, 0 blocks, duration 00:01:00
    + audio tracks:
      + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
    + subtitle tracks:
  HandBrake has exited.

  {:title=>1, :size=>21978999, :directory=>false, :duration=>60, :width=>1920, :height=>816, :fps=>23.976, :autocrop=>nil, :audio=>{1=>{:format=>"AC3", :channels=>5.1, :language=>"eng", :bps=>640000}}, :subtitle=>{}, :h264=>false, :mpeg2=>false, :bd=>false, :dvd=>false, :mkv=>true, :mp4=>false}
  + title 1:
    + stream: nas-Downloads/Star.Wars.Episode.VI.Return.of.the.Jedi.1983.sample.mkv
    + duration: 00:01:00
    + size: 1920x816, pixel aspect: 1/1, display aspect: 2.35, 23.976 fps
    + chapters:
      + 1: cells 0->0, 0 blocks, duration 00:01:00
    + audio tracks:
      + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
    + subtitle tracks:
  Done.
lisamelton commented 8 years ago

@dgibbs64 Can you paste that in again formatted as code this time? Otherwise it's completely mangled and I can use it. See the Markdown styling guidelines for help on that. Thanks.

dgibbs64 commented 8 years ago

Thats better :)

lisamelton commented 8 years ago

@dgibbs64 Cool. Thanks!

But it looks like your stream information is intact in the scan. It should have been parsed correctly. So, I still have no idea what's going wrong.

Does convert-video work for you with any other titles?

dgibbs64 commented 8 years ago

Sorry for late reply. No I get the same output everytime. Im going to try re installing my vm and see if that helps at all :)

lisamelton commented 8 years ago

@dgibbs64 Wait. You're runningconvert-video within a virtual machine? What kind of VM is this?

dgibbs64 commented 8 years ago

Its just VIrtualBox running Ubuntu 15.10. Im using my own script with yours to watch a directory and automatically convert/transcode videos from that dir. It works quite well.

lisamelton commented 8 years ago

@dgibbs64 Does convert-video exhibit the same problem when running in your host OS, i.e. not the virtual machine?

And what is your host OS?

lisamelton commented 8 years ago

@dgibbs64 Any update on this? Were you able to finally resolve this problem?

dgibbs64 commented 8 years ago

@donmelton sorry been very busy recently and not had time to do anything with this. Im currently using your old bash script for converting as it works correctly at the moment. I will need to test any updates you have made and try again.

lisamelton commented 8 years ago

@dgibbs64 Any update on this?

dgibbs64 commented 8 years ago

Will be doing a fresh install once I get my VMware server installed :D. I will test then

lisamelton commented 8 years ago

@dgibbs64 Were you able to re-test this yet?

dgibbs64 commented 8 years ago

Im just getting issues as per #41 currently. So I think when that is resolved we I can re-test this

lisamelton commented 8 years ago

@dgibbs64 Looking at what we've discovered in #41 and the scan output you included earlier here, I'm pretty sure now that these two are exactly the same bug. :)

lisamelton commented 8 years ago

@dgibbs64 OK, the fix has been released in version 0.8.0. Just update to get it. Please test on your configuration and let me know if it actually works.

Thanks again!

dgibbs64 commented 8 years ago

I can confirm this issue is now resolve. Awesome work!!!!

lisamelton commented 8 years ago

@dgibbs64 Whew! Glad that fixed it. :) And thanks for testing!