Better way to merge audio and video? (ffmpeg 1.2.1)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Better way to merge audio and video? (ffmpeg 1.2.1)

John Crossman
Is the following the best I can do? My current wait for process to finish
seems too long.

*ffmpeg -i audio.mp2 -i video.mp4 -qscale 0 -shortest -strict experimental
output.mp4
*

Also, should I replace  '-qscale 0'  with  '-q:v 0'?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg 1.2.1)

Lou Logan
On Mon, 22 Jul 2013 14:26:29 -0700
John Crossman <[hidden email]> wrote:

> Is the following the best I can do? My current wait for process to finish
> seems too long.

What are you trying to do?

> *ffmpeg -i audio.mp2 -i video.mp4 -qscale 0 -shortest -strict experimental
> output.mp4
> *
>
> Also, should I replace  '-qscale 0'  with  '-q:v 0'?

You did not include the complete console output. Note that the default
encoder used for mp4 output (libx264 or mpeg4) depends on your ffmpeg
configuration, and libx264 ignores "-qscale", but you did not provide
enough information for me to give you any suggestions.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg 1.2.1)

John Crossman
On Mon, Jul 22, 2013 at 2:38 PM, Lou <[hidden email]> wrote:

> > Is the following the best I can do? My current wait for process to finish
> > seems too long.
>
> What are you trying to do?
>

Merge the audio and video into a single video track (i.e., output.mp4)


> > *ffmpeg -i audio.mp2 -i video.mp4 -qscale 0 -shortest -strict
> experimental
> > output.mp4
> > *
> >
> > Also, should I replace  '-qscale 0'  with  '-q:v 0'?
>
> You did not include the complete console output. Note that the default
> encoder used for mp4 output (libx264 or mpeg4) depends on your ffmpeg
> configuration, and libx264 ignores "-qscale", but you did not provide
> enough information for me to give you any suggestions.
>

*Output is below. *Note: this is a job in progress so you don't get final
summary.* *I can send that once it is done.
*
*
/usr/bin/ffmpeg -i /export/mh_data/.../1013/audio.mp2 -i
/export/mh_data/.../1013/screen.mp4 -qscale 0 -shortest -strict
experimental
/export/mh_data/.../1013/screen_804358ef-3eff-41ef-9f90-fa24144a17ab-work2.mp4

ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat
4.4.6-4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect
--enable-gpl --enable-version3 --enable-postproc --enable-avfilter
--enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth
--enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm
--enable-libmp3lame --enable-libnut --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx
--enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mp3 @ 0x12f5b60] max_analyze_duration 5000000 reached at 5015510
microseconds
[mp3 @ 0x12f5b60] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from
'/export/mh_data/opencast/shared/workspace/collection/1013/audio.mp2':
  Duration: 01:19:52.53, start: 0.000000, bitrate: 192 kb/s
    Stream #0:0: Audio: mp2, 44100 Hz, stereo, s16p, 192 kb/s
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from
'/export/mh_data/opencast/shared/workspace/collection/1013/screen.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomiso2
    creation_time   : 2013-07-22 19:31:00
  Duration: 01:19:59.64, start: 0.000000, bitrate: 1157 kb/s
    Stream #1:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 1151 kb/s, 100 fps, 100
tbr, 1k tbn, 1073741824 tbc
    Metadata:
      creation_time   : 2013-07-22 19:31:00
      handler_name    : VideoHandler
Please use -q:a or -q:v, -qscale is ambiguous
[libx264 @ 0x1307880] using SAR=1/1
[libx264 @ 0x1307880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x1307880] profile High, level 4.2
[libx264 @ 0x1307880] 264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft
2003-2013 - 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=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to
'/export/mh_data/opencast/shared/workspace/collection/1013/screen_804358ef-3eff-41ef-9f90-fa24144a17ab-work2.mp4':
  Metadata:
    encoder         : Lavf54.63.104
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1024x768 [SAR 1:1 DAR 4:3], q=-1--1, 12800 tbn, 100 tbc
    Metadata:
      creation_time   : 2013-07-22 19:31:00
      handler_name    : VideoHandler
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo,
fltp, 128 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (h264 -> libx264)
  Stream #0:0 -> #0:1 (mp2 -> aac)
