FFMPEG OUTPUT
COMMAND
/usr/local/bin/ffmpeg -i '/home/machine/public_html/video_1355531272.m4v' -s '640x480' -sameq -ab '64k' -ar '44100' -f 'flv' -pass '1' -passlogfile '/home/machine/public_html/tmp/1355531273-50cbc4090d696-multipass' -y /home/machine/public_html/tmp/1355531273-50cbc4090d2a9.flv &> /home/machine/public_html/tmp/1355531273-50cbc4090da7c.info
/usr/local/bin/ffmpeg -i '/home/machine/public_html/video_1355531272.m4v' -s '640x480' -sameq -ab '64k' -ar '44100' -f 'flv' -pass '2' -passlogfile '/home/machine/public_html/tmp/1355531273-50cbc4090d696-multipass' -y /home/machine/public_html/tmp/1355531273-50cbc4090d2a9.flv &> /home/machine/public_html/tmp/1355531273-50cbc4090da7c.info
eng): Video: h264, yuv420p, 960x540, 3428 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn, 5994 tbc
Metadata:
creation_time : 2012-12-14 22:50:55
Stream #0.1(eng): Audio: aac, 44100 Hz, stereo, s16, 111 kb/s
Metadata:
creation_time : 2012-12-14 22:50:55
[buffer # 0xdd079d0] w:960 h:540 pixfmt:yuv420p
[scale # 0xdd07da0] w:960 h:540 fmt:yuv420p -> w:640 h:480 fmt:yuv420p flags:0xa0000004
[flv # 0xdd041c0] requested bitrate is too low
Output #0, flv, to '/home/machine/public_html/tmp/1355531273-50cbc4090d2a9.flv':
Stream #0.0(eng): Video: flv, yuv420p, 640x480, q=2-31, pass 2, 200 kb/s, 90k tbn, 29.97 tbc
Metadata:
creation_time : 2012-12-14 22:50:55
Stream #0.1(eng): Audio: adpcm_swf, 44100 Hz, stereo, s16, 64 kb/s
Metadata:
creation_time : 2012-12-14 22:50:55
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
-------------------------------
RESULT
-------------------------------
Execute error. Output for file "/home/machine/public_html/video_1355531272.m4v" was found, but the file contained no data. Please check the available codecs compiled with FFmpeg can support this type of conversion. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().
Remove the -sameq option. It does not mean same quality.
Related
I have a problem and I need help.
I have read each post on the subject, but I have no solution, it turns out that when trying to add chapters to a video they are written, but they erase or overwrite the subtitles, is there a way to add the chapters without overwriting and keeping the information?
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 03:01:21.92, start: 0.000000, bitrate: 937 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 801 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : ISO Media file.
vendor_id : [0][0][0][0]
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file.
vendor_id : [0][0][0][0]
Stream #0:2: Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
handler_name : SubtitleHandler
Please help.
Here is the basic command:ffmpeg -i INPUT -f ffmetadata -i input.chap -map 0:v -map 0:a -map 0:s -map_metadata 1 -map_chapters 1 -c copy OUTPUT
-map 0:v, -map 0:a and -map 0:s to keep the video+audio+subtitles streams of the INPUT file
-map_metadata 1 to include the metadata of the input.chap file to output
-map_chapters 1 to include the chapters of the input.chap file to output
-c copy for stream copy all streams
I'm trying to encode an m2ts (MPEG-2 Transport Stream) file to mp4 (H.264) and get the ssim value.
I did get some SSIM values, but the results were contrary to my expectations.
Are there wrong command options for ffmpeg?
Encoding and SSIM calculation commands
# encode
$ ffmpeg -hide_banner -fflags +discardcorrupt -i input.m2ts \
-c:v libx264 -crf <CRF> -preset:v medium \
-c:a copy -bsf:a aac_adtstoasc \
output_ff_crf-<CRF>.mp4
# calculate ssim
$ ffmpeg -hide_banner -i <A> -i <B> \
-lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim" \
-f null -
The results of the SSIM
(a) A=input.m2ts, B=input.m2ts, ssim=0.973266
(b) A=input.m2ts, B=output_ff_crf-0.mp4, ssim=0.813347
(c) A=input.m2ts, B=output_ff_crf-30.mp4, ssim=0.819897
(d) A=output_ff_crf-0.mp4, B=output_ff_crf-0.mp4, ssim=1.000000
(e) A=output_ff_crf-0.mp4, B=output_ff_crf-30.mp4, ssim=0.972911
(d)(e): These are what I expected.
(a): The files are the same, but ssim≠1.
(b)(c): SSIMs with CRF=0 and CRF=30 have almost the same value, although the image quality is different.
In the case of HandBrakeCLI
To determine if there was a problem with input.m2ts, I ran HandBrakeCLI with almost the same parameters as ffmpeg.
# encode
HandBrakeCLI --verbose --format av_mp4 --encoder x264 --quality <CRF> --x264-preset medium \
--aencoder copy \
--input input.m2ts --output output_hb_crf-<CRF>.mp4
# calculate ssim (same as ffmpeg)
$ ffmpeg -hide_banner -i <A> -i <B> \
-lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim" \
-f null -
(b') A=input.m2ts, B=output_hb_crf-0.mp4, ssim=0.999999
(c') A=input.m2ts, B=output_hb_crf-30.mp4, ssim=0.972886
(d') A=output_hb_crf-0.mp4, B=output_hb_crf-0.mp4, ssim=1.000000
(e') A=output_hb_crf-0.mp4, B=output_hb_crf-30.mp4, ssim=0.972886
It's all as I expected. (although A is not ssim=1.0)
Therefore, I don't see a problem with input.m2ts.
Informations about video files and tools
Results of the ffprobe
input.m2ts
[mpeg2video # 0x5655577c1680] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpegts # 0x5655577bd080] start time for stream 2 is not set in estimate_timings_from_pts
[mpegts # 0x5655577bd080] PES packet size mismatch
Input #0, mpegts, from 'input.m2ts':
Duration: 00:30:02.68, start: 39593.392600, bitrate: 19019 kb/s
Program 211
Stream #0:0[0x140]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x141]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 255 kb/s
Stream #0:2[0x138]: Data: bin_data ([6][0][0][0] / 0x0006)
Unsupported codec with id 100359 for input stream 2
output_ff_crf-0.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output_ff_crf-0.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:30:02.67, start: 0.000000, bitrate: 109301 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 109040 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 252 kb/s (default)
Metadata:
handler_name : SoundHandler
output_hb_crf-0.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output_hb_crf-0.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2020-05-17T06:22:06.000000Z
encoder : HandBrake 1.1.0 2018042400
Duration: 00:30:02.22, start: 0.000000, bitrate: 109661 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 109405 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2020-05-17T06:22:06.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 252 kb/s (default)
Metadata:
creation_time : 2020-05-17T06:22:06.000000Z
handler_name : Stereo
Tools
version
ffmpeg: 3.4.6-0ubuntu0.18.04.1
HandBrakeCLI: 1.1.0
ldd
$ ldd /usr/bin/ffmpeg
...
libx264.so.152 => /usr/lib/x86_64-linux-gnu/libx264.so.152 (0x00007efbf1f33000)
...
$ ldd /usr/bin/HandBrakeCLI
...
libx264.so.152 => /usr/lib/x86_64-linux-gnu/libx264.so.152 (0x00007efbfb38f000)
...
ffmpeg and HandBrakeCLI are using the same libx264.
may i ask help to understand why the png logo appears only on the first video of the concat result?
Thanks!
ffmpeg -f concat -safe 0 -y -i list.txt -i ../logo/logo.png -c:a copy -c:v libx264 -x264opts keyint=$50:min-keyint=$50:no-scenecut -bf 0 -r $25 -b:v 4800k -maxrate 9600k -bufsize 19200k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" -t 370 1080set.mp4
I suspect the 2nd and possibly further inputs have video streams with differing properties, so the filtergraph gets reinitialized, and at that point, since you haven't looped the image, there's no image frame left to overlay.
So, loop the image,
ffmpeg -f concat -safe 0 -y -i list.txt -loop 1 -i ../logo/logo.png -c:a copy -c:v libx264 -x264opts keyint=$50:min-keyint=$50:no-scenecut -bf 0 -r $25 -b:v 4800k -maxrate 9600k -bufsize 19200k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" -t 370 1080set.mp4
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2007-05-09T07:55:25.000000Z
Duration: 00:01:29.22, start: 0.000000, bitrate: 7490 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x816, 7403 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2007-05-09T07:55:25.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 94 kb/s (default)
Metadata:
creation_time : 2007-05-09T07:55:29.000000Z
handler_name : GPAC ISO Audio Handler
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2007-07-17T09:18:37.000000Z
genre : Trailer
artist : Fox
title : The Simpsons Movie
date : 2007
Duration: 00:02:17.25, start: 0.000000, bitrate: 8591 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x800, 8486 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2007-07-17T09:18:37.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 5.1, fltp, 107 kb/s (default)
Metadata:
creation_time : 2007-07-17T09:18:45.000000Z
handler_name : GPAC ISO Audio Handler
Stream #0:2: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 101x150 [SAR 72:72 DAR 101:150], 90k tbr, 90k tbn, 90k tbc (attached pic)
Version
ffmpeg : 4.0.2
openh264: 1.8.0
Problem
I try to trim a .mp4 file which metadata info contains rotate info, but I failed with the error information.
The file stream info :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-10-09T09:40:53.000000Z
location : +39.8983+116.4145/
location-eng : +39.8983+116.4145/
com.android.version: 6.0
Duration: 00:00:10.56, start: 0.000000, bitrate: 8671 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 8563 kb/s, SAR 1:1 DAR 16:9, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 180
creation_time : 2018-10-09T09:40:53.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -180.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2018-10-09T09:40:53.000000Z
handler_name : SoundHandle
ffmpeg cmd
ffmpeg -y -i 1.mp4 -threads 4 -b:v 2000k -vcodec libopenh264 -acodec copy -ss 0 -t 3 -f mp4 -movflags faststart -strict -2 ./output.mp4
result
Error reinitializing filters!
Failed to inject frame into filter network: Out of memory
Error while processing the decoded data for stream #0:0
Then I found this answer: ffmpeg-for-android-out-of-memory, after i added -noautorotate command to my cmd, the video is trimmed successful.
If I use -vcodec copy instead of -vcodec libopenh264, the result also is ok, I wonder if there is a bug when libopenh264 decode with ffmpeg's autorotate function.
I wipe the video's rotate info from metadata with -metadata:s:v:0 command, the newly video can be trimmed successful with the origin cmd :(
The error message is misleading. Due to your usage of --disable-filters you need to manually enable the hflip/vflip filters:
--enable-filter=aresample,crop,hflip,scale,transpose,vflip
Some filters (such as the format filter) will be automatically enabled in this case.
While converting avi video to ogv, there is a color problem in output file.
How can I solve this issue ?
normal colors altered colors
Actually a part of the problem is from the player - so weak question
Command using ffmpeg-3.3.2-1.mga6.tainted :
ffmpeg -i dscn0146.avi -pix_fmt yuv422p -s 640x480 dscn0146_hq.ogv -y
And input metadata:
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'dscn0146.avi':
Metadata:
encoder :
maker : NIKON
model : COOLPIX S3500
creation_time : 2017-07-22 12:09:06
Duration: 00:00:07.33, start: 0.000000, bitrate: 11091 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 10770 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> theora (libtheora))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> vorbis (libvorbis))
Processes normaly, but fires a warning:
[swscaler # 0xd3c3a0] deprecated pixel format used, make sure you did set range correctly
Output metadata:
Output #0, ogv, to 'dscn0146_hq.ogv':
Metadata:
model : COOLPIX S3500
maker : NIKON
encoder : Lavf57.71.100
Stream #0:0: Video: theora (libtheora), yuv422p(progressive), 640x480, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libtheora
model : COOLPIX S3500
maker : NIKON
Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp
Metadata:
encoder : Lavc57.89.100 libvorbis
model : COOLPIX S3500
maker : NIKON
this working code
ffmpeg -i totoa.avi -c:v libtheora -q:v 10 -c:a libvorbis -q:a 5 -s 640x480 -y toto.ogv