0

I am using a powershell script and ffmpeg to convert mkv files to mp4 files so that I can stream them using serviio The script executes as it should, however when serviio tries to add the converted files to my library, they are not added. If I check the log it shows an error of

Unknown video codec.

This is the powershell script I am using to convert the files

$oldvids = Get-ChildItem *.mkv -Recurse #-path 'C:\TestDir'
foreach ($oldvid in $oldvids) 
{
    $newvid = [io.path]::ChangeExtension($oldvid.FullName, '.mp4')
    C:\FFMpeg\bin\ffmpeg.exe -i $oldvid.FullName -y -vcodec copy -acodec ac3 $newvid
}

Question at hand is, how can I use a script (be it powershell or a diff programming language) to convert mkv files to mp4 files so that serviio can stream them?

EDIT
I am using GSPOT to get audio/video codec info, and below are screenshots of good settings and bad settings. How can I have a script that can re-create the above settings (as my current one does not work)?

(Working Settings)
Good Settings
(Non-Working settings)
Bad Settings
Ideally I would want to convert with the settings from Working Settings when using ffmpeg, if that is possible.

EDIT
And this is the output from running the command

ffmpeg -i good.m4v -i bad.mp4

(the file bad.mp4 is one that the script above was used to convert)

ffmpeg version N-80256-g0a9e781 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil      55. 24.100 / 55. 24.100
libavcodec     57. 45.100 / 57. 45.100
libavformat    57. 37.101 / 57. 37.101
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 46.101 /  6. 46.101
libswscale      4.  1.100 /  4.  1.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'good.m4v':
Metadata:
  major_brand     : mp42
  minor_version   : 512
  compatible_brands: isomiso2avc1mp41
  creation_time   : 2016-06-23 15:20:11
  encoder         : HandBrake 0.10.5 2016021100
Duration: 00:28:09.31, start: 0.000000, bitrate: 3939 kb/s
  Chapter #0:0: start 0.000000, end 126.167000
Metadata:
  title           : 00:00:00.000
Chapter #0:1: start 126.167000, end 418.918000
Metadata:
  title           : 00:02:06.084
Chapter #0:2: start 418.918000, end 724.974000
Metadata:
  title           : 00:06:58.835
Chapter #0:3: start 724.974000, end 1099.515000
Metadata:
  title           : 00:12:04.891
Chapter #0:4: start 1099.515000, end 1618.950000
Metadata:
  title           : 00:18:19.432
Chapter #0:5: start 1618.950000, end 1689.313000
Metadata:
  title           : 00:26:58.659
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3772 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc (default)
Metadata:
  creation_time   : 2016-06-23 15:20:11
  handler_name    : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
  creation_time   : 2016-06-23 15:20:11
  handler_name    : Stereo
Stream #0:2(eng): Subtitle: mov_text (text / 0x74786574)
Metadata:
  creation_time   : 2016-06-23 15:20:11
  handler_name    : SubtitleHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'bad.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.37.101
  Duration: 00:29:21.41, start: 0.000000, bitrate: 2489 kb/s
  Chapter #1:0: start 0.000000, end 182.432000
  Metadata:
    title           : 00:00:00.000
  Chapter #1:1: start 182.432000, end 504.838000
  Metadata:
    title           : 00:03:02.432
  Chapter #1:2: start 504.838000, end 913.329000
  Metadata:
    title           : 00:08:24.838
  Chapter #1:3: start 913.329000, end 1236.110000
  Metadata:
    title           : 00:15:13.329
  Chapter #1:4: start 1236.110000, end 1691.523000
    Metadata:
      title           : 00:20:36.110
  Chapter #1:5: start 1691.523000, end 1761.396000
    Metadata:
      title           : 00:28:11.523
  Stream #1:0(eng): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 2034 kb/s, 23.98 fps, 23.98 tbr, 16k tbn, 23.98 tbc (default)
  Metadata:
    handler_name    : VideoHandler
  Stream #1:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Side data:
    audio service type: main
   Stream #1:2(eng): Subtitle: mov_text (text / 0x74786574)
   Metadata:
    handler_name    : SubtitleHandler
  At least one output file must be specified
9
  • Please show some info about the file that works and the file that does not work. You can use ffprobe to get this info: ffprobe -show_streams -show_format input.mkv
    – llogan
    Jun 23, 2016 at 16:17
  • @LordNeckbeard - this produces a significant amount of data. Are there any particular elements you need to see or the entire output? Jun 23, 2016 at 17:40
  • Alternatively you can show the complete output of ffmpeg -i good -i bad. If we need more info you can then provide the large ffprobe output.
    – llogan
    Jun 23, 2016 at 18:44
  • @LordNeckbeard - see edit, I believe this is the output you are needing. Jun 24, 2016 at 12:49
  • I guess it doesn't support H.265 / HEVC which is what bad.mp4 contains. (Note that I have no idea what serviio is or does).
    – llogan
    Jun 24, 2016 at 17:35

1 Answer 1

0

Thanks to the assistance of @LordNeckbeard I discovered that the format I needed to convert my .mkv files to was H.264

So a simple edit to my current powershell script can remedy this and convert with the proper codec

This script works:

$oldvids = Get-ChildItem *.mkv -Recurse #-path 'C:\TestDir'
foreach ($oldvid in $oldvids) 
{
  $newvid = [io.path]::ChangeExtension($oldvid.FullName, '.mp4')
  C:\FFMpeg\bin\ffmpeg.exe -i $oldvid.FullName -y -vcodec libx264 -acodec ac3 $newvid
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .