I have a problem with some mp3 files. When transcoding the file with FFMPEG I get the following error:
[mp3float # 0x7fd42f813200] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
Is this a problem of the file itself, and how it is produced?
Or is it a problem of FFMPEG?
Here full decoding message:
ffmpeg version git-2020-07-28-dfd12ee Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.16)
configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-dfd12ee_2 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
libavutil 56. 57.100 / 56. 57.100
libavcodec 58. 97.102 / 58. 97.102
libavformat 58. 49.100 / 58. 49.100
libavdevice 58. 11.101 / 58. 11.101
libavfilter 7. 87.100 / 7. 87.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
[mp3 # 0x7fd42f808200] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'Ice Mc - Think About The Way.mp3':
Metadata:
title : Think About The Way
TBPM : 133
artist : Ice MC
date : 1994
track : 4/15
disc : 0
album_artist : ICE MC
Duration: 00:04:16.39, start: 0.000000, bitrate: 323 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 600x592 [SAR 72:72 DAR 75:74], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
comment : Other
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> wrapped_avframe (native))
Stream #0:0 -> #0:1 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
Metadata:
title : Think About The Way
TBPM : 133
artist : Ice MC
date : 1994
track : 4/15
disc : 0
album_artist : ICE MC
encoder : Lavf58.49.100
Stream #0:0: Video: wrapped_avframe, yuvj420p(progressive), 600x592 [SAR 72:72 DAR 75:74], q=2-31, 200 kb/s, 90k fps, 90k tbn, 90k tbc (attached pic)
Metadata:
comment : Other
encoder : Lavc58.97.102 wrapped_avframe
Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc58.97.102 pcm_s16le
[mp3float # 0x7fd42f813200] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:04:16.60 bitrate=N/A speed= 725x
video:1kB audio:44204kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
What is also noticed is that this mp3 has the cover embedded as a video stream. And there is also this weird cross mapping. Not sure if that is normal?
Are you sure, that you use only the stream you need? If no, you can check it by printing all the stream number of packets, returned by av_read_frame.
To select a specific stream, you should discard others. Check this thread to find out how: How to change stream index in libavformat
Related
I'm merging a video (recorded with ffmpeg, good quality, all solid), with a musicfile.mp3. However every couple of seconds the music stutters and skips slightly. Which seems very strange since simply adding music on top of a video sounds like the engine could relax and take its time, creating no artifacts. (In comparison to recording live desktop footage). Can anyone help me sort this out?
System: MacOS MBP 2015, 16gb ram 2.7ghz i5
ffmpeg -i "temp/1561246948349.mkv" -i "music/happy.mp3" -vcodec copy -filter_complex amix -map 0:v -map 0:a -map 1:a -shortest -b:a 144k "finished/2019-06-22/1561246948349/output.mkv"
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
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
Input #0, matroska,webm, from 'temp/1561246948349.mkv':
Metadata:
ENCODER : Lavf58.20.100
Duration: 00:00:21.50, start: 0.000000, bitrate: 5834 kb/s
Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv422p(progressive), 2880x1800, 30 fps, 30 tbr, 1k tbn, 2000k tbc (default)
Metadata:
ENCODER : Lavc58.35.100 libx264
DURATION : 00:00:21.467000000
Stream #0:1: Audio: vorbis, 44100 Hz, stereo, fltp (default)
Metadata:
ENCODER : Lavc58.35.100 libvorbis
DURATION : 00:00:21.496000000
Input #1, mp3, from 'music/happy.mp3':
Metadata:
album : Random
genre : Jazz & Blues
Duration: 00:15:59.84, start: 0.025057, bitrate: 186 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 186 kb/s
Metadata:
encoder : LAME3.100
Stream mapping:
Stream #0:1 (vorbis) -> amix:input0
Stream #1:0 (mp3float) -> amix:input1
amix -> Stream #0:0 (libvorbis)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, matroska, to 'finished/2019-06-22/1561246948349/output.mkv':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 44100 Hz, stereo, fltp, 144 kb/s (default)
Metadata:
encoder : Lavc58.35.100 libvorbis
Stream #0:1: Video: h264 (High 4:4:4 Predictive) (H264 / 0x34363248), yuv422p(progressive), 2880x1800, q=2-31, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Metadata:
ENCODER : Lavc58.35.100 libx264
DURATION : 00:00:21.467000000
frame= 640 fps=0.0 q=-1.0 Lsize= 15227kB time=00:00:21.46 bitrate=5810.3kbits/s speed=33.8x
video:14888kB audio:318kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 0.139864%
According to the FFmpeg documentation over here, I can change frame rate of a video using:
ffmpeg -i input.mkv -c:v copy -vsync drop -r 59.94 output.mkv
but all I am getting is an av_interleaved_write_frame(): Invalid argument error on my machine. What am I doing wrong?
Here is the log:
ffmpeg -i noaudio.mp4 -c:v copy -vsync drop -r 160 lapse.mp4
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'noaudio.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:12:31.45, start: 0.000000, bitrate: 59950 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59948 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
File 'lapse.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'lapse.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 59948 kb/s, 29.97 fps, 29.97 tbr, 10240 tbn, 160 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 # 0x7fec5400e000] 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
av_interleaved_write_frame(): Invalid argument
frame= 1 fps=0.0 q=-1.0 Lsize= 0kB time=-577014:32:22.77 bitrate=N/A speed=N/A
video:794kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
You cannot change the frame-rate without re-encoding the video file, so -c:v copy won´t work. Try to use -c:v libx264 -b:v -r 59.94 and any other option you may need.
I'm trying to capture a screenshot from a udp stream using ffmpeg in a Ubuntu 14.04 System.
Following is the command
ffmpeg -y -i udp_ip -vframes 1 -q:v 1 test.png
But the image captured is of very poor resolution and I observed a lag while taking the screenshot.
Please suggest a best tool or a way to take a screenshot in the fastest way and also of the best image resolution possible.
edit:
log files
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[mpeg2video # 0x390cc60] Invalid frame dimensions 0x0.
Last message repeated 7 times
Input #0, mpegts, from 'udp://#xxx.xx.xx.xx:xxxx':
Duration: N/A, start: 144.130744, bitrate: 4128 kb/s
Program 1
Metadata:
service_name : Program-1
service_provider: Encoder
Stream #0:0[0x42]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 16:15 DAR 4:3], 4000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x43]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'player.png':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: png, rgb24, 720x576 [SAR 16:15 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.89.100 png
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=1 drop=1 speed=0.729x
video:777kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Since, this seems to be an issue of aspect ratio, and not quality, per se, use
ffmpeg -y -i udp_ip -vf scale=iw*sar:ih,setsar=1 -vframes 1 -q:v 1 test.png
The scale filter rescales the video to square pixels. The SAR filter isn't strictly necessary but in case the PNG muxer writes that data, better to reset it.
I have a video of just under an hour recorded but it appears to be damaged somehow. The file format is h264 MP4 and the file size is 2.3 GB, so I'm confident that the information is there, just that the file format is damaged. How could I approach fixing it?
So far, I've tried a simple ffmpeg copy operation:
>ffmpeg -i video_28_07_2015_15_16_05.mp4 -c copy out.mp4
ffmpeg version N-73895-g323ec6b Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
libavutil 54. 28.100 / 54. 28.100
libavcodec 56. 50.101 / 56. 50.101
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 25.100 / 5. 25.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x2a78e00] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
video_28_07_2015_15_16_05.mp4: could not find codec parameters
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_28_07_2015_15_16_05.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
creation_time : 2015-07-28 14:12:50
Duration: 00:56:43.53, bitrate: 5345 kb/s
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none, 1280x720, SAR 1:1 DAR 16:9, 30 fps, 90k tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2015-07-28 14:12:50
handler_name : VideoHandle
[mp4 # 0x2a7b260] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf56.40.101
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), none, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 90k tbr, 90k tbn, 90k tbc (default)
Metadata:
creation_time : 2015-07-28 14:12:50
handler_name : VideoHandle
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
I have no idea of what to try next and would appreciate suggestions and guidance.
Ok, so untrunc by Federico Ponchio worked. The procedure (on Ubuntu 14.04 LTS) was as follows:
sudo apt-get -y install libavformat-dev libavcodec-dev libavutil-dev
wget https://github.com/ponchio/untrunc/archive/master.zip
unzip master.zip
cd untrunc-master
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil
./untrunc video_12_02_2015_15_02_58.mp4 video_28_07_2015_15_16_05.mp4
The first argument is an example working video from the same device and the second argument is the broken video. The program ran for a short time and a new working file called video_28_07_2015_15_16_05.mp4_fixed.mp4 was created.
Try to use my project: https://github.com/bookkojot/mp4fixer
Similar to untruc, it requires reference file.
Seems that Federico Ponchio made his untrunc available for everybody (non-Linux users also ;-) ): untrunc.it
i am convert my rtmp streaming to rtsp streaming using ffmpeg. the following code is doing the convert
ffmpeg -i rtmp://xxxxx.com/live/live1 -f rtsp rtsp://xxxxx.com:5454/test1-rtsp.mpg
After running above command it's return the following console. and i am getting connection refused for rtsp 5454 and aslo 554. how can i solve this ?
ffmpeg version N-60489-g03911c4 Copyright (c) 2000-2014 the FFmpeg developers
built on Feb 10 2014 05:44:38 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 63.101 / 52. 63.101
libavcodec 55. 50.100 / 55. 50.100
libavformat 55. 31.100 / 55. 31.100
libavdevice 55. 8.100 / 55. 8.100
libavfilter 4. 1.102 / 4. 1.102
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
[flv # 0x40d1440] Stream discovered after head already parsed
Input #0, flv, from 'rtmp://xxxxx.com/jiljillive/live1':
Metadata:
videokeyframe_frequency: 5
avclevel : 31
videodevice : Broadcast SC Video Filter
keywords :
audiochannels : 2
presetname : Custom
copyright :
audioinputvolume: 100
creationdate : Tue Feb 11 08:47:50 2014
:
author :
audiodevice : Microphone (SplitCam Virtual Au
avcprofile : 66
title :
description :
rating :
Duration: N/A, start: 0.000000, bitrate: 438 kb/s
Stream #0:0: Video: h264 (Baseline), yuv420p(tv), 320x240 [SAR 1:1 DAR 4:3], 307 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16p, 131 kb/s
Stream #0:2: Data: none
[tcp # 0x40f9c60] Connection to tcp://emedias.com:5454?timeout=0 failed: Connection refused
Output #0, rtsp, to 'rtsp://xxxxxx.com:5454/test1-rtsp.mpg':
Metadata:
videokeyframe_frequency: 5
avclevel : 31
videodevice : Broadcast SC Video Filter
keywords :
audiochannels : 2
presetname : Custom
copyright :
audioinputvolume: 100
creationdate : Tue Feb 11 08:47:50 2014
:
author :
audiodevice : Microphone (SplitCam Virtual Au
avcprofile : 66
title :
description :
rating :
encoder : Lavf55.31.100
Stream #0:0: Video: mpeg4, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream #0:1: Audio: aac (libvo_aacenc), 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (mp3 -> libvo_aacenc)
Could not write header for output file #0 (incorrect codec parameters ?): Input/output error