Error adding text on video using ffmpeg - ffmpeg

Am trying to add text on video using ffmpeg. Everything works well if there is no spacing in the words. Here is my code
$text = "Robert Tamunoemi";
$cmd = 'ffmpeg -i '.$videoPath.' -vcodec libx264 -f mp4 -vf drawtext="fontfile=fonts/futura-normal.ttf:text="'.$text.'":fontcolor=black#1.0:fontsize=14:x=00: y=40" -preset medium videos/birds.mp4';
shell_exec($cmd.' 2> log.txt');
Here is the output from ffmpeg log
ffmpeg version N-89674-g57d0c24132 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 56. 7.100 / 56. 7.100
libavcodec 58. 9.100 / 58. 9.100
libavformat 58. 3.100 / 58. 3.100
libavdevice 58. 0.100 / 58. 0.100
libavfilter 7. 8.100 / 7. 8.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videos/pest11.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.3.100
Duration: 00:00:18.20, start: 0.000000, bitrate: 223 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x584 [SAR 1:1 DAR 160:73], 83 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 132 kb/s (default)
Metadata:
handler_name : SoundHandler
Tamunoemi:fontcolor=black#1.0:fontsize=14:x=00: y=40: Protocol not found

Try this:
ffmpeg -i videos/test3.mp4 -vcodec libx264 -f mp4 -vf drawtext='fontfile=fonts/futura-normal.ttf:text="Robert Tamunoemi":fontcolor=black#1.0:fontsize=14:x=00:y=40' -preset medium videos/birds.mp4

Related

FFPROBE get start-time of audio only

I am using this to get the start time of the video and audio:
ffprobe -show_entries stream=start_time -i https://www.website.com/video.mp4
And the response I get is:
ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --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-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://www.website.com/video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:03:14.85, start: 0.000000, bitrate: 4488 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 4418 kb/s, 24 fps, 24 tbr, 90k tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
[STREAM]
start_time=0.000000
[/STREAM]
[STREAM]
start_time=9.892993
[/STREAM]
How can I get only the second stream, which is the audio, and without all the extra info?
So the response would just be:
start_time=9.892993
ffprobe -loglevel quiet -select_streams a -show_entries stream=start_time -of csv=p=0 -i input
Should extract the start_time for audio streams, without extra text.
Selecting specific stream is possible by replacing the -select_streams a by -select_streams N where N is the stream index (starting at 0)

Problem concatenating an mp4 file with an mp4 created by repeating a single image, with the same codec with ffmpeg concat demuxer

