ffmpeg producing empty MP4 files - ffmpeg

I am trying to use ffmpeg to convert MTS files to MP4 files. It seems as though the command is running correctly, but the resulting files end up being empty.
joshua#joshua-VirtualBox:~$ ffmpeg -i /media/sf_2017-04/SD_044/00007.MTS /media/sf_2017-04/SD_04/000007.mp4
ffmpeg version 0.8.17-4:0.8.17-0ubuntu0.12.04.2, Copyright (c) 2000-2014 the Libav developers
built on Apr 1 2016 14:28:02 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
Input #0, mpegts, from '/media/sf_2017-04/SD_044/00007.MTS':
Duration: 00:01:17.07, start: 1.927822, bitrate: 25053 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x1200]: Data: [144][0][0][0] / 0x0090
File '/media/sf_2017-04/SD_04/000007.mp4' already exists. Overwrite ? [y/N] y
[buffer # 0x88772a0] w:1920 h:1080 pixfmt:yuv420p
ffmpeg -i /media/sf_2017-04/SD_044/00007.MTS /media/sf_2017-04/SD_04/000007.mp4
ffmpeg version 0.8.17-4:0.8.17-0ubuntu0.12.04.2, Copyright (c) 2000-2014 the Libav developers
built on Apr 1 2016 14:28:02 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
Input #0, mpegts, from '/media/sf_2017-04/SD_044/00007.MTS':
Duration: 00:01:17.07, start: 1.927822, bitrate: 25053 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x1200]: Data: [144][0][0][0] / 0x0090
File '/media/sf_2017-04/SD_04/000007.mp4' already exists. Overwrite ? [y/N] y
[buffer # 0x88772a0] w:1920 h:1080 pixfmt:yuv420p
encoder 'aac' is experimental and might produce bad results.
Add '-strict experimental' if you want to use it.

In your ffmpeg version, aac codec in ffmpeg is still experimental, ffmpeg automatically select aac for the output codec since you didn't specify with -c:a. But you need to manually enable it.
Like the output information said, add extra parameters -strict -2 or -strict experimental will work.

Related

ffmpeg concat .dv without errors or loss of audio sync

I'm ripping video from a bunch of ancient MiniDV tapes using, after much trial and error, some almost as ancient Mac hardware and iMovie HD 6.0.5. This is working well except that it will only create a contiguous video clip of about 12.6 GB in size. If the total video is larger than that, it creates a second clip that is usually about 500 MB.
I want to join these two clips in the "best" way possible - meaning with ffmpeg throwing as few errors as possible, and the audio / video staying in sync.
I'm currently using the following command line in a bash shell:
for f in *.dv ; do echo file '$f' >> list.txt; done && ffmpeg -f concat -safe 0 -i list.txt -c copy stitched-video.dv && rm list.txt
This seems to be working well, and using the 'eyeball' check, sync seems to be preserved.
However, I do get the following error message when ffmpeg starts in on the second file:
Non-monotonous DTS in output stream 0:1; previous: 107844491, current: 107843736; changing to 107844492. This may result in incorrect timestamps in the output file.
Since I know just enough about ffmpeg to be dangerous, I don't understand the significance of this message.
Can anyone suggest changes to my ffmpeg command that will fix whatever ffmpeg is telling me is going wrong?
I'm going to be working on HD MiniDV tapes next, and, because they suffer from numerous dropouts, my task is going to become more complex, so I'd like to nail this one.
Thanks!
as suggested below ffprobe for the two files
Input #0, dv, from 'file1.dv': Metadata: timecode : 00:00:00;22 Duration: 00:59:54.79, start: 0.000000, bitrate: 28771 kb/s Stream #0:0: Video: dvvideo, yuv411p, 720x480 [SAR 8:9 DAR 4:3], 25000 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Input #0, dv, from 'file2.dv': Metadata: timecode : 00:15:06;19 Duration: 00:02:04.09, start: 0.000000, bitrate: 28771 kb/s Stream #0:0: Video: dvvideo, yuv411p, 720x480 [SAR 8:9 DAR 4:3], 25000 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s

ffmpeg cannot concatenate m4a files with -c copy parameter

While using ffmpeg to concatenate similar m4a files:
ffmpeg -f concat -safe 0 -i <(for f in ./*.m4a; do echo "file '$PWD/$f'"; done) -c copy output.m4a
ffmpeg reports an error:
[ipod # 0x7f8db8014a00] Could not find tag for codec mjpeg in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
The files used are: chapter1.m4a, chapter2.m4a. Their ffprobe have no differences other than the duration. Possible related output is:
Duration: 00:13:16.72, start: 0.000000, bitrate: 48 kb/s
Stream #0:0(eng): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 46 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 100:100 DAR 16:9], 90k tbr, 90k tbn, 90k tbc
I just found out the error was due to the Stream #0, which is the cover art, and covers the actual audio track.
After removing the cover artworks in all files, I was able to concatenate them. And the speed is quite fast : speed=1.92e+03x.

How to process a video to mp4 with ffmpeg for quality and compatibility?

I am beginning to be more serious about video. I am processing my videos with ffmpeg in a fully updated Linux into mp4 to use it in HTML5 directly.
Now, I have old AVI videos that I want to convert to mp4 with ffmpeg for use with HTML5. In particular, I have this one:
http://luis.impa.br/photo/1101_aves_ce/caneleiro-de-chapeu-preto_femea_Quixada-CE-110126-E_05662+7a.avi
(I know, terrible quality... sorry). According to ffprobe:
Duration: 00:01:35.30, start: 0.000000, bitrate: 1284 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (DX50 / 0x30355844), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1144 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
That seems perfect: mpeg4 video and mp3 audio. So I tried:
ffmpeg -i input.avi -acodec copy -vcodec copy output.mp4
It generates a file that plays nicely in mplayer, but not in firefox getting an error:
Video format or MIME type not supported.
Chrome plays the audio, but no video is shown... Now, if I do:
ffmpeg -i input.avi output.mp4
firefox works, but the video is reencoded in another one with half the size (half the bitrate). This is what ffprobe says about the reencoded video:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:01:35.30, start: 0.000000, bitrate: 685 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 548 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
I suppose that I am loosing lots of quality (and time processing the video). So, my questions:
Why are browsers not playing my video with the copy codecs ?
Can I work with ffmpeg in this particular file without reencoding? If yes, how?
If I need to reencode, which are "reasonable" parameters to keep close to the original quality? Would something like
ffmpeg -i input.avi -b:v 1024k -bufsize 1024k output.mp4
suffice for this video? This generates a new video with size closer to the original one.
Thanks!
According to ffprobe and if I see it correctly, you have a DivX (5) video file. Do not use it for web!! ;)
mpeg4 (Simple Profile) (DX50 / 0x30355844)
So I don't see any chance to use this video without reencoding. Not if you wish to support firefox.
Use WebM or h264: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
UPDATE
Good settings for reencode depends on your input (bitrate, resolution, fps, kind of material ...), so there is no standard answer.
But you have to specify a codec or ffmpeg choose one depending on your output file extension (so it can be the wrong one).
You can try this:
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
Presets and tunes can help to find the best choice: https://trac.ffmpeg.org/wiki/Encode/H.264

Increase the bitrate tolerance of ffmpeg for creating screenshots of a movie

I'm getting the error bitrate tolerance too small for bitrate so far no problem. I know that there are several switches to increase that but nothing works.
ffmpeg -y -r 1/30 -b:v 999999k -bt 999999k -maxrate 999999k -i in.flv out%03d.jpg
The source of that commandline is directly from ffmpeg. But that crashes:
ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 2 2012 20:23:29 with gcc 4.7.1 (GCC)
[...]
Input #0, flv, from 'in.flv':
Duration: 00:05:00.13, start: 0.000000, bitrate: 259 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 22050 Hz, mono, s16
[mjpeg # 04356860] bitrate tolerance too small for bitrate
[mjpeg # 04317540] ff_frame_thread_encoder_init failed
Output #0, image2, to 'out%03d.jpg':
Stream #0:0: Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 0.03 tbc
Stream mapping:
Stream #0:0 -> #0:0 (flv -> mjpeg)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Some ideas what I'm doing wrong?

How to use ffmpeg to add a text to avi video?

I am trying to put a simple text on the bottom of video using ffmpeg on Ubuntu 12.04 . I tried this which is suggested in several places:
ffmpeg -i input.avi -vf drawtext="fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf:text='Text to write':fontsize=20:fontcolor=black:x=100:y=100" output.avi
But I get this error each time:
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from 'input.avi':
Duration: 04:09:09.66, start: 0.000000, bitrate: 480 kb/s
Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 320x240 [PAR 1:1 DAR 4:3], 45 tbr, 45 tbn, 45 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 64 kb/s
[buffer # 0x860d5a0] w:320 h:240 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 # 0x8607a00] invalid bit rate
Output #0, avi, to 'output.avi':
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 45 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, flt, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
Appreciate your help.
The documentation shows that you can use other parameters with x or y such as input video height and width and text width and height. To place the text on the bottom one method is y=main_h-text_h. If you want a little padding on the bottom you can use y=main_h-(text_h*2) To center it horizontally use x=(main_w/2-text_w/2).

Resources