Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: Varro on November 26, 2017, 06:00:34 PM

Title: Error applying audio codec
Post by: Varro on November 26, 2017, 06:00:34 PM
Hi! I have files like:
=====================================================
Video
=====================================================
Codec 4CC: H264
Image Size: 640 x 480
Aspect Ratio: 1:1 (1:1)
Frame Rate: 29.971 fps
Total Duration: 00:00:51.151

=====================================================
Extra Video Properties
=====================================================
ExtraDataSize: 28
Extra data: 01 42 E0 1F FF E1 00 0D 67 42

=====================================================
Audio
=====================================================
Codec: PCM
Channels: Stereo
Bitrate: 192000 Bps / 1536 kbps
Frequency: 48000 Hz
Total Duration: 00:00:51.136



I want to convert them into files with video x264 with 2048 bitrate and audio MP3 192 with following batch file:
set avidemux="c:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=x264
set videobitrate=cbr=2048
set audiocodec=MP3
set audiobitrate=192
set outputformat=MP4
for %%f in (*.MOV) do %avidemux% --video-codec %videocodec% --video-conf %videobitrate% --audio-codec %audiocodec% --audio-bitrate %audiobitrate% --output-format %outputformat% --force-alt-h264 --load "%%f" --save "%%f.mp4" --quit


But:
1) when GUI is shown audio settings didn't load (they set to "Copy").
2) when converting i got error "Unsupported. Only AAC, AC3, E-AC3 and mpegaudio supported for audio"

How can i fix this problem?
Title: Re: Error applying audio codec
Post by: Jan Gruuthuse on November 26, 2017, 06:08:33 PM
Try with this
set audiocodec=Lame

If still refused try using MKV muxer
Title: Re: Error applying audio codec
Post by: Varro on November 26, 2017, 07:59:23 PM
Quote from: Jan Gruuthuse on November 26, 2017, 06:08:33 PM
Try with this
set audiocodec=Lame

If still refused try using MKV muxer
I've tried MP3, AAC instead of "Lame" - with same result. I think main problem is that audio codec settings doesn't apply to GUI and conversion process. With manual setting via GUI i can convert this file successfully.

With MKV muxer - problem is that audio settings doesn't apply to output - it just copy.
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 26, 2017, 08:35:29 PM
--load should come first.
Title: Re: Error applying audio codec
Post by: Varro on November 26, 2017, 08:46:18 PM
Quote from: eumagga0x2a on November 26, 2017, 08:35:29 PM
--load should come first.
Same result. Order doesn't matter.

I write again - audio settings don't apply from command line to GUI and (as I think) to convert process.
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 26, 2017, 08:51:12 PM
What version are you using?