I have an mp4 video (of a lecture) containing two streams, video and audio. I wanted an introduction for it (title slide of the presentation that accompanied it), so I made an mp4 out of the intro image via ffmpeg -framerate 30 -i lec01_title.jpg -t 3 -c:v libx264 -pix_fmt yuvj420p -vf "scale=1920:1080" lec01_title.mp4 -f lavfi -i anullsrc -c:a aac. When I try to concat the files using the demuxer, it doesn't work. First, I try to verify that the properties (encoding, etc.) of the two videos are the same.
If I run ffmpeg -i lec01.mp4, I get:
ffmpeg version 5.1.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dcai_lec01.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Wide
encoder : Lavf58.20.100
Duration: 00:45:24.01, start: 0.000000, bitrate: 743 kb/s
Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 606 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
If I run ffmpeg -i lec01_title.mp4, I get:
ffmpeg version 5.1.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dcai_lec01_title.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf59.27.100
Duration: 00:00:03.00, start: 0.000000, bitrate: 150 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt470bg/unknown/unknown, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 12877 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
I tried to verify that the properties of the two videos match via ffprobe -select_streams a:0 -show_entries stream=codec_name,channels -of default=nw=1:nk=1 -v 0 lec01.mp4 and ffprobe -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt -of default=nw=1:nk=1 -v 0 lec01.mp4, and they do. The first command gives me
aac
2
and the second command gives me
h264
1920
1080
yuvj420p
30/1
for both videos.
Now, if I have a file called lec01.txt containing:
file 'lec01_title.mp4'
file 'lec01.mp4'
when I run ffmpeg -f concat -i lec01.txt -c copy output.mp4, the resulting video is of length 04:44:04 (four hours, when my two input videos were 3 seconds and 45:24 minutes respectively), and it only shows the title slide for that entire duration.
Furthermore, when I run this concat command, I get the following message repeated many times: [mp4 # 0x7f82b9013b80] Non-monotonous DTS in output stream 0:1; previous: 133290, current: 133120; changing to 133291. This may result in incorrect timestamps in the output file.
I'm missing something. When I look up this error, it seems to be something related to the decoding time stamps (DTS) or presentation time stamps. Anyone know what I'm doing wrong and how to fix? Thank you for your help!
Edit:
It appears to work if I re-encode via ffmpeg -i lec01_title.mp4 -i lec01.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4, but I'd like to avoid doing this since I have tons of videos I need to do this for.

ffmpeg At least one output file must be specified error

How can i fix this ;( help me....
it works well if i tpye only "'ffmpeg -i ' + video_path + ' -q:v 2 -f image2 ' + frame_path + '\image_%6d.jpg'" on prompt with specific path name.
but it doesn't work in .py (i used code in .py-> os.system('ffmpeg -i ' + video_path + ' -q:v 2 -f image2 ' + frame_path + '\image_%6d.jpg')
'''
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
[mov,mp4,m4a,3gp,3g2,mj2 # 000002629ef05540] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'E:\dataset\Videos\Arrest\Arrest007_x264.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
track : 0
artist :
album :
date : 0
genre :
lyrics :
title :
encoder : Lavf56.36.100
Duration: 00:01:44.84, start: 0.000000, bitrate: 1499 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 1387 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 105 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2: Video: png, rgb24(pc), 58x38 [SAR 304:261 DAR 16:9], 90k tbr, 90k tbn, 90k tbc (attached pic)
At least one output file must be specified
'''
Make use of helpful (& more secure) built-in packages/functions:
from os import path
import subprocess as sp
sp.run(['ffmpeg','-i', video_path,
'-q:v','2','-f','image2',
path.join(frame_path,'image_%6d.jpg')])
I suspect your call went nuts because of unescaped backslashes in the file paths. subprocess.run essentially avoids that nastiness from making a system call.

how to conver a m4v(mpeg) codec raw video to a mp4 file which can be played?

I uses the following command that can extract the mpeg4 raw video file:
ffmpeg -i D:\mp4v-mp4\test\360.mov -vcodec copy -an -f rawvideo D:\mp4v-mp4\test\360CmdSplit_std.dat
but how can I convert the rawvideo file back to a playable mp4 file.
I have tried the follow cmd, but failed:
ffmpeg -y -f m4v -i D:\mp4v-mp4\test\360CmdSplit_std1.dat -vcodec copy D:\mp4v-mp4\test\tmp360.mp4
the first cmd(extract the raw mp4v video) is success,logs:
D:\install\ffmpeg-4.3.1-essentials_build\bin>ffmpeg.exe -i D:\mp4v-mp4\MOV\360(mp4v_aac).mov -vcodec copy -an -f rawvideo D:\mp4v-mp4\MOV\360mov_std.dat
ffmpeg version 4.3.1-essentials_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.0 (Rev1, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\mp4v-mp4\MOV\360(mp4v_aac).mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.17.101
Duration: 00:00:52.08, start: 0.000000, bitrate: 408 kb/s
Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 360x240 [SAR 1:1 DAR 3:2], 277 kb/s, 24 fps, 24 tbr, 12288 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.22.101 mpeg4
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, rawvideo, to 'D:\mp4v-mp4\MOV\360mov_std.dat':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.45.100
Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 360x240 [SAR 1:1 DAR 3:2], q=2-31, 277 kb/s, 24 fps, 24 tbr, 24 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.22.101 mpeg4
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 1250 fps=0.0 q=-1.0 Lsize= 1764kB time=00:00:52.08 bitrate= 277.5kbits/s speed=1.47e+03x
video:1764kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
convert the rawvideo file back to a playable mp4 file,failed:
D:\install\ffmpeg-4.3.1-essentials_build\bin>ffmpeg -y -f m4v -i D:\mp4v-mp4\MOV\360mov_std.dat -vcodec copy D:\mp4v-mp4\MOV\tmp360.mp4
ffmpeg version 4.3.1-essentials_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.0 (Rev1, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
[mpeg4 # 00000214e53d47c0] time_increment_bits 0 is invalid in relation to the current bitstream, this is likely caused by a missing VOL header
[mpeg4 # 00000214e53d47c0] time_increment_bits set to 5 bits, based on bitstream analysis
[mpeg4 # 00000214e53d47c0] time_increment_bits 4 is invalid in relation to the current bitstream, this is likely caused by a missing VOL header
[mpeg4 # 00000214e53d47c0] time_increment_bits set to 5 bits, based on bitstream analysis
[mpeg4 # 00000214e53d47c0] looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag
[m4v # 00000214e53cab40] decoding for stream 0 failed
[m4v # 00000214e53cab40] Could not find codec parameters for stream 0 (Video: mpeg4, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, m4v, from 'D:\mp4v-mp4\MOV\360mov_std.dat':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mpeg4, yuv420p, 25 fps, 25 tbr, 1200k tbn, 25 tbc
[mp4 # 00000214e543a840] dimensions not set
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Last message repeated 1 times

Laravel FFMpeg - FFMpeg cannot edit existing files in-place

After I wanted to upload a video in the queue was returned a failed job.
[2020-09-25 13:24:25][125] Processing: App\Jobs\ConvertVideoForStreaming <br /> [2020-09-25 13:24:26][125] Failed: App\Jobs\ConvertVideoForStreaming
So I've took from the DB failed_jobs table the response and run the following:
C:\ffmpeg\bin\ffmpeg.exe -y -i "C:\wamp64\www\laravel-stream\storage\app/public\WF3UL8fJTSE7BMxa.mp4" -threads 12 -vcodec libx264 -acodec libmp3lame -b:v 500k -refs 6 -coder 1 -sc_threshold 40 -flags +loop -me_range 16 -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -trellis 1 -b:a 128k -vf "[in]scale=720:360 [out]" -pass 1 -passlogfile "C:\Users\wlask\AppData\Local\Temp\ffmpeg-passes5f6dd36a4519fd1fev/pass-5f6dd36a452c9" "C:\wamp64\www\laravel-stream\storage\app/public\WF3UL8fJTSE7BMxa.mp4"
Which returned the following:
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\wamp64\www\laravel-stream\storage\app/public\WF3UL8fJTSE7BMxa.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2015-08-07T09:13:02.000000Z
Duration: 00:00:30.53, start: 0.000000, bitrate: 411 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x270 [SAR 1:1 DAR 16:9], 301 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc (default)
Metadata:
creation_time : 2015-08-07T09:13:02.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 112 kb/s (default)
Metadata:
creation_time : 2015-08-07T09:13:02.000000Z
handler_name : L-SMASH Audio Handler
Output C:\wamp64\www\laravel-stream\storage\app/public\WF3UL8fJTSE7BMxa.mp4 same as Input #0 - exiting
FFmpeg cannot edit existing files in-place.
This was returned after i've run the command from DB failed jobs table return.
How should I solve this?
Ffmpeg cannot edit videos whose input and output are in the same folder.
You have to configure your video output in other folder.
Solved!
In the config.filesystems.php I've added
'videos' => [
'driver' => 'local',
'root' => storage_path('app/converted_videos'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
And after run, and voilá!
php artisan config:clear

Resources