FFmpeg: Remux f4v cutted from stream to mp4 - ffmpeg

I have a mp4 file cutted from a H.264/AAC stream with Wowza Media Server.
After the cutting, the file was forced to mp4 format with the following command:
ffmpeg -i wowza_output_file -vcodec copy -acodec copy -f mp4 -y wowza_output_file_copy
From there I renamed it to test_f4v.mp4 and took ffprobe, to take a look at the file:
ffprobe version 0.8, Copyright (c) 2007-2011 the FFmpeg developers
built on Jul 20 2011 13:32:19 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264
libavutil 51. 9. 1 / 51. 9. 1
libavcodec 53. 7. 0 / 53. 7. 0
libavformat 53. 4. 0 / 53. 4. 0
libavdevice 53. 1. 1 / 53. 1. 1
libavfilter 2. 23. 0 / 2. 23. 0
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_f4v.mp4':
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2012-04-23 12:36:06
Duration: 01:00:01.84, start: 0.000000, bitrate: 2004 kb/s
Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 854x480 [PAR 1:1 DAR 427:240], 1903 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
creation_time : 2012-04-23 12:36:06
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 96 kb/s
Metadata:
creation_time : 2012-04-23 12:36:06
Now there is a problem. I need a file, which has the following meta data:
major_brand : mp42
compatible_brands: isom
Is there a way to remux the mp4 file to get the major_brand and compatible_brands to the described values with ffmpeg?

You can set arbitrary metadata using the -metadata flag for FFmpeg.
From the man page:
-metadata[:metadata_specifier] key=value (output,per-metadata)
Set a metadata key/value pair.
An optional metadata_specifier may be given to set metadata on
streams or chapters. See "-map_metadata" documentation for details.
This option overrides metadata set with "-map_metadata". It is also
possible to delete metadata by using an empty value.
For example, for setting the title in the output file:
ffmpeg -i in.avi -metadata title="my title" out.flv
To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:1 language=eng OUTPUT

I don't know much about Wowza formatting, but since you're just copying the actual stream data and only changing the packaging, you could try the HandBrakeCLI for conversion to mp4. By default it sets major_brand to mp42 and compatible_brands to mp42isomavc1. Perhaps close enough?

Related

ffmpeg version 2.6.8 : Stream specifier ':a' in filtergraph description matches no streams

