Transcode to opus by Fluent-ffmpeg or ffmpeg from

2019-08-18 08:26发布

My purpose is to transcode a webm file into opus file. It works just fine as the following;

ffmpeg -i input.webm -vn -c:a copy output.opus

But the generated opus file always starts from 4rd or 5th seconds when I play it. It seems like that the first seconds are lost. Any idea why it happens?

>ffmpeg -i x.webm -vn -c:a copy x1.opus
ffmpeg version N-86175-g64ea4d1 Copyright (c) 2000-2017 the FFmpeg 
developers
built with gcc 6.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid -
-enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-
avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls 
--enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-
libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb -
-enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --
enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --
enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab -
-enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-
libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, matroska,webm, from 'x.webm':
  Metadata:
  encoder         : libwebm-0.2.1.0
  creation_time   : 2017-06-19T20:50:21.722000Z
Duration: 00:00:32.33, start: 0.000000, bitrate: 134 kb/s
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #0:1(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 
4:3, 16.67 fps, 16.67 tbr, 1k tbn, 1k tbc (default)
Output #0, opus, to 'x1.opus':
Metadata:
encoder         : Lavf57.72.101
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Metadata:
  encoder         : Lavf57.72.101
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=     114kB time=00:00:32.33 bitrate=  28.8kbits/s speed=3.22e+003x
video:0kB audio:111kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 2.152229%

It is jumping from 0 to 4th second . Please take a look at this screencast. https://www.screenmailer.com/v/52IXnpAarHavwJE

This is the sample video file that I tried to transcode : https://drive.google.com/open?id=0B2sa3oV_Y3X_ZmVWX3MzTlRPSmc

So I guess the transcoding starts right at the point that the voice comes in, why is that?

标签: ffmpeg
1条回答
女痞
2楼-- · 2019-08-18 08:30

With ffprobe you can see that your video stream starts with a presentation timestamp of 0, while the audio stream starts with an offset:

$ ffprobe sample.webm -loglevel error -select_streams v -show_packets -show_entries packet=pts_time -of compact=p=0:nk=1 | head
0.000000
0.064000
0.112000
0.176000
0.240000
0.304000
0.353000
0.417000
0.481000
0.545000

$ ffprobe sample.webm -loglevel error -select_streams a -show_packets -show_entries packet=pts_time -of compact=p=0:nk=1 | head
2.495000
2.515000
2.535000
2.555000
2.575000
2.595000
2.615000
2.635000
2.655000
2.675000

This is why the playhead indicates a different time when you play the audio stream only, as those timestamps are copied to the output .opus file.

I don't know how to make them zero without re-encoding the output (rather than streamcopying), but this should give you a pointer as to what's wrong.

查看更多
登录 后发表回答