FFMPEG cannot encode .MP4 to usable .Y4M RAW video: "Operation not permitted" - ffmpeg

I am running ffmpeg version 4.2.2 on macOS Sierra and I cannot decode a RAW video.
First I create the .Y4M video:
ffmpeg -y -i inputfolder/GH012088.MP4 temp_raw_video.Y4M
Then I try to input it to ffmpeg:
ffmpeg -i temp_raw_video.Y4M
However I get the following error in the terminal: temp_raw_video.Y4M: Operation not permitted
I have checked the permissions for the 'temp_raw_video.Y4M' file and I have both read and write permissions.
I have tried the above with .MOV videos from an iPhone and it works fine.
The problem seems to be with the .MP4 videos I am trying to convert. These videos were taken with a GoPro camera.
What is going on here? Please see the GH012088.MP4 file info below:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb9b6809400] Using non-standard frame rate 29/1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inputfolder/GH012088.MP4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2019-12-28T14:12:04.000000Z
firmware : HD7.01.01.61.00
Duration: 00:00:40.47, start: 0.000000, bitrate: 60267 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 60015 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro AVC
encoder : GoPro AVC encoder
timecode : 14:40:34:06
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro AAC
timecode : 14:40:34:06
Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro TCD
timecode : 14:40:34:06
Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 37 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro MET
Stream #0:4(eng): Data: none (fdsc / 0x63736466), 10 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro SOS
Here is the output log for creating the .Y4M:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fa9da802200] Using non-standard frame rate 29/1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inputfolder/GH012088.MP4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2019-12-28T14:12:04.000000Z
firmware : HD7.01.01.61.00
Duration: 00:00:40.47, start: 0.000000, bitrate: 60267 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 60015 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro AVC
encoder : GoPro AVC encoder
timecode : 14:40:34:06
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro AAC
timecode : 14:40:34:06
Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro TCD
timecode : 14:40:34:06
Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 37 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro MET
Stream #0:4(eng): Data: none (fdsc / 0x63736466), 10 kb/s (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro SOS
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, yuv4mpegpipe, to 'temp_raw_video.Y4M':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
firmware : HD7.01.01.61.00
encoder : Lavf58.29.100
Stream #0:0(eng): Video: wrapped_avframe, yuvj420p, 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
Metadata:
creation_time : 2019-12-28T14:12:04.000000Z
handler_name : GoPro AVC
timecode : 14:40:34:06
encoder : Lavc58.54.100 wrapped_avframe
frame= 43 fps=0.0 q=-0.0 size= 522240kB time=00:00:01.43 bitrate=2981801.3kbiframe= 92 fps= 90 q=-0.0 size= 1117696kB time=00:00:03.06 bitrate=2982723.8kbiframe= 144 fps= 95 q=-0.0 size= 1749504kB time=00:00:04.80 bitrate=2982837.3kbiframe= 190 fps= 94 q=-0.0 size= 2308352kB time=00:00:06.33 bitrate=2982809.6kbiframe= 241 fps= 95 q=-0.0 size= 2928128kB time=00:00:08.04 bitrate=2982978.5kbiframe= 287 fps= 94 q=-0.0 size= 3486976kB time=00:00:09.57 bitrate=2982937.8kbiframe= 336 fps= 95 q=-0.0 size= 4082176kB time=00:00:11.21 bitrate=2982837.3kbiframe= 388 fps= 96 q=-0.0 size= 4713984kB time=00:00:12.94 bitrate=2982864.2kbiframe= 436 fps= 96 q=-0.0 size= 5297152kB time=00:00:14.54 bitrate=frame= 1213 fps= 95 q=-0.0 Lsize=14737957kB time=00:00:40.47 bitrate=2983002.4kbits/s speed=3.19x
video:635kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2321095.250000%

