Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I have this recorded video file transcoded by avidemux. For some reason the audio turned out to be crap. Therefore, I used ffmpeg to generate the audio manually from the original source:

G:\My Downloads\converting>ffmpeg -i "20130912 1313 - Sky Cinema HD - Liebe.ts"
-map 0:2 -ss 0:2:16.220 Liebe.m4a
ffmpeg version N-57961-gec8e68c Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  7 2013 18:01:40 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 52.100 / 52. 52.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.102 /  3. 90.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] non-existing PPS referenced
[h264 @ 03d78060] non-existing PPS 0 referenced
[h264 @ 03d78060] decode_slice_header error
[h264 @ 03d78060] no frame!
[h264 @ 03d78060] mmco: unref short failure
    Last message repeated 3 times
[mpegts @ 03d8d360] PES packet size mismatch
    Last message repeated 2 times
Input #0, mpegts, from '20130912 1313 - Sky Cinema HD - Liebe.ts':
  Duration: 02:21:58.64, start: 87280.793944, bitrate: 6588 kb/s
  Program 118
  Program 129
  Program 130
  Program 131
    Stream #0:0[0x20](deu): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:1[0x4ff]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv,
 bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x503](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stere
o, fltp, 384 kb/s (clean effects)
    Stream #0:3[0x504](eng): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stere
o, fltp, 384 kb/s (clean effects)
Output #0, ipod, to 'Liebe.m4a':
  Metadata:
    encoder         : Lavf55.21.100
    Stream #0:0(deu): Audio: aac (libvo_aacenc) (mp4a / 0x6134706D), 48000 Hz, s
tereo, s16, 128 kb/s (clean effects)
Stream mapping:
  Stream #0:2 -> #0:0 (ac3 -> libvo_aacenc)
Press [q] to stop, [?] for help
Input stream #0:2 frame changed from rate:48000 fmt:fltp ch:2 chl:stereo to rate
:48000 fmt:fltp ch:6 chl:5.1(side)
Input stream #0:2 frame changed from rate:48000 fmt:fltp ch:6 chl:5.1(side) to r
ate:48000 fmt:fltp ch:2 chl:stereo
Input stream #0:2 frame changed from rate:48000 fmt:fltp ch:2 chl:stereo to rate
:48000 fmt:fltp ch:6 chl:5.1(side)
[mpegts @ 03d8d360] PES packet size mismatch8.0kbits/s
[ac3 @ 03da9de0] incomplete frame
size=  132498kB time=02:19:41.47 bitrate= 129.5kbits/s
video:0kB audio:130961kB subtitle:0 global headers:0kB muxing overhead 1.173612%

[libvo_aacenc @ 0039fae0] 1 frames left in the queue on closing

G:\My Downloads\converting>

I have no idea what it means regarding those channel setups in the output file. Anyway, now I have a video file with nice video and bad audio and above audio file with nice audio.

Now I want to mux these two together:

G:\My Downloads\converting>ffmpeg -i V:\et9200\Liebe.mp4 -i Liebe.m4a -shortest
-map 0:0 -map 1:0 -c copy "Liebe neu.mp4"
ffmpeg version N-57961-gec8e68c Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  7 2013 18:01:40 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 52.100 / 52. 52.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.102 /  3. 90.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'V:\et9200\Liebe.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.63.104
  Duration: 02:02:10.76, start: 0.160000, bitrate: 935 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x690
[SAR 1:1 DAR 128:69], 876 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(deu): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 50
 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'Liebe.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    encoder         : Lavf55.0.100
  Duration: 02:19:41.49, start: 0.018667, bitrate: 129 kb/s
    Stream #1:0(deu): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 12
8 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
File 'Liebe neu.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'Liebe neu.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.21.100
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x690 [S
AR 1:1 DAR 128:69], q=2-31, 876 kb/s, 25 fps, 25k tbn, 25k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(deu): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 128
 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  194 fps=0.0 q=-1.0 size=    3545kB time=00:00:47.27 bitrate= 614.4kbits/
frame= 2286 fps=2280 q=-1.0 size=    7183kB time=00:01:52.61 bitrate= 522.5kbits
frame= 2849 fps=1893 q=-1.0 size=   10467kB time=00:03:16.33 bitrate= 436.7kbits
frame= 3302 fps=1647 q=-1.0 size=   13966kB time=00:04:38.48 bitrate= 410.8kbits
frame= 4006 fps=1596 q=-1.0 size=   17392kB time=00:06:10.66 bitrate= 384.4kbits
frame= 4344 fps=1441 q=-1.0 size=   21651kB time=00:07:42.82 bitrate= 383.2kbits
frame= 4724 fps=1344 q=-1.0 size=   25845kB time=00:09:02.69 bitrate= 390.1kbits
frame= 5162 fps=1286 q=-1.0 size=   29610kB time=00:10:59.43 bitrate= 367.8kbits
frame= 5738 fps=1271 q=-1.0 size=   32903kB time=00:12:33.83 bitrate= 357.6kbits
frame= 6314 fps=1258 q=-1.0 size=   36053kB time=00:14:28.30 bitrate= 340.1kbits
frame= 6960 fps=1261 q=-1.0 size=   38543kB time=00:15:56.56 bitrate= 330.1kbits
frame= 7416 fps=1232 q=-1.0 size=   42456kB time=00:17:06.34 bitrate= 338.9kbits
frame= 7958 fps=1221 q=-1.0 size=   46004kB time=00:18:36.13 bitrate= 337.7kbits
frame= 8558 fps=1218 q=-1.0 size=   48623kB time=00:20:18.51 bitrate= 326.9kbits
frame= 9129 fps=1213 q=-1.0 size=   50806kB time=00:22:07.08 bitrate= 313.6kbits
frame= 9795 fps=1219 q=-1.0 size=   52689kB time=00:24:07.91 bitrate= 298.1kbits
frame=10566 fps=1238 q=-1.0 size=   54654kB time=00:26:06.67 bitrate= 285.8kbits
frame=11528 fps=1276 q=-1.0 size=   56509kB time=00:27:51.14 bitrate= 277.0kbits
frame=11984 fps=1256 q=-1.0 size=   59588kB time=00:31:07.75 bitrate= 261.4kbits
frame=12544 fps=1249 q=-1.0 size=   62894kB time=00:33:08.56 bitrate= 259.1kbits
frame=13089 fps=1242 q=-1.0 size=   66155kB time=00:35:00.13 bitrate= 258.1kbits
frame=13678 fps=1239 q=-1.0 size=   69123kB time=00:37:06.17 bitrate= 254.4kbits
frame=14217 fps=1231 q=-1.0 size=   72360kB time=00:38:40.38 bitrate= 255.5kbits
frame=14792 fps=1228 q=-1.0 size=   75309kB time=00:40:08.44 bitrate= 256.2kbits
frame=15371 fps=1225 q=-1.0 size=   78566kB time=00:41:32.39 bitrate= 258.2kbits
frame=15863 fps=1215 q=-1.0 size=   81622kB time=00:46:06.80 bitrate= 241.7kbits
frame=16406 fps=1210 q=-1.0 size=   85172kB time=00:47:51.10 bitrate= 243.0kbits
frame=16967 fps=1206 q=-1.0 size=   87951kB time=00:49:50.03 bitrate= 241.0kbits
frame=17428 fps=1197 q=-1.0 size=   91644kB time=00:51:22.21 bitrate= 243.6kbits
frame=17980 fps=1193 q=-1.0 size=   95013kB time=00:52:56.42 bitrate= 245.0kbits
frame=18594 fps=1195 q=-1.0 size=   98032kB time=00:54:22.46 bitrate= 246.2kbits
frame=19160 fps=1193 q=-1.0 size=  100684kB time=00:56:25.32 bitrate= 243.6kbits
frame=19672 fps=1187 q=-1.0 size=  103702kB time=00:58:08.55 bitrate= 243.5kbits
frame=20180 fps=1182 q=-1.0 size=  106947kB time=01:00:16.91 bitrate= 242.2kbits
frame=20672 fps=1177 q=-1.0 size=  109839kB time=01:01:55.05 bitrate= 242.2kbits
frame=21227 fps=1175 q=-1.0 size=  113118kB time=01:03:19.01 bitrate= 243.9kbits
frame=21744 fps=1171 q=-1.0 size=  116339kB time=01:05:03.46 bitrate= 244.2kbits
frame=22276 fps=1168 q=-1.0 size=  119746kB time=01:06:37.67 bitrate= 245.4kbits
frame=23006 fps=1175 q=-1.0 size=  122202kB time=01:08:03.69 bitrate= 245.1kbits
frame=23714 fps=1181 q=-1.0 size=  124414kB time=01:09:07.34 bitrate= 245.7kbits
frame=24398 fps=1186 q=-1.0 size=  127110kB time=01:10:35.24 bitrate= 245.9kbits
frame=25050 fps=1189 q=-1.0 size=  129441kB time=01:12:16.46 bitrate= 244.5kbits
frame=25698 fps=1191 q=-1.0 size=  131917kB time=01:13:53.87 bitrate= 243.7kbits
frame=26356 fps=1194 q=-1.0 size=  134314kB time=01:15:42.44 bitrate= 242.2kbits
frame=26946 fps=1193 q=-1.0 size=  136646kB time=01:17:55.56 bitrate= 239.4kbits
frame=27620 fps=1196 q=-1.0 size=  139091kB time=01:19:42.05 bitrate= 238.3kbits
frame=28261 fps=1198 q=-1.0 size=  141598kB time=01:21:44.93 bitrate= 236.5kbits
frame=28872 fps=1198 q=-1.0 size=  144161kB time=01:23:23.24 bitrate= 236.0kbits
frame=29493 fps=1199 q=-1.0 size=  146493kB time=01:25:36.36 bitrate= 233.6kbits
frame=30102 fps=1199 q=-1.0 size=  148991kB time=01:27:31.05 bitrate= 232.4kbits
frame=30696 fps=1199 q=-1.0 size=  151992kB time=01:29:27.80 bitrate= 232.0kbits
frame=31148 fps=1193 q=-1.0 size=  155663kB time=01:30:53.18 bitrate= 233.8kbits
frame=31694 fps=1191 q=-1.0 size=  158824kB time=01:32:11.62 bitrate= 235.2kbits
frame=32310 fps=1192 q=-1.0 size=  161545kB time=01:33:45.83 bitrate= 235.2kbits
frame=32834 fps=1189 q=-1.0 size=  163289kB time=01:35:30.30 bitrate= 233.4kbits
frame=33418 fps=1189 q=-1.0 size=  165524kB time=01:37:20.85 bitrate= 232.2kbits
frame=34024 fps=1189 q=-1.0 size=  168343kB time=01:39:27.85 bitrate= 231.1kbits
frame=34527 fps=1186 q=-1.0 size=  171751kB time=01:40:51.79 bitrate= 232.5kbits
frame=35080 fps=1185 q=-1.0 size=  174862kB time=01:43:33.58 bitrate= 230.5kbits
frame=35683 fps=1185 q=-1.0 size=  177750kB time=01:45:22.15 bitrate= 230.3kbits
frame=36331 fps=1187 q=-1.0 size=  180709kB time=01:47:18.89 bitrate= 229.9kbits
frame=36942 fps=1187 q=-1.0 size=  183323kB time=01:49:03.33 bitrate= 229.5kbits
frame=37562 fps=1188 q=-1.0 size=  185480kB time=01:51:24.67 bitrate= 227.3kbits
frame=38162 fps=1188 q=-1.0 size=  188238kB time=01:53:05.00 bitrate= 227.3kbits
frame=38802 fps=1190 q=-1.0 size=  191043kB time=01:55:11.97 bitrate= 226.4kbits
frame=39450 fps=1191 q=-1.0 size=  193407kB time=01:56:52.33 bitrate= 225.9kbits
frame=40142 fps=1194 q=-1.0 size=  195984kB time=01:59:07.49 bitrate= 224.6kbits
frame=40823 fps=1196 q=-1.0 size=  198363kB time=02:00:54.01 bitrate= 224.0kbits
frame=41458 fps=1197 q=-1.0 size=  200492kB time=02:03:03.01 bitrate= 222.5kbits
frame=42075 fps=1198 q=-1.0 size=  202608kB time=02:04:39.46 bitrate= 221.9kbits
frame=42750 fps=1200 q=-1.0 size=  205037kB time=02:06:29.86 bitrate= 221.3kbits
frame=43306 fps=1199 q=-1.0 size=  207993kB time=02:08:02.02 bitrate= 221.8kbits
frame=43899 fps=1198 q=-1.0 size=  211349kB time=02:09:56.74 bitrate= 222.1kbits
frame=44505 fps=1198 q=-1.0 size=  213649kB time=02:11:41.06 bitrate= 221.5kbits
frame=45063 fps=1197 q=-1.0 size=  216592kB time=02:13:25.64 bitrate= 221.6kbits
frame=45583 fps=1195 q=-1.0 size=  219505kB time=02:15:03.92 bitrate= 221.9kbits
frame=46350 fps=1200 q=-1.0 size=  222467kB time=02:16:40.35 bitrate= 222.2kbits
frame=47310 fps=1209 q=-1.0 size=  224615kB time=02:18:20.53 bitrate= 221.7kbits
frame=47930 fps=1209 q=-1.0 size=  227902kB time=02:19:40.29 bitrate= 222.8kbits
frame=47949 fps=1138 q=-1.0 Lsize=  331635kB time=02:19:41.49 bitrate= 324.1kbit
s/s
video:198060kB audio:130961kB subtitle:0 global headers:0kB muxing overhead 0.79
4403%

As you can see from the bitrate on the right side something goes wrong. Also note that -shortest didn't do anything.

In VLC the video stops having video at 32 minutes, but the audio continues until 2:19:41. Here's what ffmpeg has to say about what it has done:

G:\My Downloads\converting>ffmpeg -i "Liebe neu.mp4"
ffmpeg version N-57961-gec8e68c Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov  7 2013 18:01:40 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 52.100 / 52. 52.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.102 /  3. 90.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Liebe neu.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.21.100
  Duration: 02:19:41.51, start: 0.000000, bitrate: 324 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x690
[SAR 1:1 DAR 128:69], 845 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(deu): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 12
7 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
At least one output file must be specified

G:\My Downloads\converting>

Note how it claims bitrate: 324 kb/s while the video is still listed with 845 kb/s.

I had a version from March running and updated to the latest and both are doing it wrong.

Obvious question: what am I doing wrong here? In case it's a timestamp/sync issue: how do I fix that?

share|improve this question
    
When you are demuxing audio you are already getting errors. The error is [h264 @ 03d78060] non-existing PPS 0 referenced; [h264 @ 03d78060] decode_slice_header error; [h264 @ 03d78060] no frame! See this discussion. –  Rajib Nov 11 '13 at 13:10
    
Why are you starting at 2:16.220 during demxing? (-ss 0:2:16.220)? –  Rajib Nov 11 '13 at 13:21
    
@Rajib The video is a direct recording from my satellite receiver, which is probably why there don't seem to be any key frames at the beginning and why I can't do anything about it. The actual content starts 2:16 into the video after some commercials, which is why I don't need the stuff at the beginning. –  sjngm Nov 11 '13 at 18:59

1 Answer 1

up vote 1 down vote accepted

Seriously, I don't know why this solves it, but then again I'm no ffmpeg-pro. Anyway, what I did was I removed the -shortest option. Before that I had to add the -to option while generating the nice audio:

ffmpeg -i "20130912 1313 - Sky Cinema HD - Liebe.ts" -map 0:2 -ss 0:2:16.220 -to 2:04:27.000 Liebe.m4a

Now the audio and the video have pretty much the same length, only apart by a few milliseconds. Then muxing without -shortest generated a nice video with nice audio:

ffmpeg -i V:\et9200\Liebe.mp4 -i Liebe.m4a -map 0:0 -map 1:0 -c copy "Liebe neu.mp4"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.