Press [q] to stop, [?] for help
frame= 6820 fps=120 q=33.0 size=    7924kB time=00:01:07.70 bitrate=
958.7kbits/s
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg1.2.1)

Bouke / VideoToolShed
----- Original Message -----
From: "John Crossman" <[hidden email]>
To: "FFmpeg user questions" <[hidden email]>
Sent: Monday, July 22, 2013 11:49 PM
Subject: Re: [FFmpeg-user] Better way to merge audio and video?
(ffmpeg1.2.1)


> On Mon, Jul 22, 2013 at 2:38 PM, Lou <[hidden email]> wrote:
>
>> > Is the following the best I can do? My current wait for process to
>> > finish
>> > seems too long.
>>
>> What are you trying to do?
>>
>
> Merge the audio and video into a single video track (i.e., output.mp4)

But you are re-encoding the whole shebang.
Try -i audio -i video -vcodec copy -acodec copy outfile

Bouke

VideoToolShed
van Oldenbarneveltstraat 33
6512 AS  NIJMEGEN, the Netherlands
+31 24 3553311


>> > *ffmpeg -i audio.mp2 -i video.mp4 -qscale 0 -shortest -strict
>> experimental
>> > output.mp4
>> > *
>> >
>> > Also, should I replace  '-qscale 0'  with  '-q:v 0'?
>>
>> You did not include the complete console output. Note that the default
>> encoder used for mp4 output (libx264 or mpeg4) depends on your ffmpeg
>> configuration, and libx264 ignores "-qscale", but you did not provide
>> enough information for me to give you any suggestions.
>>
>
> *Output is below. *Note: this is a job in progress so you don't get final
> summary.* *I can send that once it is done.
> *
> *
> /usr/bin/ffmpeg -i /export/mh_data/.../1013/audio.mp2 -i
> /export/mh_data/.../1013/screen.mp4 -qscale 0 -shortest -strict
> experimental
> /export/mh_data/.../1013/screen_804358ef-3eff-41ef-9f90-fa24144a17ab-work2.mp4
>
> ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
>  built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat
> 4.4.6-4)
>  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
> --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect
> --enable-gpl --enable-version3 --enable-postproc --enable-avfilter
> --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth
> --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm
> --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb
> --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
> --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx
> --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g
> -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
>  libavutil      52. 18.100 / 52. 18.100
>  libavcodec     54. 92.100 / 54. 92.100
>  libavformat    54. 63.104 / 54. 63.104
>  libavdevice    54.  3.103 / 54.  3.103
>  libavfilter     3. 42.103 /  3. 42.103
>  libswscale      2.  2.100 /  2.  2.100
>  libswresample   0. 17.102 /  0. 17.102
>  libpostproc    52.  2.100 / 52.  2.100
> [mp3 @ 0x12f5b60] max_analyze_duration 5000000 reached at 5015510
> microseconds
> [mp3 @ 0x12f5b60] Estimating duration from bitrate, this may be inaccurate
> Input #0, mp3, from
> '/export/mh_data/opencast/shared/workspace/collection/1013/audio.mp2':
>  Duration: 01:19:52.53, start: 0.000000, bitrate: 192 kb/s
>    Stream #0:0: Audio: mp2, 44100 Hz, stereo, s16p, 192 kb/s
> Input #1, mov,mp4,m4a,3gp,3g2,mj2, from
> '/export/mh_data/opencast/shared/workspace/collection/1013/screen.mp4':
>  Metadata:
>    major_brand     : mp42
>    minor_version   : 0
>    compatible_brands: mp42mp41isomiso2
>    creation_time   : 2013-07-22 19:31:00
>  Duration: 01:19:59.64, start: 0.000000, bitrate: 1157 kb/s
>    Stream #1:0(eng): Video: h264 (Constrained Baseline) (avc1 /
> 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], 1151 kb/s, 100 fps, 100
> tbr, 1k tbn, 1073741824 tbc
>    Metadata:
>      creation_time   : 2013-07-22 19:31:00
>      handler_name    : VideoHandler
> Please use -q:a or -q:v, -qscale is ambiguous
> [libx264 @ 0x1307880] using SAR=1/1
> [libx264 @ 0x1307880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
> [libx264 @ 0x1307880] profile High, level 4.2
> [libx264 @ 0x1307880] 264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft
> 2003-2013 - 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=25 scenecut=40
> intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60
> qpmin=0
> qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
> Output #0, mp4, to
> '/export/mh_data/opencast/shared/workspace/collection/1013/screen_804358ef-3eff-41ef-9f90-fa24144a17ab-work2.mp4':
>  Metadata:
>    encoder         : Lavf54.63.104
>    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
> 1024x768 [SAR 1:1 DAR 4:3], q=-1--1, 12800 tbn, 100 tbc
>    Metadata:
>      creation_time   : 2013-07-22 19:31:00
>      handler_name    : VideoHandler
>    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo,
> fltp, 128 kb/s
> Stream mapping:
>  Stream #1:0 -> #0:0 (h264 -> libx264)
>  Stream #0:0 -> #0:1 (mp2 -> aac)
> Press [q] to stop, [?] for help
> frame= 6820 fps=120 q=33.0 size=    7924kB time=00:01:07.70 bitrate=
> 958.7kbits/s
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user 

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg1.2.1)

