News:

--

Main Menu

How to append 500 mp4 files into single video?

Started by avilon, January 30, 2021, 08:04:32 PM

Previous topic - Next topic

eumagga0x2a

It doesn't make much sense to compare to ancient 2.7.1, couldn't make any of the both latest nightlies crash on my Windows 10 installation upon multiple attempts with different raise() invocations.

butterw

#16
It didn't crash with disabled config3.

Does Tinypy raise get called outside of user scripts ?

butterw

Quote from: butterw on January 31, 2021, 08:37:00 PMIt didn't crash with disabled config3.

Does Tinypy raise get called outside of user scripts ?

Try with "reset_encoder_on_video_load" : true
I think this causes the issue.

eumagga0x2a

Quote from: butterw on January 31, 2021, 08:50:32 PMTry with "reset_encoder_on_video_load" : true

A good idea, I haven't tried this yet, will give it a go as soon as my Windows installation is available again.

eumagga0x2a


dosdan

#20
Simple, repetitive tasks like this may be better suited to FFMPEG.

I've already explained about working at the command-prompt window in https://avidemux.org/smif/index.php/topic,19416.msg90907.html#msg90907

To that, I'll add that you can use the Tab key to autocomplete directory names and filenames e.g. type c and press Tab to find the first match of a name, in the current directory, beginning with c. Type co to find a name beginning with co. If it's not the match you want, press Tab again to bring up the next match. You can also use the Up Arrow to bring back previous command lines for direct reuse or alteration/reuse.  Tab and Up Arrow make the command line a much friendlier place.

For those who would like to try FFMPEG concatenation, but don't have suitable media files, here is a 60s 720p60 MP4 (43MB) which you can d/l to test this. You can test audio syncing using the referee whistle blown at the start or with sound of the "thunks" when the ball is kicked.

60s_testfile.mp4

Here is a batchfile to create numbered copies of this file. It's currently set to makes 10 copies, GRMN0010.mp4 to GRMN0019.mp4. You can easily alter this to make up to 10,000 numbered copies (0,1,9999).  Note: use Ctrl-C if you wish to abort the operation of a batchfile.

Create_numbered_copies.bat
@echo off
rem SETLOCAL EnableDelayedExpansion
for /L %%i IN (10,1,19) do call :docopy %%i
goto :EOF

:docopy
set FN=000%1
set FN=%FN:~-4%
copy 60s_testfile.mp4 GRMN%FN%.mp4

Here is the batchfile to concatenate the MP4s. I suggest you start with 10 x 60s GRMN MP4 files in the current directory.

concat_grmn_mp4s.bat
@echo off
rem setlocal EnableDelayedExpansion
cls

if exist journey_list.txt del journey_list.txt

(for %%G in (GRMN*.mp4) do @echo file '%%G') >> journey_list.txt
rem if exist journey_list.txt start /w journey_list.txt

ffmpeg -f concat -safe 0 -i journey_list.txt -c copy -hide_banner -y output.mp4
rem ffmpeg -f concat -safe 0 -i journey_list.txt -vf "hflip,vflip,format=yuv420p" -metadata:s:v rotate=0  -c:a copy -c:v h264 -b:v 5M -y -hide_banner output.mp4

FFMPEG expects the filenames in the list to be specified in a certain format. Here is the contents of journey_list.txt
file 'GRMN0010.mp4'
file 'GRMN0011.mp4'
file 'GRMN0012.mp4'
file 'GRMN0013.mp4'
file 'GRMN0014.mp4'
file 'GRMN0015.mp4'
file 'GRMN0016.mp4'
file 'GRMN0017.mp4'
file 'GRMN0018.mp4'
file 'GRMN0019.mp4'

Note: I believe the default sort-order under Windows, on both NTFS and FAT32-formatted drives, is alphabetic name-order, so the list should be sorted correctly because the numbers in the filenames have leading zeros. Without leading zeros, GRMN10.mp4 would be listed before GRMN2.mp4.

Since I don't know the options that Garmin uses to produce the AVC video stream in its MP4 files, you should test the audio sync and the cleanliness of the inter-file joining, toward the end of the concatentated output.mp4, say at the 9 min mark, to ensure that this MP4 concat method works OK for you.

Once you are happy with the 10 MP4 concat, you should work out the video bitrate to use for the recompressed 180°-rotated video stream. The -vf indicates that what follows is one or more video filters. When you use video filters in FFMPEG you can't just copy the video stream - you have to recompress it. So during the recompression process, you can compress the video stream a bit harder to reduce its size. For reasons of speeding up testing I suggest you work with just a single MP4 in the current directory during this determination process. You then deactivate the 1st FFMPEG line by remarking it out, i.e. by placing rem at the start of the line, activate the 2nd FFMPEG line by removing its rem, and save the changes. (Ctrl-S in many text editor programs).

The video stream bitrate is currently set to approx. 5Mbits/s. You can use M/m (Megabits/million bits), K/k (e.g. 5000K) and decimals (5.5M)

