Related
i have a video encoded in 16bits. I cannot use opencv as it does not support 16bits video. So i tried ffmpeg-python. The video is around 1Go and each frame is 1M pixels. So, i would like to extract one frame at a time to process it, otherwise, it won't fit in memory. I mean it can, but i want to limit the amount of RAM used by my process.
I looked at examples here. I guess what is closer than what i want is the following, but instead of filling the numpy array with the whole video, i want to read one frame at a time. Or maybe it is possible to give ffmpeg a callback so that is returns a numpy array with all the frames already processed ?
out, _ = (
ffmpeg
.input('test.16b.raw.avi')
.output('pipe:', format='rawvideo', pix_fmt='gray16le')
.run(capture_stdout=True)
)
video = (
np
.frombuffer(out, np.uint16)
.reshape(-1, height, width, 2)
)
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, avi, from 'test.16b.raw.avi':
Metadata:
encoder : Lavf58.45.100
Duration: 00:00:14.23, start: 0.000000, bitrate: 46453 kb/s
Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), gray16le, 640x400, 46553 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (ffv1 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: rawvideo (Y1[0][16] / 0x10003159), gray16le, 640x400, q=2-31, 122880 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc58.91.100 rawvideo
frame= 427 fps=103 q=-0.0 Lsize= 213500kB time=00:00:14.23 bitrate=122880.0kbits/s speed=3.44x
video:213500kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
You can do this:
def extract_frame(input_vid, frame_num):
out, _ = (
ffmpeg
.input(input_vid)
.filter_('select', 'gte(n,{})'.format(frame_num))
.output('pipe:', format='rawvideo', pix_fmt='gray16le', vframes=1)
.run(capture_stdout=True, capture_stderr=True)
)
return np.frombuffer(out, np.uint16).reshape(-1, height, width, 2)
for i in range($totalFrameNumber):
frame = extract_frame($videoPath,i)
Change $totalFrameNumber and $videoPath.
I'm trying to remove a superfluous audio track from a movie file. Specifically, this movie on archive.org has the original audio as track 2, and what appears to be a slavic (Russian?) voiceover in track 1. I'd like to get rid of the latter.
I found this question that suggested I should do the following:
ffmpeg -i Benjamín\ dúfa.avi -map 0 -map -0:a:0 -c copy Benjamín\ dúfa\ \(aðeins\ íslenskt\ tal\).avi
But this doesn't work: after removing the first audio track, audio and video are not in sync in the resulting file anymore (when played in VLC). Now, I was able to overcome this problem by also reencoding the remaining audio track along the way, using
ffmpeg -i Benjamín\ dúfa.avi -map 0 -map -0:a:0 -c:v copy Benjamín\ dúfa\ \(aðeins\ íslenskt\ tal\).avi
But while this works, I'd like to understand why copying the audio track instead does not. I suppose it's a somewhat philosophical question --- consider it a matter of intellectual curiosity, combined with an aversion to needless lossy re-encoding.
So if anyone can explain this to me, I'd very grateful. Thanks!
EDIT: as per Gyan's request, here's ffmpeg's output for the first command:
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
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-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-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from 'Benjamín dúfa.avi':
Metadata:
encoder : VirtualDubModRus 1.5.10.2 (build 2542/release)
IAS1 : Islenska
Duration: 01:27:37.00, start: 0.000000, bitrate: 1313 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x400 [SAR 1:1 DAR 9:5], 979 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Output #0, avi, to 'b.avi':
Metadata:
IAS1 : Islenska
ISFT : Lavf58.29.100
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x400 [SAR 1:1 DAR 9:5], q=2-31, 979 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[avi # 0000000002bf00c0] 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
frame=131425 fps=7616 q=-1.0 Lsize= 718952kB time=01:27:37.00 bitrate=1120.3kbits/s speed= 305x
video:628523kB audio:82141kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.166227%
And also for the second, for comparison:
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
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-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-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from 'Benjamín dúfa.avi':
Metadata:
encoder : VirtualDubModRus 1.5.10.2 (build 2542/release)
IAS1 : Islenska
Duration: 01:27:37.00, start: 0.000000, bitrate: 1313 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x400 [SAR 1:1 DAR 9:5], 979 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:2 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, avi, to 'b2.avi':
Metadata:
IAS1 : Islenska
ISFT : Lavf58.29.100
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x400 [SAR 1:1 DAR 9:5], q=2-31, 979 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp
Metadata:
encoder : Lavc58.54.100 libmp3lame
[avi # 00000000004b7440] 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
frame=131425 fps=1090 q=-1.0 Lsize= 718952kB time=01:27:37.00 bitrate=1120.3kbits/s speed=43.6x
video:628523kB audio:82141kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.166233%
I am writing code to speed up video using FFMPEG with multiplier. 5X for five times faster video, 0.5X for twice slower video etc.
This code has worked previously in other use case, but it looks like there is something wrong with args array.
var spawn = require('child_process').spawn;
var cmd = 'node_modules\\ffmpeg-binaries\\bin\\ffmpeg.exe';
speedupFilename = tmpdir + vts + 'speedup.mp4';
var args = ['-i', filename, '-filter:v ', '"setpts=PTS/' + multiplier + '"', speedupFilename];
console.log(cmd + ' ' + args.join(' '));
var proc = spawn(cmd, args);
/* code that reads stdout and print it out to console */
This prints out in console:
node_modules\ffmpeg-binaries\bin\ffmpeg.exe -i C:\Users\User\AppData\Local\Temp\1533658543video.mp4 -filter:v "setpts=PTS/0.10" C:\Users\User\AppData\Local\Temp\1533658543speedup.mp4
ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\AppData\Local\Temp\1533658543video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands:
script.js:337 isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 00:00:00.12, start: 0.000000, bitrate: 9398 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 9340 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
[AVFilterGraph # 05c67dc0] No such filter: '"setpts'
Error opening filters!
I have setpts filter in my FFMPEG, I have looked into ffmpeg -filters.
If I run command (first line in output) in console, it works fine.
If I change -filter:v ', '"setpts=PTS/' + multiplier + '"' to -filter:v "setpts=PTS/' + multiplier + '"' in args array (remove ', ' to connect those two array items), then it just says At least one output file must be specified:
ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Trailing options were found on the commandline.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\AppData\Local\Temp\1533659280video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands:
isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 00:00:00.12, start: 0.000000, bitrate: 9398 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 9340 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
At least one output file must be specified
I finally figured out the solution.
In the array item '"pts=PTS/' + multiplier + '"' I had to remove quotation marks. They are useless, because argument is anyways isolated unlike in command line space is not enough.
This is what I'm trying to do:
(1) Read rtmp stream with ffmpeg(python subprocess) and piping to rawvideo
(2) processing rawvideo pipe from (1) to opencv readable image using numpy
(3) process the image from (2) using opencv for whatever application
(4) Display or (Stream)to processed image from (3)
This is the code I've written:
FFMPEG_BIN = 'ffmpeg'
#SOURCE -> rtmp://yourdomain/rtmpappname/streamkey
SOURCE = 'YOUR RTMP INPUT STREAM HERE URL'
#DESTINATION -> rtmp://yourdomain/rtmpappname/streamkey
DESTINATION = 'YOUR RTMP PROCESSED OUTPUT STREAM URL'
#frame width and height of source stream
FRAME_WIDTH = 1280
FRAME_HEIGHT = 720
import subprocess as sp
#read from rtmp source and output to rawvideo pipe
cmd_video_only_in = [ FFMPEG_BIN, '-i', SOURCE, '-f', 'image2pipe', '-pix_fmt', 'bgr24', '-vcodec', 'rawvideo','-']
video_input_stream = sp.Popen(cmd_video_only_in, stdout=sp.PIPE, bufsize=FRAME_WIDTH*FRAME_HEIGHT*3, shell=False)
#(Optional) stream opencv processed frames to DESTINATION url with audio mapped from source, audio-video sync can be achieved by changing
#the float value 2.00 of -itsoffset to what suits you
#cmd_processed_stream_out = [FFMPEG_BIN,'-y','-thread_queue_size', '1024','-f', 'rawvideo', '-pix_fmt', 'bgr24', '-video_size', str(FRAME_WIDTH)+'X'+str(FRAME_HEIGHT),'-i','-','-itsoffset','2.00','-i', SOURCE,'-map','0:v:0','-map','1:a:0','-vcodec','libx264','-pix_fmt','yuv420p','-acodec','copy','-preset','ultrafast','-f','flv',DESTINATION]
#processed_output_stream = sp.Popen(cmd_processed_stream_out, stdin=sp.PIPE, shell=False)
import cv2
import numpy as np
import time
while (True):
raw_image = video_input_stream.stdout.read(FRAME_WIDTH*FRAME_HEIGHT*3)
image = np.fromstring(raw_image, dtype='uint8')
image = image.reshape((FRAME_HEIGHT,FRAME_WIDTH,3))
#Process the image
#any opencv based image processing can be done here eg. object detection, feature extraction, etc.,
#Display output
cv2.imshow('OUTPUT', image)
#(Optional)send the processed image frames (output) to DESITNATION rtmp url
#processed_output_stream.stdin.write(image.tostring())
video_input_stream.stdout.flush()
if cv2.waitKey(25) & 0xFF == ord('q'):
video_input_stream.terminate()
processed_output_stream.stdin.close()
processed_output_stream.terminate()
break
The output frames which i'm trying to Display (using cv2.imshow) or Stream to rtmp destination are scrolling vertically from bottom to top. How do I solve this vertical scrolling issue?
EDIT1: FULL LOG - streaming output to DESTINATION URL:
$python3 processing.py
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
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
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
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
Metadata:
Server NGINX RTMP (github.com/arut/nginx-rtmp-module)
width 1280.00
height 720.00
displayWidth 1280.00
displayHeight 720.00
duration 0.00
framerate 25.00
fps 25.00
videodatarate 0.00
videocodecid 7.00
audiodatarate 0.00
audiocodecid 10.00
Input #0, live_flv, from 'SOURCE URL':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 1280
displayHeight : 720
fps : 25
profile :
level :
Duration: 00:00:00.00, start: 10435.038000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p, 1280x720, 25 fps, 25 tbr, 1k tbn, 2k tbc
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp
Output #0, image2pipe, to 'pipe:':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 1280
displayHeight : 720
fps : 25
profile :
level :
encoder : Lavf56.40.101
Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 552960 kb/s
Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 552960 kb/s, 25 tbr, 25 tbn, 25 tbc
Metadata:
Server NGINX RTMP (github.com/arut/nginx-rtmp-module)
width 1280.00
height 720.00
displayWidth 1280.00
displayHeight 720.00
duration 0.00
framerate 25.00
fps 25.00
videodatarate 0.00
videocodecid 7.00
audiodatarate 0.00
audiocodecid 10.00
Input #1, live_flv, from 'SOURCE URL':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 1280
displayHeight : 720
fps : 25
profile :
level :
Duration: 00:00:00.00, start: 10438.591000, bitrate: N/A
Stream #1:0: Video: h264 (Main), yuv420p, 1280x720, 25 fps, 25 tbr, 1k tbn, 2k tbc
Stream #1:1: Audio: aac (LC), 44100 Hz, stereo, fltp
[libx264 # 0x19c1820] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x19c1820] profile Constrained Baseline, level 3.1
[libx264 # 0x19c1820] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
[flv # 0x19c0880] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, flv, to 'DESINATION URL':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream #0:1: Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, stereo
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #1:1 -> #0:1 (copy)
frame= 3 fps=1.0 q=-0.0 size= 8100kB time=00:00:00.12 bitrate=552960.0kbits/[live_flv # 0x19b1900] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 45 fps=0.0 q=20.0 size= 427kB time=00:00:01.28 bitrate=2730.9kbits/s
frame= 123 fps= 34 q=-0.0 size= 332100kB time=00:00:04.92 bitrate=552960.0kbits/
frame= 58 fps= 57 q=21.0 size= 608kB time=00:00:01.80 bitrate=2766.4kbits/s
frame= 136 fps= 33 q=-0.0 size= 367200kB time=00:00:05.44 bitrate=552960.0kbits/
frame= 70 fps= 46 q=20.0 size= 737kB time=00:00:02.28 bitrate=2648.5kbits/s
frame= 149 fps= 32 q=-0.0 size= 402300kB time=00:00:05.96 bitrate=552960.0kbits/
I have the following code:
var ffmpeg = require('fluent-ffmpeg');
var proc = new ffmpeg({source: media.file.path, nolog: false})
.withVideoCodec('libx264')
.withVideoBitrate(800)
.withAudioCodec('libvo_aacenc')
.withAudioBitrate('128k')
.withAudioChannels(2)
.toFormat('mp4')
.saveToFile(media.targetDir + media.getName() + '.' + '.mp4',
function (retcode, error) {
console.log('file has been converted succesfully');
});
fs.chmodSync(media.targetDir, '755');
This should (hopefully) convert an mov file to an mp4 file. However that is not the case. Instead it goes through the code without printing any error nor other console messages and just continue?
So my question is what have I done wrong?
I know it's not alot to go for but I'll be ready to answer any question you might have!
Here is a picture of the proc variable after the code has been executed:
Output of command
I ran the following command:
ffmpeg -i trim.F4A79C58-1141-412E-A713-2CF893F44055.MOV -c:v libx264 -vb 800k -c:a libfdk_aacenc -ab 128k -ac 2 test.mp4
And got the following output:
ffmpeg version N-76045-g97be5d4 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-libfreetype --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 55. 4.100 / 55. 4.100
libavcodec 57. 6.100 / 57. 6.100
libavformat 57. 4.100 / 57. 4.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 11.100 / 6. 11.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x3d494c0] moov atom not found
trim.F4A79C58-1141-412E-A713-2CF893F44055.MOV: Invalid data found when processing input
Attempted another file
Here is the output for when i attempted another file (the other file might have been broken)
ffmpeg version N-76045-g97be5d4 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-libfreetype --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 55. 4.100 / 55. 4.100
libavcodec 57. 6.100 / 57. 6.100
libavformat 57. 4.100 / 57. 4.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 11.100 / 6. 11.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-11-04 15:28:54
Duration: 00:00:02.21, start: 0.032948, bitrate: 751 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 91 kb/s (default)
Metadata:
creation_time : 2015-11-04 15:28:54
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 272x480, 647 kb/s, 24.04 fps, 24.08 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2015-11-04 15:28:54
handler_name : Core Media Data Handler
encoder : H.264
[libx264 # 0x356d660] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x356d660] profile High, level 2.1
[libx264 # 0x356d660] 264 - core 142 r2491 24e4fed - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=800 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf57.4.100
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 272x480, q=-1--1, 800 kb/s, 24.08 fps, 18496 tbn, 24.08 tbc (default)
Metadata:
creation_time : 2015-11-04 15:28:54
handler_name : Core Media Data Handler
encoder : Lavc57.6.100 libx264
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
Metadata:
creation_time : 2015-11-04 15:28:54
handler_name : Core Media Data Handler
encoder : Lavc57.6.100 libvo_aacenc
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
frame= 54 fps=0.0 q=-1.0 Lsize= 226kB time=00:00:02.30 bitrate= 803.3kbits/s dup=1 drop=0
video:187kB audio:37kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.346419%
[libx264 # 0x356d660] frame I:1 Avg QP:18.97 size: 5651
[libx264 # 0x356d660] frame P:16 Avg QP:16.05 size: 6730
[libx264 # 0x356d660] frame B:37 Avg QP:17.38 size: 2086
[libx264 # 0x356d660] consecutive B-frames: 3.7% 11.1% 11.1% 74.1%
[libx264 # 0x356d660] mb I I16..4: 18.0% 56.5% 25.5%
[libx264 # 0x356d660] mb P I16..4: 3.5% 14.9% 5.9% P16..4: 37.2% 26.1% 10.0% 0.0% 0.0% skip: 2.5%
[libx264 # 0x356d660] mb B I16..4: 0.5% 1.3% 0.5% B16..8: 40.2% 8.6% 1.7% direct:18.9% skip:28.3% L0:47.4% L1:36.9% BI:15.7%
[libx264 # 0x356d660] final ratefactor: 15.06
[libx264 # 0x356d660] 8x8 transform intra:60.0% inter:47.9%
[libx264 # 0x356d660] coded y,uvDC,uvAC intra: 86.0% 88.2% 37.7% inter: 33.7% 48.0% 2.6%
[libx264 # 0x356d660] i16 v,h,dc,p: 27% 10% 44% 19%
[libx264 # 0x356d660] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 14% 36% 4% 4% 6% 5% 5% 5%
[libx264 # 0x356d660] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 16% 22% 5% 7% 8% 5% 5% 3%
[libx264 # 0x356d660] i8c dc,h,v,p: 50% 18% 25% 7%
[libx264 # 0x356d660] Weighted P-Frames: Y:6.2% UV:0.0%
[libx264 # 0x356d660] ref P L0: 66.8% 11.1% 14.9% 6.6% 0.6%
[libx264 # 0x356d660] ref B L0: 92.8% 6.0% 1.1%
[libx264 # 0x356d660] ref B L1: 97.6% 2.4%
[libx264 # 0x356d660] kb/s:679.79