FFMPEG wmv conversion to flv - ffmpeg

anyone using ffmpeg
I have a fairly simple wmv exported by a user from movie maker with standard output and want to convert to .flv using
C:>ffmpeg -i "E:\Jab Core 4 Recounters.wmv" -vcodec flv "C:\Net Projects\SVN\IntegratedAlgorithmics\src\MediaAdmin\MediaAdmin\bin\Debug\Movies\Jab Core 4 Recounters.flv" -ar 44100
the output / error i receive is
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er --enable-avfilter-lavf --enable-pthreads --enable-avisynth --enable-libfaac -
-enable-libfaad --enable-libmp3lame --enable-libspeex --enable-libtheora --enabl
e-libvorbis --enable-libxvid --enable-libx264 --enable-memalign-hack
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]
[wmv3 # 0x1c0d490]Extra data: 8 bits left, value: 0
Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000
/1) -> 30.00 (30/1)
Input #0, asf, from 'E:\Jab Core 4 Recounters.wmv':
Duration: 00:01:55.99, start: 5.000000, bitrate: 813 kb/s
Stream #0.0: Audio: wmav2, 48000 Hz, stereo, s16, 192 kb/s
Stream #0.1: Video: wmv3, yuv420p, 640x480, 586 kb/s, 30 tbr, 1k tbn, 1k tbc
Output #0, flv, to 'C:\Net Projects\SVN\IntegratedAlgorithmics\src\MediaAdmin\Me
diaAdmin\bin\Debug\Movies\Jab Core 4 Recounters.flv':
Stream #0.0: Video: flv, yuv420p, 640x480, q=2-31, 200 kb/s, 90k tbn, 30 tbc
Stream #0.1: Audio: libmp3lame, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Stream #0.0 -> #0.1
[wmv3 # 0x1c0d490]Extra data: 8 bits left, value: 0
[libmp3lame # 0x1c0d8d0]flv does not support that sample rate, choose from (4410
0, 22050, 11025).
Could not write header for output file #0 (incorrect codec parameters ?)
i added th -ar switch when i got the error the first time
the codec info i have on the file is as follows
General
Complete name : E:\Jab Core 4 Recounters.wmv
Format : Windows Media
File size : 11.3 MiB
Duration : 2mn 0s
Overall bit rate mode : Variable
Overall bit rate : 780 Kbps
Maximum Overall bit rate : 949 Kbps
Encoded date : UTC 2009-03-07 07:02:41.121
Writing application : 6.0.6000.16386 / Windows Movie Maker
Application : Windows Movie Maker 6.0.6000.16386
Video
ID : 2
Format : VC-1
Format profile : MP#ML
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Duration : 2mn 0s
Bit rate mode : Variable
Bit rate : 587 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate : 30.000 fps
Resolution : 24 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.064
Stream size : 8.46 MiB (75%)
Language : en-us
Audio
ID : 1
Format : WMA2
Format profile : L3
Codec ID : 161
Codec ID/Info : Windows Media Audio 2
Description of the codec : Windows Media Audio 9.2 - VBR Quality 90, 48 kHz, stereo 1-pass VBR
Duration : 2mn 0s
Bit rate mode : Variable
Bit rate : 186 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Resolution : 16 bits
Stream size : 2.68 MiB (24%)
Language : en-us
i see alot of people with this issue with so solution or cause
any ideas would be helpful
thanks in advance

In ffmpeg, options must prefix the input file they relate to. Move -ar 44100 to the front and it will work.

I know question already has an answer but I thought it might help someone.
If you are facing the audio sample rate issue please use the following command
ffmpeg -i video.avi -ar 22050 video.flv
-i input file name
-ar audio sampling rate in Hz

For what little help it may be, you can see that the source audio is at 48khz, and flv is refusing it. ffmpeg is apparently ignoring your -ar flag. Your first step needs to be to resample the audio... you could try transcoding to some intermediary format to get the sample rate converted, and then transcode from there to flv.

More precisely: in ffmpeg, options must prefix the output file they relate to. Move -ar 44100 to the front of the output filename and it will work.

Related

Add coverart into ogg containing an opus audio stream with ffmpeg without re-encoding the audio stream

I'm trying to add a coverart into an ogg file with ffmpeg :
Here are my source.ogg and source.jpg files :
$ ffprobe -hide_banner source.ogg
Input #0, ogg, from 'source.ogg':
Duration: 00:03:02.45, start: 0.007500, bitrate: 73 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
$ identify source.jpg
source.jpg JPEG 480x360 480x360+0+0 8-bit DirectClass 15.1KB 0.000u 0:00.000
I tried this :
$ ffmpeg -hide_banner -i source.ogg -i source.jpg -map 0 -map 1 -c:a copy -c copy -map_metadata 0 dest.ogg -y && echo && ffprobe -hide_banner dest.ogg
Input #0, ogg, from 'source.ogg':
Duration: 00:03:02.45, start: 0.007500, bitrate: 73 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
Input #1, image2, from 'source.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 3023 kb/s
Stream #1:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 480x360 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[ogg # 0x5655578064c0] Unsupported codec id in stream 1
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Last message repeated 1 times
[ogg # 0x5655577e8540] Format ogg detected only with low score of 1, misdetection possible!
dest.ogg: End of file
I've also found this answer but it does not explain how to do it with ffmpeg.
I've read about a "METADATA_BLOCK_PICTURE" metadata in the ogg container that might contain the picture in base64, so I tried this :
$ ffmpeg -hide_banner -i source.ogg -map 0 -c:a copy -c copy -metadata METADATA_BLOCK_PICTURE="$(base64 source.jpg)" dest.ogg
Input #0, ogg, from 'source.ogg':
Duration: 00:03:02.45, start: 0.007500, bitrate: 73 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
File 'dest.ogg' already exists. Overwrite ? [y/N] y
Output #0, ogg, to 'dest.ogg':
Metadata:
METADATA_BLOCK_PICTURE: /9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz
: ODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2Nj
..............................................................................
: nVmaS2E/urUWVbH6ORI9z2l8zyRfFpkLooIHSBuk9lFFoC6OBnP1SON8rEooqM2WOVHDdRRAAUVK
: KiiCWRRRRBJ//9k=
encoder : Lavf58.20.100
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
METADATA_BLOCK_PICTURE: /9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz
: ODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2Nj
: Y2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY//AABEIAWgB4AMBIgACEQED
..............................................................................
: nVmaS2E/urUWVbH6ORI9z2l8zyRfFpkLooIHSBuk9lFFoC6OBnP1SON8rEooqM2WOVHDdRRAAUVK
: KiiCWRRRRBJ//9k=
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 1658kB time=00:03:02.41 bitrate= 74.5kbits/s speed=1.01e+03x
video:0kB audio:1624kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.100392%
It kinda "worked", but neither ffplay nor mpv can parse the cover art :
$ ffplay -hide_banner dest.ogg
[ogg # 0x5655577e8540] Failed to parse cover art block.
Input #0, ogg, from 'dest.ogg':
Duration: 00:03:02.44, start: 0.000000, bitrate: 74 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
3.95 M-A: -0.000 fd= 0 aq= 14KB vq= 0KB sq= 0B f=0/0
$ mpv dest.ogg
Playing: dest.ogg
[ffmpeg/demuxer] ogg: Failed to parse cover art block.
(+) Audio --aid=1 (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
A: 00:00:03 / 00:03:02 (2%)
Exiting... (Quit)
I alse tried -metadata:s:a along with the --wrap 0 of base64 (which I had forgotten to specify, oops :) ) :
$ ffmpeg -i source.ogg -map 0 -c:a copy -c copy -metadata:s:a METADATA_BLOCK_PICTURE="$(base64 --wrap 0 source.jpg)" dest.ogg
Input #0, ogg, from 'source.ogg':
Duration: 00:03:02.45, start: 0.007500, bitrate: 73 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
File 'dest.ogg' already exists. Overwrite ? [y/N] y
Output #0, ogg, to 'dest.ogg':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
METADATA_BLOCK_PICTURE: /9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY//AABEIAWgB4AMBIgACEQEDEQH/xAAaAAACAwEBAAAAAAAAAAA
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 1658kB time=00:03:02.41 bitrate= 74.5kbits/s speed=1.22e+03x
video:0kB audio:1624kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.084397%
But still the dest.ogg jpg coverart cannot be read properly :
$ ffprobe -hide_banner dest.ogg
[ogg # 0x5655577e8540] Invalid picture type: -2555936.
[ogg # 0x5655577e8540] Could not read mimetype from an attached picture.
Input #0, ogg, from 'dest.ogg':
Duration: 00:03:02.44, start: 0.000000, bitrate: 74 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
Metadata:
DURATION : 00:03:02.441000000
ENCODER : Lavf58.20.100
Can you please help me ?
FFmpeg version 4.4 automatically supports embedding album art into Ogg containers with the Theora video codec (see "Ogg codecs" on Wikipedia for a list of supported codecs, although they may not all be supported by FFmpeg).
This is not the the same as MP3 files, which store album art as binary encoded strings in special purpose tags. This allows media players to correctly detect it as an audio file (e.g. with mpv's --audio-display option) and prevent frame redrawing during playback. Ogg containers do not support this functionality, so FFmpeg simply adds a regular video stream to the file. The framerate of this video stream is set (at least for JPEGs) to 90000 resulting in a harmless warning.
This does not decrease performance at least with mpv, which only redraws as fast as the screen refresh rate allows. Only a single frame is encoded in the video stream, which can be manually verified by running ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.ogg as suggested in this answer. The framerate can be manually set to 1 with the -r:v 1 option if desired. See the comments for additional discussion.
Here's an example converting an MP3 file with a video track containing album art to an Ogg file with Opus encoded audio and Theora encoded video:
$ ffprobe -hide_banner '01 - State of Grace.mp3'
[mp3 # 0x5594cbafe320] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '01 - State of Grace.mp3':
Metadata:
lyrics-eng :
copyright : š 2012 Big Machine Records, LLC.
title : State of Grace
album_artist : Taylor Swift
album : Red (Deluxe Version)
date : 2012
track : 01/22
genre : Country
composer : Taylor Swift
disc : 1/1
comment : Taylor Swift
Duration: 00:04:55.81, start: 0.000000, bitrate: 321 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
title : Cover
comment : Cover (front)
$ ffmpeg -hide_banner -i '01 - State of Grace.mp3' -c:a libopus -b:a 128000 -c:v libtheora -q:v 10 '01 - State of Grace.ogg'
[mp3 # 0x55ebe6d3cc40] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '01 - State of Grace.mp3':
Metadata:
lyrics-eng :
copyright : š 2012 Big Machine Records, LLC.
title : State of Grace
album_artist : Taylor Swift
album : Red (Deluxe Version)
date : 2012
track : 01/22
genre : Country
composer : Taylor Swift
disc : 1/1
comment : Taylor Swift
Duration: 00:04:55.81, start: 0.000000, bitrate: 321 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
title : Cover
comment : Cover (front)
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:0 -> #0:1 (mp3 (mp3float) -> opus (libopus))
Press [q] to stop, [?] for help
[swscaler # 0x55ebe6db69e0] deprecated pixel format used, make sure you did set range correctly
[ogg # 0x55ebe6d44c80] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Output #0, ogg, to '01 - State of Grace.ogg':
Metadata:
lyrics-eng :
copyright : š 2012 Big Machine Records, LLC.
title : State of Grace
album_artist : Taylor Swift
album : Red (Deluxe Version)
date : 2012
track : 01/22
genre : Country
composer : Taylor Swift
disc : 1/1
comment : Taylor Swift
encoder : Lavf58.76.100
Stream #0:0: Video: theora, yuv444p(tv, bt470bg/unknown/unknown, progressive), 600x600 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k fps, 90k tbn (attached pic)
Metadata:
title : Cover
DESCRIPTION : Cover (front)
encoder : Lavc58.134.100 libtheora
lyrics-eng :
copyright : š 2012 Big Machine Records, LLC.
ALBUMARTIST : Taylor Swift
album : Red (Deluxe Version)
date : 2012
TRACKNUMBER : 01/22
genre : Country
composer : Taylor Swift
DISCNUMBER : 1/1
Stream #0:1: Audio: opus, 48000 Hz, stereo, flt, 128 kb/s
Metadata:
encoder : Lavc58.134.100 libopus
lyrics-eng :
copyright : š 2012 Big Machine Records, LLC.
title : State of Grace
ALBUMARTIST : Taylor Swift
album : Red (Deluxe Version)
date : 2012
TRACKNUMBER : 01/22
genre : Country
composer : Taylor Swift
DISCNUMBER : 1/1
DESCRIPTION : Taylor Swift
[mp3float # 0x55ebe6d96360] Header missing time=00:04:31.63 bitrate= 0.1kbits/s speed=59.8x 64x
Error while decoding stream #0:0: Invalid data found when processing input
frame= 1 fps=0.2 q=-0.0 Lsize= 4929kB time=00:04:55.79 bitrate= 136.5kbits/s speed=59.8x
video:58kB audio:4830kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 0.845459%
$ mpv '01 - State of Grace.ogg'
(+) Video --vid=1 'Cover' (theora 600x600)
(+) Audio --aid=1 'State of Grace' (opus 2ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch float
VO: [gpu] 600x600 yuv444p
(Paused) AV: -00:00:00 / 00:04:55 (0%)
Exiting... (Quit)
$
Note that the -q:v 10 Theora video codec option is used for the highest possible video quality. Without this option the album art is extremely low resolution by default, and the size difference when using the highest quality is negligible since only a single frame is being encoded.
This requires FFmpeg to be built with libtheora (and libopus for Opus encoded audio). Here is the output of ffmpeg -codecs with unrelated codecs removed and better formatting:
$ ffmpeg -codecs
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11.1.0
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--docdir=/usr/share/doc/ffmpeg-4.4.1-r1/html --mandir=/usr/share/man
--enable-shared --cc=x86_64-pc-linux-gnu-gcc
--cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar
--nm=x86_64-pc-linux-gnu-nm --ranlib=x86_64-pc-linux-gnu-ranlib
--pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-O2 -pipe
-march=native -ggdb3' --extra-libs= --enable-static --enable-avfilter
--enable-avresample --disable-stripping --disable-optimizations
--disable-libcelt --enable-nonfree --disable-indev=v4l2
--disable-outdev=v4l2 --disable-indev=oss --disable-indev=jack
--disable-indev=sndio --disable-outdev=oss --disable-outdev=sndio
--enable-bzlib --enable-runtime-cpudetect --disable-debug
--disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl
--disable-hardcoded-tables --enable-iconv --disable-libxml2 --enable-lzma
--enable-network --disable-opencl --enable-openssl --enable-postproc
--disable-libsmbclient --disable-ffplay --disable-sdl2 --disable-vaapi
--disable-vdpau --disable-vulkan --enable-xlib --enable-libxcb
--enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib
--disable-libcdio --disable-libiec61883 --disable-libdc1394
--disable-libcaca --enable-openal --enable-opengl --disable-libv4l2
--disable-libpulse --disable-libdrm --disable-libjack
--disable-libopencore-amrwb --disable-libopencore-amrnb
--disable-libcodec2 --enable-libdav1d --disable-libfdk-aac
--disable-libopenjpeg --disable-libbluray --disable-libgme
--disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug
--enable-libopus --disable-libilbc --disable-librtmp --disable-libssh
--disable-libspeex --disable-libsrt --disable-librsvg --disable-ffnvcodec
--disable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit
--disable-libbs2b --disable-chromaprint --disable-cuda-llvm
--disable-libflite --disable-frei0r --disable-libfribidi
--enable-fontconfig --disable-ladspa --disable-libass
--disable-libtesseract --disable-lv2 --disable-libfreetype
--disable-libvidstab --disable-librubberband --disable-libzmq
--disable-libzimg --disable-libsoxr --enable-pthreads
--disable-libvo-amrwbenc --disable-libmp3lame --disable-libkvazaar
--enable-libaom --disable-libopenh264 --disable-librav1e
--disable-libsnappy --enable-libtheora --disable-libtwolame
--disable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid
--disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2
--disable-neon --disable-vfp --disable-vfpv3 --disable-armv8
--disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec
--disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext
--disable-aesni --disable-avx --disable-avx2 --disable-fma3
--disable-fma4 --disable-sse3 --disable-ssse3 --disable-sse4
--disable-sse42 --disable-xop --cpu=host --disable-doc
--disable-htmlpages --enable-manpages
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Codecs:
D..... = Decoding supported
.E.... = Encoding supported
..V... = Video codec
..A... = Audio codec
..S... = Subtitle codec
...I.. = Intra frame-only codec
....L. = Lossy compression
.....S = Lossless compression
-------
[...]
DEV.L. theora Theora (encoders: libtheora )
[...]
DEAIL. opus Opus (Opus Interactive Audio Codec)
(decoders: opus libopus ) (encoders: opus libopus )
[...]
$
FFmpeg can also add album art (or any video track) from a separate file, instead of directly mapping the original album art to the output. Here's an example of how to extract the original MJPEG album art as a separate file, then pass it back in and using the -map option to only use the audio track from the MP3 and the video track from the MJPEG (I removed most of the output of the commands since they are basically the same):
$ ffmpeg -i '01 - State of Grace.mp3' -map 0:v -c:v copy '01 - State of Grace.jpg'
[...]
$ ffmpeg -i '01 - State of Grace.mp3' -i '01 - State of Grace.jpg' -map 0:a -map 1:v '01 - State of Grace.ogg'
[...]
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> flac (native))
Stream #1:0 -> #0:1 (mjpeg (native) -> theora (libtheora))
[...]
I also omitted the audio and video codecs and their options (which I wouldn't suggest) so FFmpeg used FLAC as the default audio codec and Theora as the default video codec for an Ogg container.
Hope this helps!
This works for me:
ffmpeg -i mysong.ogg -i coverart.jpg song_with_art.ogg

Is there any way to edit just the track data of an AVI file, like mkvpropedit does with MKV files?

I am trying to swap the order of 2 audio tracks of an AVI file using ffmpeg.
ffmpeg -i "infile.avi" -map 0:0 -map 0:2 -map 0:1 -c copy "outfile.avi"
This works but the file is being re-encoded, not copied. It takes much longer than a straight copy to finish and the resulting file is larger than the original.
Is there any way to edit just the track data of an AVI file, like mkvpropedit does with MKV files? Command line tool preferred.
General
Complete name : infile.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 451 MiB
Duration : 43mn 11s
Overall bit rate : 1 460 Kbps
Writing application : VirtualDubMod 1.5.10.2 (build 2540/release)
Writing library : VirtualDubMod build 2540/release
Video
ID : 0
Format : MPEG-4 Visual
Format profile : Advanced Simple#L5
Format settings, BVOP : 3
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (MPEG)
Muxing mode : Packed bitstream
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 43mn 11s
Bit rate : 1 190 Kbps
Width : 656 pixels
Height : 368 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.206
Stream size : 367 MiB (82%)
Writing library : XviD 1.2.1 (UTC 2008-12-04)
Audio #1
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 43mn 11s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel count : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 39.5 MiB (9%)
Alignment : Aligned on interleaves
Interleave, duration : 42 ms (1.00 video frame)
Interleave, preload duration : 504 ms
Writing library : LAME3.98r
Encoding settings : -m s -V 4 -q 2 -lowpass 17 -b 128
Audio #2
ID : 2
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 43mn 11s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel count : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 39.5 MiB (9%)
Alignment : Aligned on interleaves
Interleave, duration : 42 ms (1.00 video frame)
Interleave, preload duration : 504 ms
Writing library : LAME3.98r
Encoding settings : -m s -V 4 -q 2 -lowpass 17 -b 128
$ ffmpeg -i "infile.avi" -map 0:0 -map 0:2 -map 0:1 -c copy "outfile.avi"
ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libsnappy --enable-libfontconfig --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libass --enable-ffplay --enable-libssh --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-openssl --enable-libopus --enable-frei0r --enable-libcaca --enable-libsoxr --enable-libvidstab --enable-libx265 --enable-libwebp --enable-libbs2b --enable-librubberband --enable-libopenh264 --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-nonfree --enable-vda
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, avi, from 'infile.avi':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2540/release)
Duration: 00:44:03.10, start: 0.000000, bitrate: 1434 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 656x368 [SAR 1:1 DAR 41:23], 1164 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
[avi # 0x7f826b03d200] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 2 times
Output #0, avi, to 'outfile.avi':
Metadata:
ISFT : Lavf57.41.100
Stream #0:0: Video: mpeg4 (XVID / 0x44495658), yuv420p, 656x368 [SAR 1:1 DAR 41:23], q=2-31, 1164 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, 128 kb/s
Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Stream #0:1 -> #0:2 (copy)
Press [q] to stop, [?] for help
[avi # 0x7f826b03d200] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=63371 fps=1830 q=-1.0 Lsize= 465060kB time=00:44:03.10 bitrate=1441.4kbits/s speed=76.3x
video:375760kB audio:82597kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.462486%
infile.avi 474 MB
outfile.avi 476.2 MB

ffmpeg live rtmp stream does not start to process for long time

I have rtmp stream created by flash player in h264 but when i convert it to video or tumbnail using ffmpeg it some times works after very very long time and some time not work but if I create a stream with Flash Media live encoder on same FMS server the command below works fine. At the same time if I try the stream in player it works well and fine.
I am using IP so DNS resolving issue is not possible either I think.
ffmpeg -i rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 -r 1 -an -updatefirst 1 -y thumbnail.jpg
Following is when it worked aftre 15 - 20 minutes
ffmpeg -i "rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 live=1" -r 1 -an -updatefirst 1 -y thumb.jpg
[root#test ~]# ffmpeg -i rtmp://38.125.41.20/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 -r 1 -an -updatefirst 1 -y thumbnail.jpg
ffmpeg version N-49953-g7d0e3b1-syslint Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 14 2013 15:29:40 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil 52. 17.101 / 52. 17.101
libavcodec 54. 91.103 / 54. 91.103
libavformat 54. 63.100 / 54. 63.100
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 37.101 / 3. 37.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[flv # 0x14c0100] Stream #1: not enough frames to estimate rate; consider increasing probesize
[flv # 0x14c0100] Could not find codec parameters for stream 1 (Audio: none, 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv # 0x14c0100] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://xxx.xxx.xx.xx/bdeef2c065509361e78fa8cac90aac741cc5ee29':
Metadata:
keyFrameInterval: 15
quality : 90
level : 3.1
bandwith : 0
codec : H264Avc
fps : 15
profile : baseline
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0:1: Audio: none, 0 channels
Output #0, image2, to 'thumbnail.jpg':
Metadata:
keyFrameInterval: 15
quality : 90
level : 3.1
bandwith : 0
codec : H264Avc
fps : 15
profile : baseline
encoder : Lavf54.63.100
Stream #0:0: Video: mjpeg, yuvj420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 2723 fps=1.3 q=1.6 size=N/A time=00:45:23.00 bitrate=N/A dup=8 drop=12044
and on stopping the stream by closing the browser running the flash player which is publishing the video I get the following
[flv # 0x23684e0] Could not find codec parameters for stream 1 (Audio: none, 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv # 0x23684e0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29':
Metadata:
keyFrameInterval: 15
quality : 90
bandwith : 0
level : 3.1
codec : H264Avc
fps : 15
profile : baseline
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0:1: Audio: none, 0 channels
when if i stop the stream it quickly creates a thumbnail file where as running stream is an issue.
I found the reason and cause of this, if a stream created by flash not no microphone selected the audio channel is 0 in rtmp published stream so for that reason the audio codec part of rtmp goes into some kind of loop and not returns and goes further . I have found the cause . but looking for a way to get rid if this loop incase there is no audio channel . may be might have to modify the source code of rtmp and compile again .

ffmpeg: AVI to FLV conversion doubles file size

I convert AVI to FLV with ffmpeg using -sameq parameter (same quality):
ffmpeg -i test.avi -sameq -f flv sameq.flv
The resulting file has the same video and audio quality as the original, but it's more than twice the original file size:
84M sameq.flv
41M test.avi
Why does it happen?
Transcoder output:
ffmpeg version N-34750-g070d2d7, Copyright (c) 2000-2011 the FFmpeg developers
built on Nov 12 2011 11:23:07 with gcc 4.6.1
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 51. 24. 1 / 51. 24. 1
libavcodec 53. 33. 0 / 53. 33. 0
libavformat 53. 20. 0 / 53. 20. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 48. 0 / 2. 48. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from 'test.avi':
Duration: 00:06:30.00, start: 0.000000, bitrate: 866 kb/s
Stream #0:0: Video: mpeg4 (Advanced Real Time Simple Profile) (DIVX / 0x58564944), yuv420p, 400x300 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, mono, s16, 64 kb/s
[buffer # 0xa247ae0] w:400 h:300 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
Output #0, flv, to 'sameq.flv':
Metadata:
encoder : Lavf53.20.0
Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 400x300 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 25 tbc
Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, mono, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> flv)
Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
frame= 9742 fps=255 q=0.0 Lsize= 85074kB time=00:06:30.00 bitrate=1787.0kbits/s
video:79163kB audio:5525kB global headers:0kB muxing overhead 0.455568%
Two thing comes to mind:
Compress a video without audio stream to eliminate the audio portion of this issue. BTW, the audio source is HALF the bitrate of the output, that increases the size a little. Use -ar and -ab switches to control the output.
Check out this article on qscale vs quality using -qscale option. Add in the -b (bitrate) and -s (size) and tweak it to your needs.
When all fails, there are a few switches you can try from the ffmpeg website or try using the new H.264 compression, the two pass option is recommended. Have fun compressing
its because of -sameq. It gives you a good quality but pay the price with a bigger file size.
Can you try adding:
-qcomp 1.0
video quantizer scale compression ( VBR ) (default 0.5). Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0

FFMPEG - Scale video filter not providing expected results

Apologies if this question has been asked. I couldn't find it, but if it has, please let me know and I'll close this out.
I'm attempting a simple scale of a video whose original dimensions are 480x360 and whose target dimensions are 400x300. The video starts as an FLV and eventually needs to end up as an MPEG. I'm using the following command line to do this:
ffmpeg -i user.flv -vf "scale=400:300" user_scaled.mpg
When I play the scaled video in MPEG Streamclip, the scale is correct and the video info shows that the dimensions are 400x300. However, when I play the scaled video in Quicktime, the video is scaled to 478x359. More importantly, FFMPEG, itself, treats the video as being 478x359, so any future commands (trimming, conversion, overlaying, etc) executed on it result in a video of 478x359.
The initial workflow required an FLV to MPEG conversion, but I've tried this with several different in and out formats (FLV -> FLV, FLV -> MPEG, MPEG -> MPEG, etc) all with the same results. As long as I can end up with an MPEG, though, I can deal with however many steps and conversions it would take to get this scaling working.
I'll paste the command-line output below, and a sample input video is also linked below, if you'd like it. Thank you very much for any help.
http://www.monkeydriver.com/dpassera/stack_flv.zip
Command-line output:
ffmpeg -i user.flv -vf "scale=400:300" user_scaled.mpg
ffmpeg version 0.7-rc1, Copyright (c) 2000-2011 the FFmpeg developers
built on May 21 2011 22:13:19 with gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--mandir=/usr/share/man --incdir=/usr/include --disable-avisynth
--extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC'
--enable-avfilter --enable-libdirac --enable-libgsm --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264
--enable-gpl --enable-postproc --enable-pthreads --enable-shared
--enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
--disable-yasm --enable-filters --enable-filter=movie
libavutil 50. 40. 1 / 50. 40. 1
libavcodec 52.120. 0 / 52.120. 0
libavformat 52.108. 0 / 52.108. 0
libavdevice 52. 4. 0 / 52. 4. 0
libavfilter 1. 77. 0 / 1. 77. 0
libswscale 0. 13. 0 / 0. 13. 0
libpostproc 51. 2. 0 / 51. 2. 0
[flv # 0x11dd3b30] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'user.flv':
Metadata:
duration : 5
videocodecid : 2
audiocodecid : 6
canSeekToEnd : true
createdby : FMS 4.0
creationdate : Mon Oct 31 11:43:44 2011
Duration: 00:00:04.62, start: 0.000000, bitrate: N/A
Stream #0.0: Video: flv, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: nellymoser, 44100 Hz, mono, s16
[buffer # 0x11ddc950] w:640 h:480 pixfmt:yuv420p
[scale # 0x11dda610] w:640 h:480 fmt:yuv420p -> w:400 h:300 fmt:yuv420p flags:0xa0000004
[mpeg # 0x11dd6bd0] VBV buffer size not set, muxing may fail
Output #0, mpeg, to 'user_scaled.mpg':
Metadata:
duration : 5
videocodecid : 2
audiocodecid : 6
canSeekToEnd : true
createdby : FMS 4.0
creationdate : Mon Oct 31 11:43:44 2011
encoder : Lavf52.108.0
Stream #0.0: Video: mpeg1video, yuv420p, 400x300, q=2-31, 200 kb/s, 90k tbn, 60 tbc
Stream #0.1: Audio: mp2, 44100 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 230 fps= 0 q=10.2 size= 366kB time=3.82 bitrate= 785.6kbits/s dup=175 drop=0
frame= 267 fps= 0 q=10.7 Lsize= 412kB time=4.43 bitrate= 761.3kbits/s dup=203 drop=0
video:370kB audio:36kB global headers:0kB muxing overhead 1.568959%
After much gnashing of teeth, I think the problem has nothing to do with ffmpeg, and everything to do with Quicktime.
Quicktime Player (10.1 (501.5)) scales videos to match the size of the window, and has a minimum window size. So regardless of the actual video size, Quicktime will scale it to at least 480 by 360. This is why the info display has size information in the "Format" section (the true size), but also has a "Current Size" section. Changing the window size changes that latter number.
So, scale videos using ffmpeg either with -vf scale or just -s, but don't trust Quicktime Player to show them to you at the correct size. I recommend VLC as a very capable alternative.

Resources