You mentioned grouping the files by day. As mentioned, you could split up the 1645 MP4s into different directories, one for each day. Or, if you know which sequences belong to which day you can work with them all in the current directory. To do that:

1. unREM the if exist journey_list.txt start /w journey_list.txt line. start /w starts a new program in a new window, here the associated default program for text files, (usually Notepad), and waits for you to finish editing journey_list.txt. (Without the /w option, the batchfile would continue to the next line as soon as this line was executed.)

2. You can now mark and delete a large block of filenames, leaving only the ones you want. Save the changes and close this window.



3. Once this day's output.mp4 has been created, you should rename it to say day1.mp4 so it won't get overwritten when you later go to work on the next day's batch of MP4s.

Dan.

butterw

@dosdan
Avidemux is essentially a ffmpeg gui (with extras) + an editor/preview.

If the user wants to learn to handle the complex ffmpeg command-line (muxers+filters+encoders, batch, error-handling, build options) and the task doesn't require a GUI or preview, yes it's possible and in some cases more effective to use ffmpeg directly.

In this threads case, the single timeline preview of Avidemux can be used to review the footage. You don't get that option with ffmpeg.

eumagga0x2a

Quote from: butterw on January 31, 2021, 08:37:00 PMDoes Tinypy raise get called outside of user scripts ?

It is used in auto-generated scripts, please see avidemux_plugins/ADM_scriptEngines/tinyPy/src/PythonScriptWriter.cpp

Quote from: butterw on January 31, 2021, 08:37:00 PMIt didn't crash with disabled config3.

Have you preserved a copy of that config3 file?

eumagga0x2a

Quote from: butterw on February 01, 2021, 10:10:35 AMAvidemux is essentially a ffmpeg gui (with extras) + an editor/preview.

The main difference is that Avidemux uses its own demuxers, which is responsible for a lot of limitations but also advantages.

butterw

Quote from: butterw on January 31, 2021, 08:04:33 PMadm = Avidemux()
adm.loadVideo("B:/mpc/1.mp4")
raise("panic")
I'm confirming the issue on my end on the Jan18/2021 mingw win64 2.7.7 portable (on Win10).

After a clean start (power-on the PC)   
- doesn't crash with "reset_encoder_on_video_load" : false
- crashes with "reset_encoder_on_video_load" : true
Other settings at default.

I may try this on a clean 2.7.6 VC++ install

I've been getting quite a few of these slow crashes (TinyPy exception, saves crash.py and displays crash messages popups).

eumagga0x2a

Quote from: butterw on February 01, 2021, 11:00:13 AMI'm confirming the issue on my end on the Jan18/2021 mingw win64 2.7.7 portable (on Win10).

The latest one is from Jan 29.

Quote from: butterw on February 01, 2021, 11:00:13 AM- doesn't crash with "reset_encoder_on_video_load" : false
- crashes with "reset_encoder_on_video_load" : true

Please post your defaultSetting.py

butterw

#26
Quote from: eumagga0x2a on February 01, 2021, 11:58:12 AM
Quote from: butterw on February 01, 2021, 11:00:13 AMI'm confirming the issue on my end on the Jan18/2021 mingw win64 2.7.7 portable (on Win10).

The latest one is from Jan 29.

Quote from: butterw on February 01, 2021, 11:00:13 AM- doesn't crash with "reset_encoder_on_video_load" : false
- crashes with "reset_encoder_on_video_load" : true

Please post your defaultSetting.py

tested with clean install of VsWin64 Jan 29 2021.
"reset_encoder_on_video_load" : true
It crashes if defaultSetting.py exists and isn't an empty file.

it crashes with this (I've also tried with the file generated by save settings as defaults):
#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()#crashes will this line commented also.
 

eumagga0x2a

Oh yes, no need for defaultSetting.py, just enter # into the shell and evaluate – tinyPy is completely broken afterwards. I could crash the latest VC++ build this way, failed to crash my own MinGW build, but the latter might have been just by accident. Looks like a bigger problem with script parsing within tinyPy.

Thank you.

eumagga0x2a

Quote from: eumagga0x2a on January 31, 2021, 12:21:25 AMIf it is preferable to append without pre-sorting files into different directories, then the following should do it with some graphical configuration:

# set a few important variables
ext = "mp4"
sep = "\\"
prefix = "GRMN"
# instantiate
adm = Avidemux()
gui = Gui()
# choose input directory
src = gui.dirSelect("Select the source folder")
if src is None:
    return 0
# create a list of all files with extension ext there
list = get_folder_content(src,ext)

(...... and so on .......)

Scratch that. I just realized that get_folder_content() is hardcoded to 200 entries max.

butterw

Quote from: eumagga0x2a on February 01, 2021, 08:38:24 PMScratch that. I just realized that get_folder_content() is hardcoded to 200 entries max.

Is it possible to raise the limit to 500 or 1000files or is this a TinyPy limitation ?