videos usar para convertir convertidor como ffmpeg

ffmpeg - usar - convertidor de videos para linux mint



ffmpeg: combinar/combinar mĂșltiples videos mp4 que no funcionan, la salida solo contiene el primer video (8)

Concat demuxer

El concat demuxer se agregó a ffmpeg 1.1. Si su versión de ffmpeg es antigua, obtenga el binario estático más nuevo desde aquí: http://www.ffmpeg.org/download.html

Instrucciones

Cree un archivo mylist.txt con todos los archivos que desea concatenar en el siguiente formulario (se ignoran las líneas que comienzan con un guión):

# this is a comment file ''/path/to/file1'' file ''/path/to/file2'' file ''/path/to/file3''

Tenga en cuenta que estas pueden ser rutas relativas o absolutas. Entonces puedes codificar tus archivos con:

ffmpeg -f concat -i mylist.txt -c copy output

Es posible generar este archivo de lista con un bash for loop, o usando printf. Cualquiera de los siguientes generaría un archivo de lista que contiene cada * .wav en el directorio de trabajo:

for f in ./*.wav; do echo "file ''$f''" >> mylist.txt; done printf "file ''%s''/n" ./*.wav > mylist.txt

Fuente: http://trac.ffmpeg.org/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files

Aquí está el comando que estoy usando para combinar varios videos:

ffmpeg -i 75_540_38HQ2.mp4 -i 76_70_20.mp4 -i 76_173_80.mp4 -i 81_186_35.mp4 -vcodec copy -acodec copy Mux1.mp4

El Mux1.mp4 resultante no contiene todos los videos. Solo el primer video ( 75_540_38HQ2.mp4 ). El tamaño del archivo de la fuente y el video resultante está debajo (como puede ver, el video resultante es un poco más grande que el primer video):

$ ls -lh -rw-r--r-- 1 dbaker dbaker 42M 2011-03-24 11:59 75_540_38HQ2.mp4 -rw-r--r-- 1 dbaker dbaker 236M 2011-03-24 12:09 76_173_80.mp4 -rw-r--r-- 1 dbaker dbaker 26M 2011-03-24 12:05 76_70_20.mp4 -rw-r--r-- 1 dbaker dbaker 54M 2011-03-24 12:15 81_186_35.mp4 -rw-r--r-- 1 dbaker dbaker 44M 2011-03-24 14:48 Mux1.mp4

Aquí está la salida del comando ffmpeg . Para mí se ve bien, mostrando las múltiples entradas de fuente y la salida única.

FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Mar 21 2011 18:05:32 with gcc 4.4.5 configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 libpostproc 51. 2. 0 / 51. 2. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ''75_540_38HQ2.mp4'': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:29.99, start: 0.000000, bitrate: 11517 kb/s Stream #0.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 11575 kb/s, 29.94 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Input #1, mov,mp4,m4a,3gp,3g2,mj2, from ''76_70_20.mp4'': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:19.98, start: 0.000000, bitrate: 10901 kb/s Stream #1.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10804 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #1.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Input #2, mov,mp4,m4a,3gp,3g2,mj2, from ''76_173_80.mp4'': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:03:09.99, start: 0.000000, bitrate: 10393 kb/s Stream #2.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10321 kb/s, 29.96 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #2.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Seems stream 0 codec frame rate differs from container frame rate: 119.88 (120000/1001) -> 30000.00 (30000/1) Input #3, mov,mp4,m4a,3gp,3g2,mj2, from ''81_186_35.mp4'': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:35.00, start: 0.000000, bitrate: 12700 kb/s Stream #3.0(eng): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 12620 kb/s, 59.91 fps, 30k tbr, 60k tbn, 119.88 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #3.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Output #0, mp4, to ''Mux1.mp4'': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Stream #0.0(eng): Video: libx264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], q=2-31, 11575 kb/s, 30k tbn, 29.97 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Stream mapping: Stream #0.0 -> #0.0 Stream #2.1 -> #0.1 Press [q] to stop encoding frame= 883 fps=632 q=-1.0 Lsize= 44730kB time=29.40 bitrate=12465.1kbits/s video:41678kB audio:2969kB global headers:0kB muxing overhead 0.184548%

¿Estoy haciendo algo deslumbrantemente estúpido aquí?

Los videos fuente vinieron de una cámara de video, y son pequeños fragmentos tomados con ffmpeg -i bigfile.mp4 -ss 20 -t 10 -vcodec copy etc..

¡¡Montones de gracias!! Dave

Editar: no pude resolverlo, así que solo uso la herramienta de interfaz gráfica de usuario devidemux. Parecía agregar el MP4 está bien.

Debe ser un problema con MP4 o solo los que salen de una cámara gopro.


Desde la sección "Ejemplos" de la página man de ffmpeg:

Puede poner muchas secuencias del mismo tipo en la salida:

ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy / -vcodec copy -acodec copy test12.avi -newvideo -newaudio

Además de las primeras transmisiones de audio y video, el archivo de salida resultante test12.avi contendrá el segundo video y el segundo flujo de audio encontrado en la lista de flujos de entrada.

Las opciones "-newvideo", "-newaudio" y "-newsubtitle" deben especificarse inmediatamente después del nombre del archivo de salida al que desea agregarlas.

Si quisiste decir que quieres concatenarlos, las FAQ tienen instrucciones.

No estoy seguro de si esta pregunta / respuesta pertenece a SuperUser .


He estado usando este script bastante exitosamente. Los resultados son perfectos porque está utilizando video en bruto.

http://trac.ffmpeg.org/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files

Asegúrese de editar la cadena EXTRA OPTIONS.

#!/bin/bash ################################################################################ # # Script name: MultiMedia Concat Script (mmcat) # Author: burek ([email protected]) # License: GNU/GPL, see http://www.gnu.org/copyleft/gpl.html # Date: 2012-07-14 # # This script concatenates (joins, merges) several audio/video inputs into one # final output (just like as if all the inputs were played in a playlist, one # after another). # # All input files must have at least one audio and at least one video stream. # If not, you can easily add audio silence, using FFmpeg. Just search the # internet for "ffmpeg add silence". # # The script makes use of FFmpeg tool (www.ffmpeg.org) and is free for use under # the GPL license. The inspiration for this script came from this FAQ item: # http://ffmpeg.org/faq.html#How-can-I-join-video-files_003f # # If you find any bugs, please send me an e-mail so I can fix it. # ################################################################################ # # General syntax: mmcat <input1> <input2> <input3> ... <output> # # For example: mmcat file1.flv file2.flv output.flv # would create "output.flv" out of "file1.flv" and "file2.flv". # ################################################################################ # change this to what you need !!! EXTRA_OPTIONS=''-vcodec libx264 -crf 23 -preset medium -acodec aac -strict experimental -ac 2 -ar 44100 -ab 128k'' ################################################################################ # # NO NEED TO TOUCH ANYTHING AFTER THIS LINE! # ################################################################################ # the version of the script VERSION=1.3 # location of temp folder TMP=/tmp ################################################################################ echo "MultiMedia Concat Script v$VERSION (mmcat) - A script to concatenate multiple multimedia files." echo "Based on FFmpeg - www.ffmpeg.org" echo "Don''t forget to edit this script and change EXTRA_OPTIONS" echo "" ################################################################################ # syntax check (has to have at least 3 params: infile1, infile2, outfile ################################################################################ if [ -z $3 ]; then echo "Syntax: $0 <input1> <input2> <input3> ... <output>" exit 1 fi ################################################################################ # get all the command line parameters, except for the last one, which is output ################################################################################ # $first - first parameter # $last - last parameter (output file) # $inputs - all the inputs, except the first input, because 1st input is # handled separately ################################################################################ first=${@:1:1} last=${@:$#:1} len=$(($#-2)) inputs=${@:2:$len} # remove all previous tmp fifos (if exist) rm -f $TMP/mcs_* ################################################################################ # decode first input differently, because the video header does not have to be # kept for each video input, only the header from the first video is needed ################################################################################ mkfifo $TMP/mcs_a1 $TMP/mcs_v1 ffmpeg -y -i $first -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 $TMP/mcs_a1 2>/dev/null </dev/null & ffmpeg -y -i $first -an -f yuv4mpegpipe -vcodec rawvideo $TMP/mcs_v1 2>/dev/null </dev/null & # if you need to log the output of decoding processes (usually not necessary) # then replace the "2>/dev/null" in 2 lines above with your log file names, like this: #ffmpeg -y -i $first -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 $TMP/mcs_a1 2>$TMP/log.a.1 </dev/null & #ffmpeg -y -i $first -an -f yuv4mpegpipe -vcodec rawvideo $TMP/mcs_v1 2>$TMP/log.v.1 </dev/null & ################################################################################ # decode all the other inputs, remove first line of video (header) with tail # $all_a and $all_v are lists of all a/v fifos, to be used by "cat" later on ################################################################################ all_a=$TMP/mcs_a1 all_v=$TMP/mcs_v1 i=2 for f in $inputs do mkfifo $TMP/mcs_a$i $TMP/mcs_v$i ffmpeg -y -i $f -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 $TMP/mcs_a$i 2>/dev/null </dev/null & { ffmpeg -y -i $f -an -f yuv4mpegpipe -vcodec rawvideo - 2>/dev/null </dev/null | tail -n +2 > $TMP/mcs_v$i ; } & # if you need to log the output of decoding processes (usually not necessary) # then replace the "2>/dev/null" in 2 lines above with your log file names, like this: #ffmpeg -y -i $f -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 $TMP/mcs_a$i 2>$TMP/log.a.$i </dev/null & #{ ffmpeg -y -i $f -an -f yuv4mpegpipe -vcodec rawvideo - 2>$TMP/log.v.$i </dev/null | tail -n +2 > $TMP/mcs_v$i ; } & all_a="$all_a $TMP/mcs_a$i" all_v="$all_v $TMP/mcs_v$i" let i++ done ################################################################################ # concatenate all raw audio/video inputs into one audio/video ################################################################################ mkfifo $TMP/mcs_a_all mkfifo $TMP/mcs_v_all cat $all_a > $TMP/mcs_a_all & cat $all_v > $TMP/mcs_v_all & ################################################################################ # finally, encode the raw concatenated audio/video into something useful ################################################################################ ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i $TMP/mcs_a_all / -f yuv4mpegpipe -vcodec rawvideo -i $TMP/mcs_v_all / $EXTRA_OPTIONS / $last ################################################################################ # remove all fifos ################################################################################ rm -f $TMP/mcs_*


MP4Box funciona sin romper el audio. Hice lo siguiente para obtener buenos resultados:

  1. Descargue la última versión de Deb Linux desde el sitio web de gpac: http://gpac.wp.mines-telecom.fr/downloads/gpac-nightly-builds/

  2. Use la opción -force-cat

Línea de comando de muestra:

MP4Box -force-cat -add in1.mp4 -cat in2.mp4 -cat in3.mp4 ... out.mp4

Algunos comentarios menores:

  1. La forma anterior es importante, ya que la última versión de MP4Box distribuida con Linux Mint 13 tiene fallas y da como resultado un audio dañado.

  2. -force-cat es importante, ya que la etiqueta de formato de video se cambió de AVC a avc3 sin ella.


Olvídate de FFmpeg, utiliza MP4Box, es más fácil y rápido:

mp4box -add video1.mp4 -cat video2.mp4 -cat video3.mp4 output.mp4

Está disponible para Windows, Linux y OS X: http://www.videohelp.com/tools/mp4box

Si está en Windows, puede usar YAMB, que es una GUI para MP4Box que funciona muy bien: http://www.videohelp.com/tools/YAMB

ACTUALIZACIÓN junio de 2016: FFmpeg ha agregado un filtro de concatenación, más información aquí: https://.com/a/11175851/218418


Simple concat funciona para los archivos mp4 y mkv si todos los videos de entrada tienen el mismo códec y usted también desea el video de salida en el mismo códec. trac.ffmpeg.org/wiki/Concatenate
necesitas crear un archivo de texto como

# this is a comment file ''/path/to/file1'' file ''/path/to/file2'' file ''/path/to/file3''

Y luego usa el comando

ffmpeg -f concat -i mylist.txt -c copy output.mp4

He usado el ejemplo de la misma página de referencia, funciona bastante bien. El único problema surge cuando el video no se captura correctamente. Podría presentar problemas de sincronización de audio y video porque simplemente copia la información PTS y DTS de los videos originales al video de destino.
Para obtener una solución de prueba completa, necesita leer paquetes de video por paquete y luego reunir todos los paquetes en un solo video con optimizaciones personalizadas, como descartar paquetes PTS repetitivos y mantener valores de PTS monótonos.


Suponiendo que desea concatenar la película, puede usar el siguiente comando:

ffmpeg -f concat -i inputs.txt -vcodec copy -acodec copy Mux1.mp4

Con el siguiente texto en inputs.txt:

file 75_540_38HQ2.mp4 file 76_70_20.mp4 file 76_173_80.mp4 file 81_186_35.mp4

Nota : algunas distribuciones (como Ubuntu) no tienen ffmpeg en su repositorio y en su lugar definen ffmpeg como un alias de avconv. Esto no funcionará con avconv, por lo que en tal caso debe compilar ffmpeg usted mismo. Puede verificar si tiene el ffmpeg real ejecutando ffmpeg y verificando si la primera línea de salida termina con "los desarrolladores de FFmpeg".


Tienes que convertirlos a un formato MPEG que se pueda concatenar fácilmente. Debajo hay un script que uso y llamo "ffcat" para mis videos de GoPro. Básicamente, ejecuta varios comandos "ffmpeg -i" que producen MPEG concatenado, que se canaliza a un comando ffmpeg que luego los convierte en un archivo H.264 mp4.

También dimensiona los videos a 720p, pero es posible que no quieras eso.

Las "h264options" son banderas que encontré recientemente en Internet en h264.code-shop.com

Espero que esto ayude, Reid

cmd="( " h264options="-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 / -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 / -me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 / -flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 / -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10/ -qmax 51 -qdiff 4" outfile="out-`date +%F-%H%M.%S`.mp4" for i; do cmd="${cmd}ffmpeg -i $i -ab 256000 -vb 10000000 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -f mpeg -; " done cmd="${cmd} ) | ffmpeg -y -i - -threads 8 ${h264options} -vb 10000000 -acodec libfaac -ar 44100 -ab 128k -s 1280x720 ${outfile}" echo "${cmd}" eval ${cmd}