While I am trying to convert wav file to wma file size is becomes much larger than original source file:
input.wav - 11M
output.wma - 16M
Is there any way to reduce file size of output file?
Command and output:
$ ffmpeg -i input.wav -c copy output.wma
ffmpeg version N-80797-g8b4d6cc Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.1.1 (GCC) 20160501
configuration: --enable-gpl
libavutil 55. 27.100 / 55. 27.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 40.101 / 57. 40.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 46.102 / 6. 46.102
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'input.wav':
Metadata:
encoder : Lavf57.40.101
Duration: 00:01:00.00, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Output #0, asf, to 'output.wma':
Metadata:
WM/EncodingSettings: Lavf57.40.101
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 16150kB time=00:01:00.00 bitrate=2205.1kbits/s speed=1.9e+03x
video:0kB audio:10336kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 56.255745%
WMA is crappy. Try changing the packet size. From FFmpeg ASF muxer documentation:
-packet_size
Set the muxer packet size. By tuning this setting you
may reduce data fragmentation or muxer overhead depending on your
source. Default value is 3200, minimum is 100, maximum is 64k.
Example:
ffmpeg -i input.wav -c copy -packet_size 65536 output_64k.wma
File sizes:
input.wav - 11M
output_64k.wma - 11M
output_default.wma - 16M
Related
I have a m3u8 vod video on my server. It's working correctly. Now I want to create a smaller size for mobile devices.
Need to create a 480p m3u8 file.
I've tried this code but it's not worked.
ffmpeg -i HD.m3u8 -vf scale=842:-1 -c:a copy -start_number 0 -hls_time 8 -hls_list_size 0 -f hls ./SM.m3u8
And here is my error code:
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[hls,applehttp # 0x55a16f22a880] Opening 'HD0.ts' for reading
Input #0, hls,applehttp, from 'HD.m3u8':
Duration: 02:05:08.29, start: 1.460111, bitrate: 0 kb/s
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 24 fps, 24 tbr, 90k tbn, 48 tbc
Metadata:
variant_bitrate : 0
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 # 0x55a16f267880] height not divisible by 2 (842x351)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Is it possible to convert it from a m3u8 file or do I need the original mp4 file for this?
H.264 4:2:0 sampled video has to have even dimensions, so it should be -vf scale=842:-2.
Also, for -hls_time 8, you have to ensure keyframes exist every 8 seconds. Add -force_key_frames expr:gte(t,n_forced*8)
"volume" filter does not work in complex filter. The volume is not affected in the converted audio.
env: Mac OS 10.12.6
ffmpeg -i /path/bg.mp3 -y -filter_complex [0:0]volume=0[output] -map
[output] -acodec libmp3lame -write_xing 0 /path/mixed.mp3
full log =====================================================================
liqideMacBook-Pro:pinyin-api work$ ffmpeg -i
/Users/work/dev/codebase/pinyin/pinyin-api/test/resources/bg_audio2.mp3
-y -filter_complex [0:0]volume=0.1[output] -map [output] -acodec
libmp3lame -f mp3 -write_xing 0 /Users/work/dev/codebase/pinyin/pinyin-
api/test/resources/mixed3.mp3
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-
shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --
enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-
gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-
opencl --enable-videotoolbox --disable-lzma
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
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mp3, from '/Users/work/dev/codebase/pinyin/pinyin-
api/test/resources/bg_audio2.mp3':
Metadata:
title : 喜洋洋
album : 贺岁新年音乐会
encoder : Lavf56.4.101
Duration: 00:02:43.58, start: 0.025057, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Stream mapping:
Stream #0:0 (mp3) -> volume
volume -> Stream #0:0 (libmp3lame)
Press [q] to stop, [?] for help
Output #0, mp3, to '/Users/work/dev/codebase/pinyin/pinyin-
api/test/resources/mixed3.mp3':
Metadata:
TIT2 : 喜洋洋
TALB : 贺岁新年音乐会
TSSE : Lavf57.83.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp
Metadata:
encoder : Lavc57.107.100 libmp3lame
[libmp3lame # 0x7fad80001a00] Trying to remove 1152 samples, but the
queue is empty
size= 2556kB time=00:02:43.57 bitrate= 128.0kbits/s speed=51.7x
video:0kB audio:2556kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.003782%
liqideMacBook-Pro:pinyin-api work$
=====================================================================
The duration of source video and subtracted wav audio is different , why?
I'm recorgnizing subtitle from audio, and I need to add subtitle back to video. So I want the duration of audio and video the same.
ffmpeg -i http://cdn.live.360.cn/huikan_news/vod-media/_XW_203286B417B7C6466B3B_20160627185953.m3u8 -vn test.wav -y
My CLI:
[zhangpengcheng#mobiledev03v ifly]$ ffprobe http://cdn.live.360.cn/huikan_news/vod-media/_XW_203286B417B7C6466B3B_20160627185953.m3u8 2>&1 | grep Duration
Duration: 00:06:51.99, start: 1.400000, bitrate: 0 kb/s
[zhangpengcheng#mobiledev03v ifly]$ ffmpeg -i http://cdn.live.360.cn/huikan_news/vod-media/_XW_203286B417B7C6466B3B_20160627185953.m3u8 -vn test.wav -y
ffmpeg version 3.1.3 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --prefix=./build/ --enable-shared --enable-static --enable-libx264 --enable-avisynth --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libopencv --enable-librtmp --enable-gpl --enable-nonfree
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
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, hls,applehttp, from 'http://cdn.live.360.cn/huikan_news/vod-media/_XW_203286B417B7C6466B3B_20160627185953.m3u8':
Duration: 00:06:51.99, start: 1.400000, bitrate: 0 kb/s
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p(tv, smpte170m/bt709/bt709), 668x376, 15 tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 65 kb/s
[wav # 0x10182e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, wav, to 'test.wav':
Metadata:
ISFT : Lavf57.41.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Metadata:
encoder : Lavc57.48.101 pcm_s16le
Stream mapping:
Stream #0:1 -> #0:0 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size= 31904kB time=00:06:51.84 bitrate= 634.6kbits/s speed= 146x
video:0kB audio:31904kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000239%
[zhangpengcheng#mobiledev03v ifly]$ ffprobe test.wav 2>&1 | grep Duration
Duration: 00:06:10.40, bitrate: 705 kb/s
Looks like there are gaps in the original audio.
Use
ffmpeg -i http://cdn.live.360.cn/huikan_news/vod-media/_XW_203286B417B7C6466B3B_20160627185953.m3u8 -af aresample=async=1 -vn test.wav -y
The audio filter will fill in the gaps.
i am trying to stream a file that I have in my directory using ffmpeg and ffserver. But an error occurs in both ffmpeg and ffserver. The following is my ffserver config file.
HTTPPort 8092
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 2000
CustomLog -
#NoDaemon
NoDefaults
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 20M
ACL allow 127.0.0.1
</Feed>
<Stream live.webm>
Feed feed1.ffm
Format webm
AudioCodec vorbis
AudioBitRate 64
VideoCodec libvpx
VideoSize 720x576
VideoFrameRate 25
AVOptionVideo flags +global_header
AVOptionVideo cpu-used 0
AVOptionVideo qmin 10
AVOptionVideo qmax 42
AVOptionVideo quality good
AVOptionAudio flags +global_header
PreRoll 15
StartSendOnKey
VideoBitRate 400
AudioSampleRate 44100
</Stream>
I am able to start ffserver properly with no problems but when i try to serve ffserver with a file using ffmpeg, this happens
ffmpeg -i sam.webm http://127.0.0.1:8092/feed1.ffm -vcodec copy
ffmpeg version N-72738-g7630cce Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-libvpx --enable-libvorbis --enable-libx264 --enable-gpl --enable-nonfree
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Trailing options were found on the commandline.
Input #0, matroska,webm, from 'sam.webm':
Metadata:
title : Sintel Trailer
encoder : Lavf56.25.101
Duration: 00:00:52.21, start: 0.000000, bitrate: 305 kb/s
Stream #0:0: Video: vp8, yuv420p, 854x480, SAR 1:1 DAR 427:240, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx # 0x367e180] v1.3.0
Output #0, ffm, to 'http://127.0.0.1:8092/feed1.ffm':
Metadata:
title : Sintel Trailer
creation_time : now
encoder : Lavf56.36.100
Stream #0:0: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
encoder : Lavc56.41.100 libvorbis
Stream #0:1: Video: vp8 (libvpx), yuv420p, 720x576 [SAR 427:300 DAR 427:240], q=10-42, 400 kb/s, 24 fps, 1000k tbn, 25 tbc (default)
Metadata:
encoder : Lavc56.41.100 libvpx
Stream mapping:
Stream #0:1 -> #0:0 (vorbis (native) -> vorbis (libvorbis))
Stream #0:0 -> #0:1 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Connection reset by peer
Last message repeated 2 times
frame= 14 fps=0.0 q=0.0 Lsize= 16kB time=00:00:00.56 bitrate= 234.1kbits/s dup=1 drop=0
video:1kB audio:2kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 327.780670%
Conversion failed!
And this is the message i get in ffserver when this error happens in ffmpeg.
ffserver
ffserver version N-72738-g7630cce Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-libvpx --enable-libvorbis --enable-libx264 --enable-gpl --enable-nonfree
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Mon Jun 8 18:38:28 2015 FFserver started.
Mon Jun 8 18:38:40 2015 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
Mon Jun 8 18:38:40 2015 [NULL # 0x29878a0]Missing key or no key/value separator found after key 'pkt_timebase'
Mon Jun 8 18:38:40 2015 Feed '/tmp/feed1.ffm' stream number does not match registered feed
Mon Jun 8 18:38:40 2015 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 4096
Can someone please help me?
If you have the file in your directory you could try to skip the feed section. This way, ffserver will make the file ready for streaming when the server gets started and you don't have to use the ffmpeg-command.
Instead of :
<Stream live.webm>
Feed feed1.ffm
...
Use:
<Stream live.webm>
Format webm #if needed
File "sam.webm"
...
You might want to go through the feed, if you want to manipulate the file first.
I have installed ffmpeg on cygwin from source code. I need to convert mp3 files to raw audio, but it fails with the following error message:
Assertion !link->frame_requested || link->flags & FF_LINK_FLAG_REQUEST_LOOP failed
at libavfilter/avfilter.c:360
Do I have some codec missing? Any help would be appreciated.
Here's the full output of ffmpeg (audio metadata snipped):
$ ffmpeg -i 2quickstart.mp3 -ac 1 -ar 11025 -f s16le -t 20 -ss 10 2quickstart.raw
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 20 2013 13:26:12 with gcc 4.8.2 (GCC)
configuration:
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
[mp3 # 0x80022040] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '2quickstart.mp3':
Metadata:
--snip--
Duration: 00:03:37.87, start: 0.000000, bitrate: 255 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 256 kb/s
Output #0, s16le, to '2quickstart.raw':
Metadata:
--snip--
encoder : Lavf55.19.104
Stream #0:0: Audio: pcm_s16le, 11025 Hz, mono, s16, 176 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 -> pcm_s16le)
Press [q] to stop, [?] for help
Assertion !link->frame_requested || link->flags & FF_LINK_FLAG_REQUEST_LOOP failed
at libavfilter/avfilter.c:360
Aborted (core dumped)