rehdi93 / BlenderRenderController

A tool for significant speedup of rendering with Blender VSE (Video Sequence Editor).
MIT License
7 stars 0 forks source link

New Issue with Joining Chunks with Mixdown Audio (Audio codec becomes FLAC regardless of choice) #8

Open eplipswich opened 6 years ago

eplipswich commented 6 years ago

This is the issue that I get from Joining Chunks with Mixdown Audio:

FFMpeg concat Exit code: 1

Std Error:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000196650782a0] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'E:\Videos\New folder\chunks\chunklist.txt':
  Duration: N/A, start: 0.000000, bitrate: 2508 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 2256 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 252 kb/s
    Metadata:
      handler_name    : SoundHandler
Input #1, flac, from 'E:\Videos\New folder\untitled.aac':
  Duration: 00:00:10.03, start: 0.000000, bitrate: 514 kb/s
    Stream #1:0: Audio: flac, 48000 Hz, stereo, s16
[mp4 @ 000001966516b4a0] track 1: codec frame size is not set
[mp4 @ 000001966516b4a0] flac in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times

Std Output:

I believe the error in particular is this: Input #1, flac, from 'E:\Videos\New folder\untitled.aac':

Why does it use flac when I clearly chose aac?? The flac issue applies to any other video that I join chunks with mixdown audio for some reason (regardless of which video and audio formats I choose).

rehdi93 commented 6 years ago

I really don't know, 😞. FFmpeg is being stupid 😠

This is what the Cmd looks like now:

> ffmpeg -f concat -safe 0 -i "path\to\chunklist.txt" -i "path\to\mixdown.aud" -c copy -map 0:v:0 -map 1:a:0 -t 00:03:28 "path\to\output.vid" -y

I tested AVI w/ Ac3 and it worked, I know Mp4 is more selective in what audio you can use w/ it, but I pretty sure AAC is one of them

For the time being, try using vid. conteiners like MKV and AVI.

rehdi93 commented 6 years ago

Even when I specified the correct audio codec w/ -c:a aac it still failed w/ the same error

Adding -strict -2 WILL work, but I don't know what those experimental open up to exactly. Could lead to even more unexpected behavior 😟

eplipswich commented 6 years ago

Why not use -map 0:v -map 1:a instead of -map 0:v:0 -map 1:a:0? That could work (I used -map 0:v -map 1:abefore and it worked perfect) . Like maybe use the same code as without mixdown audio.

I’ll try to test it out again on my side as well just to confirm.

eplipswich commented 6 years ago

Yeah, I tested with -map 0:v -map 1:a and it works perfect. The only other diff is that I put it in this order: -map 0:v -map 1:a -c copy and not the other way round like in your code.

Can you change it to that? Thanks :)

rehdi93 commented 6 years ago

Nope, tested MP4 + AAC, same error

DEBUG|ConcatCmd:  cmd:> ffmpeg -f concat -safe 0 -i "E:\Bibliotecas E\_projetos\Blender\Video\render\tests\chunks\chunklist.txt" -i "E:\Bibliotecas E\_projetos\Blender\Video\render\tests\test project2.aac" -map 0:v -map 1:a -c copy -t 00:03:28 "E:\Bibliotecas E\_projetos\Blender\Video\render\tests\test project2.mp4" -y
DEBUG|ConcatCmd:  ffmpeg exit code: 1

besides, I'm pretty sure -map 0:v -map 1:a is just shorthand for -map 0:v:0 -map 1:a:0

Can you post what your successful test looked like?

eplipswich commented 6 years ago
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libmfx --enable-cuda --enable-cuvid --enabl
e-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000000f9800] Auto-inserting h264_mp4toannexb bit
stream filter
Input #0, concat, from 'chunklist.txt':
  Duration: N/A, start: 0.000000, bitrate: 2804 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1364x768,
 2483 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 320 kb/s
    Metadata:
      handler_name    : SoundHandler
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'test.wav':
  Duration: 00:00:22.03, bitrate: 1411 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1364x768,
 q=2-31, 2483 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  440 fps=0.0 q=-1.0 Lsize=    8256kB time=00:00:22.01 bitrate=3072.4kbits
/s speed= 242x
video:4446kB audio:3795kB subtitle:0kB other streams:0kB global headers:0kB muxi
ng overhead: 0.178125%

This was using the code ffmpeg -f concat -safe 0 -i chunklist.txt -i test.wav -map 0:v -map 1:a -c copy output.mp4

I'll test out aac in a bit.

eplipswich commented 6 years ago
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libmfx --enable-cuda --enable-cuvid --enabl
e-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000459800] Auto-inserting h264_mp4toannexb bit
stream filter
Input #0, concat, from 'chunklist.txt':
  Duration: N/A, start: 0.000000, bitrate: 2804 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1364x768,
 2483 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 320 kb/s
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'test2.aac':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    encoder         : Lavf55.33.100
  Duration: 00:00:22.07, start: 0.000000, bitrate: 197 kb/s
    Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 195 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1364x768,
 q=2-31, 2483 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 195 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  440 fps=0.0 q=-1.0 Lsize=    4992kB time=00:00:22.05 bitrate=1853.9kbits
/s speed= 613x
video:4446kB audio:528kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: 0.371739%

This was with aac.

eplipswich commented 6 years ago

So, just to revisit this issue, I think this is the solution:

ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 output.mp4

From https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg

The key probably lies in -c:v and -c:a.