Apparently, the pixel format yuvj420p is throwing a spanner. I will debug it later.
The header is overflowing the limit assumed by the demuxer. Patched in git master.
For now, use,
ffmpeg -y -i inputfolder/GH012088.MP4 -pix_fmt yuv420p temp_raw_video.Y4M

Related

cutting mp4 with codec copy results no audio in browser

I'm editing a video clip with ffmpeg. The original does not play in Firefox browser by itself. It does normally in Chromium. I do something like:
ffmpeg -ss 00:05:10 -i INPUT.mp4 -c copy OUTPUT.mp4
the resulting clip plays in Firefox but there's no audio. This happens in Firefox (82.0.3), but not in Chromium (86.0.4240.75). In chromium the sound is ok.
If audio is reencoded with
ffmpeg -ss 00:05:10 -i INPUT.mp4 -c:v copy -ab 360kb OUTPUT.mp4
resulting clip is playing ok in Firefox.
Could anyone explain what is happening here and is it possible to cut the mp4 without reencoding audio resulting in a clip that plays in Firefox too?
Some data:
ffmpeg version 3.4.8-0ubuntu0.2
ffprobe INPUT.mp4:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'INPUT.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: iso4avc1isom
creation_time : 2020-11-13T18:45:37.000000Z
com.apple.proapps.clipID: INPUT
com.blackmagic-design.camera.dateRecorded: 2020:11:13
com.apple.proapps.cameraName: 0
com.blackmagic-design.camera.uuid: BDB766E79E646CBB82E3EB986EA1EA-0
Duration: 02:01:38.00, start: 0.000000, bitrate: 6047 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 5909 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
encoder : H264/AVC
timecode : 19:45:35:04
Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
timecode : 19:45:35:04
Stream #0:2(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-11-13T18:45:37.000000Z
handler_name : ?Apple Alias Data Handler
timecode : 19:45:35:04
ffprobe OUTPUT.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'OUTPUT.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 01:34:48.02, start: -0.016000, bitrate: 6022 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 5889 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 25600 tbc (default)
Metadata:
handler_name : VideoHandler
timecode : 19:45:35:04
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
handler_name : TimeCodeHandler
timecode : 19:45:35:04
ffprobe the OUTPUT.mp4 that has audio re-encoded and works in Firefox:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 01:34:48.04, start: 0.000000, bitrate: 6160 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 5889 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn, 25600 tbc (default)
Metadata:
handler_name : VideoHandler
timecode : 19:45:35:04
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 265 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
handler_name : TimeCodeHandler
timecode : 19:45:35:04
EDIT:
I'm providing links to original files, but a bit of warning, they are 4-5GB big each:
original recording from blackmagic switcher/capture/recorder (this does not play in firefox at all, but does in Chromium)
cut version made with -codec copy (plays in firefox but no audio. plays in chromium ok)
cut version with re-encoded audio (plays ok in both firefox and chromium)

How can I concatenate multiple MP4 videos with FFMPEG without audio sync issues?