I am not getting why this isn't working.. I have tried to get the video streams with [0:v]/[0:1]/[0:v:0] & the audio streams with [0:a]/[0:0]/[0:0:0].
nothing worked.
Explaining the inputs:
1.1st input stream is a video that can be of varying resolution on which the filter adds a padding on to make it 600:480.
2.2nd input is an overlay png which is already at 5:4 ratio.. just making it 600:480 before it gets overlaid in the filter.
3.3rd & 4th ones are also videos which I don't care if they get stretched.. n they are getting stretched to 600:480.
4.so finally there are 3 streams 1 overlaid video 2 stretched videos which needs to be concatenated.
here's the command :
ffmpeg
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4'
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png'
-i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4'
-i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4'
-filter_complex
"[0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a]"
-map "[v]"
-map "[a]"
-c:v libx264
-shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4
this is the complete error I am getting :
Stream specifier ':a' in filtergraph description [0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a] matches no streams.
also there are these warnings:
[Parsed_setsar_9 # 0x219fba0] num:den syntax is deprecated, please use num/den or named options instead
[Parsed_setsar_11 # 0x21a4840] num:den syntax is deprecated, please use num/den or named options instead
Complete log as requested :
[root#cloud ~]# ffmpeg -i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4' -i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png' -i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4' -i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4' -filter_complex \ "[0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libdc1394 --enable-libfaac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-08-21 02:23:24
Duration: 00:02:17.23, start: 0.000000, bitrate: 417 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 318 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
creation_time : 2017-08-21 02:23:24
handler_name : IsoMedia File Produced by Google, 5-11-2011
Input #1, png_pipe, from '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 600x479, 25 tbr, 25 tbn, 25 tbc
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2018-01-31 22:40:09
Duration: 00:00:04.90, start: 0.103811, bitrate: 846 kb/s
Stream #2:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 1920x1080, 827 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2018-01-31 22:40:10
handler_name : Core Media Video
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2018-01-31 22:40:09
Duration: 00:00:04.90, start: 0.103811, bitrate: 846 kb/s
Stream #3:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 1920x1080, 827 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2018-01-31 22:40:10
handler_name : Core Media Video
[Parsed_setsar_9 # 0x17c8ba0] num:den syntax is deprecated, please use num/den or named options instead
[Parsed_setsar_11 # 0x17cd840] num:den syntax is deprecated, please use num/den or named options instead
Stream specifier ':a' in filtergraph description [0:v]trim=0:138,setpts=PTS-STARTPTS[v0];[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0];[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][2:a][z][a0][x1][3:a]concat=n=3:v=1:a=1[v][a] matches no streams.
Your other inputs don't have audio. A dummy audio has to be supplied.
ffmpeg \
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612.mp4' \
-i '/home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_overlay.png' \
-i '/home/vidinflux/public_html/assets/user/736/video/Lines1.mp4' \
-i '/home/vidinflux/public_html/assets/user/736/video/Lines11.mp4' \
-f lavfi -t 0.1 -i anullsrc \
-filter_complex \
"[0:v]trim=0:138,setpts=PTS-STARTPTS[v0]; \
[0:a]atrim=0:138,asetpts=PTS-STARTPTS[a0]; \
[v0]scale='gte(iw/ih\,600/480)*600+lt(iw/ih\,600/480)*((480*iw)/ih):lte(iw/ih\,600/480)*480+gt(iw/ih\,600/480)*((600*ih)/iw)',pad='600:480:(600-gte(iw/ih\,600/480)*600-lt(iw/ih\,600/480)*((480*iw)/ih))/2:(480-lte(iw/ih\,600/480)*480-gt(iw/ih\,600/480)*((600*ih)/iw))/2:black'[x];[1:v]scale=600:480[y];[x][y]overlay=0:0[z];[2:v]scale=600:480,setsar=1:1[x0];[3:v]scale=600:480,setsar=1:1[x1];[x0][4:a][z][a0][x1][4:a]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -shortest /home/vidinflux/public_html/assets/temp/2018020116464612/2018020116464612_final.mp4

FFmpeg extract N images from a video

I've been searching everywhere to work out how to extract N images from a video using FFmpeg. All the answers involve playing with the rate setting (-r). However, I'm having some fundamental problems with the rate. According to the docs, the following should produce one frame per second.
ffmpeg -i input.mov -f image2 -r 1 preview-%d.jpeg
If input.mov is 7 seconds long, I would expect to get 7 images. However, I get 10. I also tried on a video 119 seconds long, but I got 122 images. I'm getting 3 more images than expected. What am I missing?
For example, with this ~3 second video I get six frames https://www.dropbox.com/s/8eke6q2gz1kgk1f/example.mov?dl=0
benblack$ ffmpeg -i example.mov -f image2 -r 1 preview-%d.jpeg
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-02-11 16:52:01
Duration: 00:00:02.83, start: 0.000000, bitrate: 736 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 638x468 [SAR 1:1 DAR 319:234], 726 kb/s, 59.29 fps, 60 tbr, 6k tbn, 12k tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
[swscaler # 0x7fdb13008c00] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'preview-%d.jpeg':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf55.19.104
Stream #0:0(und): Video: mjpeg, yuvj420p, 638x468 [SAR 1:1 DAR 319:234], q=2-31, 200 kb/s, 90k tbn, 1 tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 6 fps=0.0 q=0.0 Lsize=N/A time=00:00:06.00 bitrate=N/A dup=0 drop=162
video:283kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.007598%
I don't know why -r doesn't produce what I expect. However, I managed to extract N frames by using -vf and -vsync:
ffmpeg -i example.mov -f image2 -vsync vfr -vf "select='not(mod(n,17)')" -vframes 10 preview-%d.jpeg
round(number of frames in video/number of frames wanted) = 168/10 = 17. The number of frames in the video can be found using ffprobe:
ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -i example.mov
The vframes setting is to limit the number of frames, because due to rounding we might sometimes generate one more frame.
Another popular way to extract images from videos is a frame per second.
If you want to extract a portion of images from a video use the -ss option to specify the starting timestamp, and the -t option to specify the encoding duration, eg from 52 seconds in for 1 minute and 5 seconds:
ffmpeg.exe -i simpsonsRockBottom.mp4 -ss 00:00:52 -t 00:01:05 -r 1/1 $filename%03d.jpg
The timestamps need to be in HH:MM:SS.xxx format or in seconds.
If you don't specify the -t option it will go to the end.

Changing portrait videos to landscape aspect with latest ffmpeg release is breaking

I am having an issue scaling videos recorded in portrait with the latest version of ffmpeg (2.1). This worked fine in a previous version, but I need the lastest version to fix a different issue.
I am trying to take any video passed and make it 852 wide by 480 high. It works fine when converting videos that are wider then tall, but when the video is taller then wide it corrupts the video. It actually adds a letter box to the top and bottom, rather then left and right. Also, the meta data shows it as the correct height & width, but its wrong when played in windows.
Here are the parameters I am using.
ffmpeg -i INPUT -s 852x480 -r 30 -aspect 1.775 -b:v 2000000 -vcodec mpeg4 -vf "scale=iw*min(852/iw\,480 /ih):ih*min(852/iw\,480 /ih),pad=852:480 :(852-iw)/2:(480 -ih)/2" -ac 2 -b:a 128k -ar 44100 -y OUTPUT
Console output from ffmpeg -i INPUT -r 30 -b:v 2000000 -vcodec mpeg4 -vf "scale=852:480" -ac 2 -b:a 128k -ar 44100 -y OUTPUT:
C:\Lib>ffmpeg -i "d\ca96cd13-2995-4794-b753-22be3b918659.mov" -r 30 -b:v 2000000 -vcodec mpeg4 -vf "
scale=852:480" -ac 2 -b:a 128k -ar 44100 -y "d\portx.mp4"
ffmpeg version N-58015-g8cdf4e0 Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 10 2013 18:04:45 with gcc 4.8.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32thread
s --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-icon
v --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr -
-enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enab
le-libxavs --enable-libxvid --enable-zlib
libavutil 52. 52.100 / 52. 52.100
libavcodec 55. 41.100 / 55. 41.100
libavformat 55. 21.100 / 55. 21.100
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.102 / 3. 90.102
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd\ca96cd13-2995-4794-b753-22be3b918659.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2013-11-12 15:02:21
model : iPhone 5
model-eng : iPhone 5
encoder : 7.0.2
encoder-eng : 7.0.2
date : 2013-11-12T10:02:21-0500
date-eng : 2013-11-12T10:02:21-0500
make : Apple
make-eng : Apple
Duration: 00:00:15.48, start: 0.000000, bitrate: 780 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 7
05 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 90
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s (default)
Metadata:
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Output #0, mp4, to 'd\portx.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
make-eng : Apple
model : iPhone 5
model-eng : iPhone 5
make : Apple
encoder-eng : 7.0.2
date : 2013-11-12T10:02:21-0500
date-eng : 2013-11-12T10:02:21-0500
encoder : Lavf55.21.100
Stream #0:0(und): Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 852x480, q=2-31, 2000 kb/s, 15360
tbn, 30 tbc (default)
Metadata:
rotate : 90
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128
kb/s (default)
Metadata:
creation_time : 2013-11-12 15:02:21
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Press [q] to stop, [?] for help
frame= 465 fps=417 q=3.8 Lsize= 4118kB time=00:00:15.52 bitrate=2173.3kbits/s
video:3860kB audio:243kB subtitle:0 global headers:0kB muxing overhead 0.348231%
Try this:
ffmpeg -i input -filter:v "scale='w=min(720,trunc((480*33/40*dar)/2+0.5)*2):h=min(480,trunc((704*40/33/dar)/2+0.5)*2)',pad='w=720:h=480:x=(ow-iw)/2:y=(oh-ih)/2',setsar='r=40/33'" -target ntsc-dvd output

ffmpeg - Converting MOV files to MP4 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
The community reviewed whether to reopen this question 12 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have just installed ffmpeg and I am trying to encode all my uploaded videos to .mp4 file. Most of the users currently upload .mov and I want to convert every video to .mp4.
I am running the command as follows:
ffmpeg -i movie.mov -vcodec copy -acodec cop out.mp4
But all I am getting is the following errors
ffmpeg version 0.8.5, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 19 2012 11:38:20 with clang 3.1 (tags/Apple/clang-318.0.61)
configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-hardcoded-tables --enable-shared --enable-pthreads --disable-indevs --cc=clang
libavutil 51. 9. 1 / 51. 9. 1
libavcodec 53. 7. 0 / 53. 7. 0
libavformat 53. 4. 0 / 53. 4. 0
libavdevice 53. 1. 1 / 53. 1. 1
libavfilter 2. 23. 0 / 2. 23. 0
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'movie.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2012-03-28 07:13:20
Duration: 00:00:26.23, start: 0.000000, bitrate: 12974 kb/s
Stream #0.0(eng): Video: mjpeg, yuvj420p, 1280x720 [PAR 72:72 DAR 16:9], 12972 kb/s, 11.67 fps, 600 tbr, 600 tbn, 600 tbc
Metadata:
creation_time : 2012-03-28 07:13:20
File 'out.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2012-03-28 07:13:20
encoder : Lavf53.4.0
Stream #0.0(eng): Video: mjpeg, yuvj420p, 1280x720 [PAR 72:72 DAR 16:9], q=2-31, 12972 kb/s, 600 tbn, 600 tbc
Metadata:
creation_time : 2012-03-28 07:13:20
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop, [?] for help
frame= 121 fps= 0 q=-1.0 size= 16408kB time=00:00:10.08 bitrate=13332.2kbitsframe= 306 fps= 0 q=-1.0 Lsize= 41543kB time=00:00:26.12 bitrate=13025.0kbits/s
video:41538kB audio:0kB global headers:0kB muxing overhead 0.012531%
The command to just stream it to a new container (mp4) needed by some applications like Adobe Premiere Pro without encoding (fast) is:
ffmpeg -i input.mov -qscale 0 output.mp4
Alternative as mentioned in the comments, which re-encodes with best quaility (-qscale 0):
ffmpeg -i input.mov -q:v 0 output.mp4

Detect rotation angle and rotate final video using ffmpeg version 2.8

I used to work on ffmpeg 2.2 until now and was detecting rotation angle of video uploaded from android / iPhone mobiles and rotate the resulting video so that it run perfectly on a correct angle.
But since I have updated the ffmpeg to version 2.8 I am getting this rotation problem. My queries are not rotating the videos as they were earlier.
Here'r the commands I was using:
To check rotation angle:
ffprobe -of json -show_streams {$input} | grep rotate
below is my final command to convert a video to mp4
"ffmpeg -i {$input} -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ".fix_video_orientation($input)."' -threads 0 -ab 64k -s {$resolution} -movflags faststart -metadata:s:v:0 rotate=0 {$output}";
"fix_video_orientation" function is given below. It detect the angle of rotation of the initial video and output optimal option for rotating the final video.
function fix_video_orientation($input){
$return= ", transpose=1 ";
$dd= exec("ffprobe -of json -show_streams {$input} | grep rotate");
if(!empty($dd)){
$dd=explode(":",$dd);
$rotate=str_replace(",","",str_replace('"',"",$dd[1]));
if($rotate=="90")return $return;
else if ($rotate=="180") return ", transpose=2,transpose=2 ";
else if($rotate == "270") return ", transpose=2 ";
}
Currently above script is supporting "flv","avi","mp4","mkv","mpg","wmv","asf","webm","mov","3gp","3gpp" extensions, also the script is supporting the resulting .mp4 file to play on all browsers and devices.
Now the ffprobe command is not returning rotation angle and so a portrait video if uploaded from iphone is showing as landscape on the website.
Output console of ffprobe command:
ffprobe version N-77455-g4707497 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --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. 11.100 / 55. 11.100
libavcodec 57. 20.100 / 57. 20.100
libavformat 57. 20.100 / 57. 20.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 21.101 / 6. 21.101
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/standard/PORTRAIT.m4v':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2016-02-03 05:25:18
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 4S
com.apple.quicktime.software: 9.2.1
com.apple.quicktime.creationdate: 2016-02-03T10:52:11+0530
Duration: 00:00:03.34, start: 0.000000, bitrate: 7910 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 7832 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 50 tbc (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2016-02-03 05:25:18
handler_name : Core Media Data Handler
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3
If latest version of ffmpeg (2.8) is used to auto rotate the video, can you please suggest me what option I need to add or remove from my final command.
Try asking this in superuser.com.
ffmpeg -i in.mp4 -c copy -metadata:s:v:0 rotate=0 -an out.mp4
Source:
https://superuser.com/questions/1092951/how-to-delete-a-single-metadata-item-from-an-mp4-file

Resources