Edit: nevermind, it is 2.7, probably 2.7.0 for win64.
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 26, 2017, 09:01:31 PM
The order matters exactly as I said. With the current version (for me it is the current git master, for you the latest win64 nightly if you don't build from source), I get exactly the same error if I don't put --load option with the source video file name including the path before any audio options. It works if the video is loaded first.
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 26, 2017, 11:39:03 PM
Could you please post the output of MediaInfo for the source file? Maybe there are more audio tracks, and the command line converts only the first one.
Title: Re: Error applying audio codec
Post by: Varro on November 27, 2017, 04:25:04 PM
Yes, version is 2.7 x64 downloaded yesterday from fosshub.

Quote from: eumagga0x2a on November 26, 2017, 09:01:31 PMThe order matters exactly as I said. With the current version (for me it is the current git master, for you the latest win64 nightly if you don't build from source), I get exactly the same error if I don't put --load option with the source video file name including the path before any audio options. It works if the video is loaded first.
I use modified example from wiki (https://www.avidemux.org/admWiki/doku.php?id=tutorial:batch_processing) where "load" is after all codecs :)
Anyway with following config
set avidemux="c:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=x264
set videobitrate=cbr=2048
set audiocodec=MP3
set audiobitrate=192
set outputformat=MP4
for %%f in (*.MOV) do %avidemux% --load "%%f" --video-codec %videocodec% --video-conf %videobitrate% --audio-codec %audiocodec% --audio-bitrate %audiobitrate% --output-format %outputformat% --force-alt-h264 --save "%%f.mp4" --quit

I get same error "Unsupported. Only AAC, AC3, E-AC3 and mpegaudio supported for audio".

Quote from: eumagga0x2a on November 26, 2017, 11:39:03 PM
Could you please post the output of MediaInfo for the source file? Maybe there are more audio tracks, and the command line converts only the first one.
General
Complete name                  : D:\Convert\MVI_0906.MOV
Format                         : MPEG-4
Format profile                 : QuickTime
Codec ID                       : qt   2007.09 (qt  /CAEP)
File size                      : 43.8 MiB
Duration                       : 51 s 151 ms
Overall bit rate               : 7 188 kb/s
Encoded date                   : UTC 2017-09-24 19:04:34
Tagged date                    : UTC 2017-09-24 19:04:34
CNTH                           : яdяУяeяґяjя"яcяfяXя9яGяя5я.я#яgя2яҐяjядяҐя"
com.apple.quicktime.make       : Canon
com.apple.quicktime.model      : Canon PowerShot SX40 HS

Video
ID                             : 1
Format                         : AVC
Format/Info                    : Advanced Video Codec
Format profile                 : Baseline@L3.1
Format settings, CABAC         : No
Format settings, RefFrames     : 1 frame
Format settings, GOP           : M=1, N=15
Codec ID                       : avc1
Codec ID/Info                  : Advanced Video Coding
Duration                       : 51 s 151 ms
Bit rate                       : 5 637 kb/s
Width                          : 640 pixels
Height                         : 480 pixels
Display aspect ratio           : 4:3
Frame rate mode                : Constant
Frame rate                     : 29.970 (30000/1001) FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0
Bit depth                      : 8 bits
Scan type                      : Progressive
Bits/(Pixel*Frame)             : 0.612
Stream size                    : 34.4 MiB (78%)
Language                       : English
Encoded date                   : UTC 2017-09-24 19:04:34
Tagged date                    : UTC 2017-09-24 19:04:34
Color range                    : Full
Color primaries                : BT.709
Transfer characteristics       : BT.709
Matrix coefficients            : BT.601

Audio
ID                             : 2
Format                         : PCM
Format settings, Endianness    : Little
Format settings, Sign          : Signed
Codec ID                       : sowt
Duration                       : 51 s 151 ms
Bit rate mode                  : Constant
Bit rate                       : 1 536 kb/s
Channel(s)                     : 2 channels
Channel positions              : Front: L R
Sampling rate                  : 48.0 kHz
Bit depth                      : 16 bits
Stream size                    : 9.37 MiB (21%)
Language                       : English
Encoded date                   : UTC 2017-09-24 19:04:34
Tagged date                    : UTC 2017-09-24 19:04:34
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 27, 2017, 04:36:55 PM
Well, there is no second audio track... Could you please try the latest nightly (http://avidemux.org/nightly/win64/) then?

If you want the audio track to be encoded as MP3, use Lame as --audio-codec
Title: Re: Error applying audio codec
Post by: Varro on November 27, 2017, 04:56:17 PM
Build 171127 - much better. Output in GUI is set to MP3 (lame). But now i can't change audio bitrate - for any value audio bitrate remains 128 (i've set codec to lame).

Updated
Also I found following in log:
[audioCodecSetByName] 16:59:25-814 Audio codec Lame set for track 0 (index=7)

Unknown command :--audio-bitrate

Found garbage 192
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 27, 2017, 05:02:01 PM
Looking into it.
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 27, 2017, 05:17:41 PM
The --audio-bitrate option has been removed by this commit (https://github.com/mean00/avidemux2/commit/011755ae15d939c8cebb38e71893d83a07b1ff37#diff-6c499eeeac4fb550443bd75bee810096) in March 2012. The Wiki is terribly outdated. Please use a project script (.py) to supply codec options, just don't forget always to load the video first.

Edit:

adm = Avidemux()
adm.audioCodec(0, "Lame", "bitrate=192", "preset=0", "quality=2", "disableBitReservoir=False");
Title: Re: Error applying audio codec
Post by: eumagga0x2a on November 27, 2017, 05:50:09 PM
The --video-conf option has gone too, as well as the --force-alt-h264 one. You should configure (with a video loaded) video and audio codecs and the output container to your liking in Avidemux, then save this as a project script, edit the resulting .py file deleting the lines starting with

adm.loadVideo
adm.clearSegments
adm.addSegment
adm.markerA
adm.markerB


and load the video on command line followed by --run "path/to/your/script.py". The batch would look like the following:

set avidemux="c:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set project="path\to\edited\script.py"

for %%f in (*.MOV) do %avidemux% --load "%%f" --run %project% --save "%%f.mp4" --quit
Title: Re: Error applying audio codec
Post by: Varro on November 27, 2017, 06:01:18 PM
Great, thank you for help and useful app!
Using previously saved project is much more convenient than specifing all in command line.
Title: Re: Error applying audio codec
Post by: dosdan on November 27, 2017, 08:19:47 PM
Quoteset avidemux="c:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set project="path\to\edited\script.py"

for %%f in (*.MOV) do %avidemux% --load "%%f" --run %project% --save "%%f.mp4" --quit


I wouldn't use "%%f.mp4" here as it will create test.mov.mp4 from test.mov

To not include the orgiinal file extension under Windows, instead use "%%~nf"

Here's a slightly more complex version of this batchfile, designed to use as a icon on the Windows desktop. You drag one or more MOV files onto it. It uses a sub-directory called "processed videos" beneath the directory where the MOVs were dragged from, and creates this sub-directory if it doesn't already exist.

MOV_to_MP4.bat
@echo off
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set project="D:\ADM Test\test.py"
set output_dir=processed videos\
if not exist "%output_dir%" md "%output_dir%"

for %%f in (*.mov) do %avidemux% --load "%%f" --run %project% --save "%output_dir%%%~nf.mp4" --quit


A variation would be to use the same output directory for all conversions e.g.
set output_dir=D:\processed videos\
But you might sometimes have problems with duplicated processed filenames.

Another variation would be to test for an errorlevel and, if no err occurred, to delete the original file after the conversion, as here:
http://avidemux.org/smif/index.php/topic,17148.msg77044.html#msg77044
But I'm not sure if ADM sets an errorlevel in CLI mode.

Or, show the new file details, as displayed in a DIR line listing, as a crude type of multi-file conversion progress indicator, as each one is converted, as here:
http://avidemux.org/smif/index.php/topic,17187.msg77356.html#msg77356


Dan.