John Crossman
On Mon, Jul 22, 2013 at 3:00 PM, Bouke (VideoToolShed) <
[hidden email]> wrote:

> Merge the audio and video into a single video track (i.e., output.mp4)
>>
>
> But you are re-encoding the whole shebang.
> Try -i audio -i video -vcodec copy -acodec copy outfile
>

Thanks! After one sample run, the output looks good. Much faster.

Per Lou's comment, regardless of my operation I should never need '-qscale'
(or the equivalent '-q:v') if my configuration includes
*--enable-libx264 *(which
it does). Right?

Thanks again.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg1.2.1)

thljcl
This post was updated on .
Personally, I recommend mkvtoolnix to serve your purpose. More specifically, it allows to create, alter, split, join and inspect Matroska files without re-encoding the video/audio. Matroska container allows virtually any number of video/audio/subtitle track of any codec. Some popular media players, such as Media Player Classic Home Cinema, allows you to play variety of video/audio codecs. In your case, it can read mp4 files directly and put the video/audio track into Matroska files. If you must use mp4 container for some reasons, if you can copy the audio/video tracks into mp4 files,
ffmpeg -i "input.mkv" -codec "copy" "output.mp4"
Note that mp4 files only support certain audio/video codecs, such as H.264 or AAC. I would admit that ffmpeg is an excellent encoding tool. I assume that you want to create a file with a video track and audio track. You may recall how you can change languages, subtitles, or video angles in DVD playback; it’s because of the existence of multiple tracks of audio, video, and subtitle in VOB file containers. For more information, go to http://bit.ly/1OBiH , http://bit.ly/14VDQ , and http://bit.ly/2Xyp4
Reply | Threaded
Open this post in threaded view
|

Re: Better way to merge audio and video? (ffmpeg1.2.1)

Lou Logan
In reply to this post by John Crossman
On Mon, Jul 22, 2013, at 02:33 PM, John Crossman wrote:
> On Mon, Jul 22, 2013 at 3:00 PM, Bouke (VideoToolShed) <
> [hidden email]> wrote:
>
> > Merge the audio and video into a single video track (i.e., output.mp4)
> >>
> >
> > But you are re-encoding the whole shebang.
> > Try -i audio -i video -vcodec copy -acodec copy outfile

Or simply:
ffmpeg -i audio -i video -c copy output

See description of "stream copy":
https://ffmpeg.org/ffmpeg.html#Stream-copy

Note that by default ffmpeg will only copy one stream of each type:
https://ffmpeg.org/ffmpeg.html#Stream-selection

You can use the -map option to include any or all streams if the default
behavior is not desired.

mp4 output container may not support all of your input formats, so
consider another container format such as Matroska (.mkv) if this is the
case. Or, of course, you can always re-encode if you need mp4.

> Thanks! After one sample run, the output looks good. Much faster.
>
> Per Lou's comment, regardless of my operation I should never need
> '-qscale'
> (or the equivalent '-q:v') if my configuration includes
> *--enable-libx264 *(which
> it does). Right?

Since your console output indicates that libx264 is the default encoder
for mp4 output then -q:v will be ignored by this encoder resulting in
the default of "-crf 23" (also shown in the console output).
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user