First of all, I'd like to say that I've spent the whole day on researching the issue, tried everything I found on the web and none of the solutions worked, so I'm hopeless.
I'm testing live streaming using Azure Media Services. When the event is stopped, I'd like to get the recording as a single MP4 file, but Azure saves the video and audio tracks separately in a fragmented form. I figured out that I can concatenate these files (I used OSX cat command), so I do have perfectly working MP4 files for video and audio - both of them play without any interruptions and seem just fine.
Here's the FFmpeg info on these files:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video_1200k.mp4':
Metadata:
major_brand : isml
minor_version : 512
compatible_brands: ismlpiff
encoder : Lavf58.45.100
Duration: 01:05:49.57, start: 0.085000, bitrate: 1166 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 1163 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'audio_128k.mp4':
Metadata:
major_brand : isml
minor_version : 512
compatible_brands: ismlpiff
encoder : Lavf58.45.100
Duration: 01:06:09.57, start: 0.000000, bitrate: 132 kb/s
Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : Audio
vendor_id : [0][0][0][0]
I noticed the duration difference, but I thought that when I mux these streams, I would get a file in which the last few seconds would have just the audio track. I started with testing the most basic FFmpeg command ffmpeg -i video_1200k.mp4 -i audio_128k.mp4 -c copy muxed.mp4, however the A/V turned out to be out of sync - the video is ahead of audio and the gap increases quite a lot over time.
I've tried pretty much every FFmpeg command arguments I found in similar post, including re-encoding, offsetting the audio, speeding up the audio (to match the video duration), adding audio filters (aresample=async with different values) and none of them helped - all I managed to achieve is getting a sync at the beginning of the video, but the audio keeps getting more and more delayed (at 50 mins the delay is like 15 seconds).
Any ideas what am I doing wrong? Any hints would be highly appreciated.
Thanks a lot in advance!
Related
Please help me understand! I spent a lot of time...:( Thank you!
I'm stuck with a problem. I have a stream with damaged video and normal audio. And 2nd video, continued, with normal video and audio. I want to attach a picture to the beginning of an undamaged video with normal audio from damaged video without re-encoding the normal video.
I try this one:
ffmpeg -hide_banner -loop 1 -framerate 50 -t 3478 -i image.jpg -t 3478 -i audio.mp3 -i video.mp4 -filter_complex "[0:0] [1:0] [2:0] [2:1] concat=n=2:v=1:a=1" output.mp4
But it converts normal video.
Mediainfo from normal video:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:56:31.61, start: 0.000000, bitrate: 3726 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3594 kb/s, 27.46 fps, 50 tbr, 50k tbn, 100 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
When trying to get a clip of a video from a remote source
Input source:
ffprobe version 3.3.2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2017 the FFmpeg developers
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://website.com/video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-07-13T15:44:58.000000Z
Duration: 00:57:32.42, start: 0.000000, bitrate: 1939 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 720x480 [SAR 10:11 DAR 15:11], 1745 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc (default)
Metadata:
creation_time : 2017-07-13T15:44:58.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2017-07-13T15:44:58.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
Current command:
ffmpeg version 3.3.2-static
ffmpeg.linux -threads 2 -y -ss 3273 -i "http://website.com/video.mp4" -an -movflags +faststart -preset veryfast -codec copy /outputfolder/trimmed_video.mp4
This 5m35.102s to create a 45mb 2min file.
If I download the file using wget it takes 28s and using ffmpeg only takes 0.243s
If I add -vn OR -an to the output portion of the command it completes the trim in about 2.101s. Meaning it's faster to download the two stream and merge them myself.
Can anyone explain this behaviour and why my first command takes so long when on a lot of other video files it's very fast?
Videos where the command completed fast were optimized for streaming by youtube.
User uploaded media was not optimized.
Running ffmpeg with -movflags +faststart on the files fixed the issues server side.
I have successfully created h264/mp4 movie files with ffmpeg and the x264 library.
Now I would like to change the h264 library from x264 to openH264. I could replace the x264 library with openH264, recompile ffmpeg and produce movie files, without changing my sources that produce the movie. The resulting movie opens fine in Quicktime on Mac, but on Windows, Windows Media Player 12 cannot play it.
The documentation about Windows Media Player support for h264 is unclear. File types supported by Windows Media Player states in the table that Windows Media Player 12 supports mp4, but the text below says:
Windows Media Player does not support the playback of the .mp4 file format.
From what I have observed, Windows Media Player 12 IS capable of playing h264/mp4 files, but only when created with x264.
Does anyone know how I need to adjust the configuration of the codec/context so that the movie plays in Windows Media Player? Does Windows Media Player only support certain h264 profiles?
I noticed the warning:
[libopenh264 # 0x...] [OpenH264] this = 0x..., Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame
With the configuration:
av_dict_set(&options, "allow_skip_frames", "1", 0);
I could get rid of this warning, but the movie still does not play. Are there other options that need to be set so that the movie plays in Windows Media Player?
Thank you for your help
ffprobe output of the file that does play fine in Windows Media Player:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_x264.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : retina
encoder : Lavf57.56.100
comment : Creation Date: 2017-03-10 07:47:39.601
Duration: 00:00:04.17, start: 0.000000, bitrate: 17497 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),
yuv420p, 852x754, 17495 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
ffprobe output of the file that does not play in Windows Media Player:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_openh264.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : retina
encoder : Lavf57.56.100
comment : Creation Date: 2017-03-10 07:49:27.024
Duration: 00:00:04.17, start: 0.000000, bitrate: 17781 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661),
yuv420p, 852x754, 17779 kb/s, 24 fps, 24 tbr, 24k tbn, 48k tbc (default)
Metadata:
handler_name : VideoHandler
When I try recording a screencast with Quicktime or Screenflow and then converting to .ogv for use on the web, I get this error many times:
$ ffmpeg2theora test.mov
[audioresample # 0x7fa903800ee0] Audio sample format conversion failed
The resulting test.ogv file does not play in VLC. I can use ffmpeg to successfully convert mov to mp4. Are there only certain audio types that ffmpeg2theora supports? ffmpeg2theora version 0.29
More output:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2013-08-26 20:50:37
Duration: 00:00:07.00, start: 0.000000, bitrate: 1458 kb/s
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 90 kb/s
Metadata:
creation_time : 2013-08-26 20:50:37
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1200, 1362 kb/s, 30 fps, 30 tbr, 3k tbn, 6k tbc
Metadata:
creation_time : 2013-08-26 20:50:37
handler_name : Apple Alias Data Handler
brew remove ffmpeg
brew install --with-theora --with-libvorbis ffmpeg
ffmpeg -i test.mov -c:v libtheora -c:a libvorbis -q:v 10 -q:a 10 test.ogv
You may be specifically interested in ffmpeg solution, but the Miro Video Convertor is another free OS X option that works great for converting mov to ogg.
I'm converting .mov files to .mpg files using avconv. The command being run by my php application is as follows:
avconv -y -i '$finalvideo' -target ntsc-dvd -aspect 4:3 '$mpgvideo' > $logs
I'm able to convert small .mov files to .mpg without any problems. However, I'm unable to convert videos that are over ten or fifteen minutes long. The log file is completely empty. When I run the command directly the frame stops somewhere around 34000 no matter which video I pick.
The cpu shows 97% usage on this process, however, nothing is happening.
OS Ubuntu 10~
How can I gather more information about this stalled process?
Here's the frozen output
avconv version 0.7, Copyright (c) 2000-2011 the Libav developers
built on Nov 3 2011 13:39:09 with gcc 4.3.3
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 23.98 (24000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/sites/default/files/compiled_videos/573-stream.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.0.3
Duration: 00:18:53.49, start: 0.000000, bitrate: 1430 kb/s
Stream #0.0(eng): Video: h264 (Main), yuv420p, 854x480, 1387 kb/s, 25.60 fps, 23.98 tbr, 90k tbn, 180k tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 126 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
[buffer # 0x9d88820] w:854 h:480 pixfmt:yuv420p
[scale # 0x9d88b60] w:854 h:480 fmt:yuv420p -> w:720 h:480 fmt:yuv420p flags:0x4
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
Output #0, dvd, to '/var/www/sites/default/files/compiled_videos/573.mpg':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.10.0
Stream #0.0(eng): Video: mpeg2video, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 6000 kb/s, 90k tbn, 29.97 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(eng): Audio: ac3, 48000 Hz, stereo, flt, 448 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
Stream mapping:
Stream #0.0 -> #0.0 (h264 -> mpeg2video)
Stream #0.1 -> #0.1 (aac -> ac3)
Press ctrl-c to stop encoding
[mpeg2video # 0x9d8bf20] rc buffer underflow
Input stream #0.1 frame changed from rate:48000 fmt:s16 ch:2 to rate:48000 fmt:flt ch:2
frame=33910 fps= 91 q=2.0 size= 151922kB time=336.58 bitrate=3697.7kbits/s dup=5475 drop=530
Oh interesting. I used -loglevel debug -debug. I was seeing this information
stream #0:
keyframe=0
duration=0.000
dts=1133.449 pts=1133.533
size=103
*** 1 dup!
stream #0:
keyframe=0
duration=0.000
dts=1133.449 pts=1133.449
size=104
Until I finally received this message
*** drop!
I have posted my bug with libav
http://bugzilla.libav.org/show_bug.cgi?id=67
thanks for your help.
Try running avconv with a higher log level: -loglevel debug.
That should give you more data. Also, try -dump and -debug.
Are you sure it's not because you're hitting a storage cap?
I ran into this recently with ffmpeg while converting some oddly sized video clips to a "standard" 16:9 x264 & AAC streams inside a mp4 container. When that "Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'" message would show up, my ffmpeg process would frequently just hang indefinitely at 100% CPU use.
I finally found that the issue, at least in my case, was that because of the conversions I was doing (transcoding to an intermediary format then to the final, desired output), it was actually the number of audio stream channels that caused the encode process to hang. By telling ffmpeg to convert the audio stream to 2-channel, I was able to fix this issue permanently.
The same solution will probably apply to avconv. In the ffmpeg world (and because I'm stuck with an outdated version), I merely needed to add -ac 2 to my ffmpeg command and everything worked perfectly!
Hope that helps :)