I have been using a small script which could be used to extract Audio files encoded as .mp3. It is no longer working. I will set the code out below:
When I run it now it errors out with:Code:#!/bin/bash -x if [ echo $# -ne 1 ]; then # $# is the number of 'parameters' called on the command line. echo $0: Usage: copy-mp3-from-movi.sh movie-file-name exit 1 fi for FILE in "$@" # $@ means List of " " (Quoted) list of parameters. do ffmpeg -i "$FILE" -vn -acodec copy "$(basename "$FILE").mp3" done
This process has worked in the past. I have also tried it with a much newer 'ffmpeg' but no joy. Has something fundamental changed with 'ffmpeg' that I should address in my call to it?[me@PANTRY 2723 ~/Grab/Movi]
$ ~/Prog/Code/Scrp/copy-mp3-from-movi.sh Alison-Krauss-Paper-Airplane.mkv
+ '[' echo 1 -ne 1 ']'
/home/me/Prog/Code/Scrp/copy-mp3-from-movi.sh: line 3: [: too many arguments
+ for FILE in '"$@"'
++ basename Alison-Krauss-Paper-Airplane.mkv
+ ffmpeg -i Alison-Krauss-Paper-Airplane.mkv -vn -acodec copy Alison-Krauss-Paper-Airplane.mkv.mp3
ffmpeg version 3.1.9 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20161221 (Red Hat 6.3.1-1)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-libopencv --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from 'Alison-Krauss-Paper-Airplane.mkv':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
ENCODER : Lavf58.45.100
Duration: 00:04:15.64, start: -0.007000, bitrate: 2451 kb/s
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
HANDLER_NAME : ISO Media file produced by Google Inc.
DURATION : 00:04:15.589000000
Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
DURATION : 00:04:15.641000000
File 'Alison-Krauss-Paper-Airplane.mkv.mp3' already exists. Overwrite ? [y/N] y
[mp3 @ 0x500cd031a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp3 @ 0x500cd031a0] Invalid audio stream. Exactly one MP3 audio stream is required.
Output #0, mp3, to 'Alison-Krauss-Paper-Airplane.mkv.mp3':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
encoder : Lavf57.41.100
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo (default)
Metadata:
DURATION : 00:04:15.641000000
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
[me@PANTRY 2723 ~/Grab/Movi]
$
Robert
+ Reply to Thread
Results 1 to 9 of 9
-
-
As my designation says I am a noob. I am a mere student of all digital media processes. I actually, from a listening point of view, prefer FLAC over MP3. I just need a reasonably easy procedure to extract audio from various video formats. When looking at different videos sometimes I get .MP4, MKV or WEBM and so on. Is there a call to 'ffmpeg' that will weather all the variability that the different video formats present?
I have heard of various containers such as Matroska, MP4 etc. , which can hold all means of this and that (files of different formats) but I do not always understand the difference between the containers and the actual formats themselves, like MP4.
How can I revise my usage of 'ffmpeg' so that I can handle the various intricacies of categorizations? -
Does the output have to be mp3 format?
If so, You might be able to add to the logic of the script to copy to mp3 (assuming the source is mp3)
or convert to mp3 otherwise.
Perhaps somebody who knows more about the scripting can help.
Another possibility is to copy the audio into an *.mka instead; it can hold virtually all audio types -
That ran OK. Thanks for that. I now have a file with the .mka which I am not sure what app plays it in its native form. One question I have is, does this 'format' retain all of the original quality (fidelity) necessary to further 'trancode' it to a FLAC and/or WAV digital media file? Or is it a more lossy format, which does not reasonably lend itself to such transcoding?
-
mka is the audio-only version of the mkv container. Mpv will play it, for ex.
Think of the container as a box, what's inside the box hasn't changed (ex: opus encoded audio).
m4a (mp4 audio) is a well supported container for aac audio.
if required transcoding losslessly to flac audio codec can be done with ffmpeg.
You probably shouldn't re-encode anything to mp3. -
butterw
Thank you for your post. So any main container (like Mastrka) can be broken down into three Sub-Containers: MKv, MKA and MKS That means that m4a is a 'format' within the MKA sub-container. There could be several audio formats like mp3, opus, FLAC, m4a etc within the container mkv and sub-container mka, have I got that correct? Can a container/sub-container have more than one audio file in it, at any one time, or are they created as required by each application?
As I understand it Mastroka is an open standard and MP4 is proprietary. Can MKV containers have proprietary codecs in them (such as a AAC or is that an issue of copyright or whatever? Thanks again for the information ... -
You can put almost anything in the mkv container that is why it was suggested.
I can't comment on features or support of mka though as I don't use it.
.m4a is a container like .mka, but it can only contain aac.
Similar Threads
-
FFMPEG: how to batch extract all audio streams into separate mono files?
By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 14th Aug 2019, 15:21 -
how to extract lossless audio from an MKV file - ffmpeg fails
By batemanj in forum Newbie / General discussionsReplies: 2Last Post: 17th Apr 2019, 07:50 -
ffmpeg: most efficient way to extract frame ranges?
By chconnor in forum Video ConversionReplies: 6Last Post: 27th Feb 2018, 02:16 -
ffmpeg lower the total bitrate after extract
By UnlikeME in forum Video ConversionReplies: 5Last Post: 4th Feb 2018, 03:52 -
FFMPEG: how to extract audio from a specific timecode point?
By marcorocchini in forum Newbie / General discussionsReplies: 8Last Post: 2nd Jul 2017, 11:38