My procedure is as follows:
convert the videos to 1920x1080 at 60 FPS (some videos had only 30 FPS)
save the converted videos in a text file
merging the video by an FFMPEG concat
After the videos are merged, the audio is out of sync with the video.
To convert the videos I use the following command: ffmpeg -i input.mp4 -vf scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1 -r 60 output.mp4
(got it from here: How can I upscale videos with FFmpeg to a fixed resolution?)
My FFMPEG command to concat the videos: ffmpeg -f concat -safe 0 -i videolist.txt -c copy final.mp4
When I concatonate the videos, I sometimes get a lot of these warnings:
[mp4 # 0x55740b62ad40] Non-monotonous DTS in output stream 0:1; previous: 336921, current: 336064; changing to 336922. This may result in incorrect timestamps in the output file.
A question for the FFMPEG professionals, how can I make sure that video and audio are in sync?
UPDATE:
Here are the details of the files being listed in the videolist.txt
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:07.04, start: 0.000000, bitrate: 291 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 187 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 91 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '4t6Brqa4E5BnD6vC5inICusEtPtd3nU88NgbmUJ.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:37.66, start: 0.000000, bitrate: 1608 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1532 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'cut.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:00.65, start: 0.000000, bitrate: 7128 kb/s
Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 7576 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 115 kb/s (default)
Metadata:
handler_name : IsoMedia File Produced by Google, 5-11-2011
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '80SEh7RoTyVPNj3zTZSaixxATvUYXMNyzu15evs.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:07.75, start: 0.000000, bitrate: 1191 kb/s
Stream #3:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1106 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #3:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 70 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #4, mov,mp4,m4a,3gp,3g2,mj2, from 'outro.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:15.17, start: 0.000000, bitrate: 3417 kb/s
Stream #4:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3286 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #4:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
All attributes must be the same, but your audio has varying channel layouts (stereo & mono) and sample rates (48000 & 44100).
Add -ar 48000 -ac 2 to your command:
ffmpeg -i input.mp4 -vf scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1 -r 60 -ar 48000 -ac 2 output.mp4
Alternatively, if you want to avoid any temporary files you can do everything in one command using the concat filter as shown in How to concatenate videos in ffmpeg with different attributes?.

ffmpeg - less frames getting extracted than expected

ffmpeg -i instagram.mp4 -vf fps=29.97 thumb%06d.jpg -hide_banner
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'instagram.mp4': Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104 Duration: 00:00:13.61, start: 0.000000, bitrate: 1163 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 1099 kb/s, 29.97 fps,
29.97 tbr, 11988 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) Press [q] to stop, [?] for help [swscaler # 0x55b2b53cf440] deprecated pixel format used, make sure
you did set range correctly Output #0, image2, to 'thumb%06d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 640x640 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.107.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 frame= 405 fps=231 q=24.8 Lsize=N/A time=00:00:13.51 bitrate=N/A speed=7.72x video:5961kB audio:0kB subtitle:0kB other streams:0kB
global headers:0kB muxing overhead: unknown
The video duration is 13.61 seconds and frame rate is 29.97. So I was expecting 13.61 * 29.97 = 407.8917 i.e. 407 frames. But have got 405 frames. I am new to ffmpeg, need help to correctly get all 407 frames.
I had also tried following command,
ffmpeg -i instagram.mp4 thumb%06d.jpg -hide_banner
but the output was same 405 frames.
Possibly the start 2 frames are missing.
I need to display the frames generated in the base video timeline. And on clicking on the frame I need to exactly seek the video to the frame position using HTML5 currentTime. Since the first 2 frames are not getting available, exact mapping is not getting possible.
Please guide.
have you try to use -vsync vfr or -vsync 0 disables the frame drop/dup behaviour?
#Gyan
Please refer to this question.
https://superuser.com/questions/1374584/why-does-ffmpeg-extracts-a-lot-more-frames-than-the-actual

ffmpeg: concat and encode with one command

I have a script that automates encode and concat a series of input video files.
I'm trying to get encode and concat in a single command.
At the moment it does not work causing immense empty pauses in the final video output.
I would like to get the result with concat demux instead of concat protocol because it is much harder to automate in a script
Do you know if it is possible to archive this result with concat demux?
Thanks a lot!
Massimo
ENCODE / CONCAT 1080p
for f in ./*.mp4; do echo "file '$f'" >> list.txt; done
ffmpeg -f concat -safe 0 -y -i list.txt -i ../logo/logo.png -c:a aac -b:a 384k -ar 48000 -ac 2 -af aresample=async=1000 -c:v libx264 -x264opts keyint=50:min-keyint=50:no-scenecut -bf 0 -r 25 -b:v 4800k -maxrate 4800k -bufsize 3000k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" ../buffer/1080set.mp4
It seems to add long pause at low frame-rate:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb03f05e600] Auto-inserting h264_mp4toannexb bitstream filter
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:52.56 bitrate=1348.0kbits
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:56.57 bitrate=1343.3kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:00.65 bitrate=1338.5kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:02.29 bitrate=1336.5kbits/
More than 1000 frames duplicated
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2016-02-27T22:25:49.000000Z
encoder : HandBrake 0.10.5 2016021100
Duration: 00:06:29.87, start: 0.000000, bitrate: 3447 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 768x432, 3282 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2016-02-27T22:25:49.000000Z
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
Metadata:
creation_time : 2016-02-27T22:25:49.000000Z
handler_name : Stereo
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
creation_time : 2016-02-27T18:52:37.000000Z
Duration: 00:07:16.93, start: 0.000000, bitrate: 1184 kb/s
Stream #1:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 991 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2016-02-27T18:52:37.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2016-02-27T18:52:37.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-06-27T17:58:17.000000Z
Duration: 00:05:05.05, start: 0.000000, bitrate: 2622 kb/s
Stream #2:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2301 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-27T17:58:17.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2017-06-27T17:58:17.000000Z
handler_name : Alias Data Handler
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '4.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-06-27T17:53:32.000000Z
Duration: 00:06:47.36, start: 0.000000, bitrate: 3144 kb/s
Stream #3:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2819 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-27T17:53:32.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2017-06-27T17:53:32.000000Z
handler_name : Alias Data Handler
concat demxuer
The concat demuxer needs all inputs to have the same formats, number of streams, type of streams, order of streams (or use exact_stream_id), timebase, frame rate, audio sample rate, audio channel layout, and it is also recommended to have the same width and height.
In your case the timebase (tbn) of the first input is different than the rest. You can pre-process this input to conform it to the others:
ffmpeg -i 1.mp4 -c copy -video_track_timescale 25k 1_reset.mp4
Then run your command using the concat demuxer.
concat filter
Because you're re-encoding anyway it may be easier for you to use the concat filter. This allows you to conform each input using various filters then concate all in one command. There are several examples of such use on this site.

Speeding up video to image conversion

I use
call(['avconv', '-i', 'video.mp4', '-vsync', '1','-r', '1','-an','-y','%5d.jpg'])
in Python. It works, but it goes through the videofile in realtime. How to speed this up, so getting 60 pictures all in all, each second of the video file does not take 1 minute but less.
The following Python code extracts 60 seconds worth of frames as fast as possible, and outputs them as JPEG files in the current directory.
source
from subprocess import call
call([
'avconv', '-i', 'video.mp4',
'-vsync', '1',
'-r', '1',
'-an', '-y',
'-t', '60', # 60 seconds = 60 pictures
'%5d.jpg',
])
output
avconv version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
built on Nov 9 2013 19:09:46 with gcc 4.8.1
[mov,mp4,m4a,3gp,3g2,mj2 # 0x14bbe00] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf53.21.1
Duration: 01:59:16.23, start: 0.000000, bitrate: 1153 kb/s
Stream #0.0(und): Video: mpeg4 (Advanced Simple Profile), yuv420p, 480x368 [PAR 1:1 DAR 30:23], 1016 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 23.98 tbc
Stream #0.1(und): Audio: aac, 48000 Hz, mono, s16, 63 kb/s
Stream #0.2(und): Audio: aac, 48000 Hz, mono, s16, 64 kb/s
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer # 0x1670a20] w:480 h:368 pixfmt:yuv420p
[avsink # 0x147f6a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale # 0x14bf520] w:480 h:368 fmt:yuv420p -> w:480 h:368 fmt:yuvj420p flags:0x4
Output #0, image2, to '%5d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf53.21.1
Stream #0.0(und): Video: mjpeg, yuvj420p, 480x368 [PAR 1:1 DAR 30:23], q=2-31, 200 kb/s, 90k tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> mjpeg)
Press ctrl-c to stop encoding
frame= 62 fps= 37 q=11.2 Lsize= -0kB time=62.00 bitrate= -0.0kbits/s dup=0 drop=1375
video:1784kB audio:0kB global headers:0kB muxing overhead -100.001204%

Resources